You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by to...@apache.org on 2016/04/19 16:25:51 UTC
svn commit: r1739936 - in
/sling/trunk/contrib/extensions/distribution/extensions/src/test/java: ./
org/ org/apache/ org/apache/sling/ org/apache/sling/distribution/
org/apache/sling/distribution/serialization/
org/apache/sling/distribution/serializati...
Author: tommaso
Date: Tue Apr 19 14:25:51 2016
New Revision: 1739936
URL: http://svn.apache.org/viewvc?rev=1739936&view=rev
Log:
SLING-5577 - added missing tests for avro and kryo serializers
Added:
sling/trunk/contrib/extensions/distribution/extensions/src/test/java/
sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/
sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/
sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/
sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/distribution/
sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/distribution/serialization/
sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/distribution/serialization/impl/
sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/distribution/serialization/impl/avro/
sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/distribution/serialization/impl/avro/AvroContentSerializerTest.java (with props)
sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/distribution/serialization/impl/kryo/
sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/distribution/serialization/impl/kryo/KryoContentSerializerTest.java (with props)
Added: sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/distribution/serialization/impl/avro/AvroContentSerializerTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/distribution/serialization/impl/avro/AvroContentSerializerTest.java?rev=1739936&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/distribution/serialization/impl/avro/AvroContentSerializerTest.java (added)
+++ sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/distribution/serialization/impl/avro/AvroContentSerializerTest.java Tue Apr 19 14:25:51 2016
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.serialization.impl.avro;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.distribution.DistributionRequest;
+import org.apache.sling.distribution.DistributionRequestType;
+import org.apache.sling.distribution.SimpleDistributionRequest;
+import org.apache.sling.testing.resourceresolver.MockHelper;
+import org.apache.sling.testing.resourceresolver.MockResourceResolverFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests for {@link AvroContentSerializer}
+ */
+public class AvroContentSerializerTest {
+
+ private MockHelper helper;
+ private ResourceResolver resourceResolver;
+
+ @Before
+ public void setUp() throws Exception {
+ resourceResolver = new MockResourceResolverFactory().getResourceResolver(null);
+ helper = MockHelper.create(resourceResolver).resource("/libs").p("prop", "value")
+ .resource("sub").p("sub", "hello")
+ .resource(".sameLevel")
+ .resource("/apps").p("foo", "baa");
+ helper.commit();
+ }
+
+ @Test
+ public void testExtract() throws Exception {
+ AvroContentSerializer avroContentSerializer = new AvroContentSerializer("avro");
+ DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, "/libs");
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ avroContentSerializer.exportToStream(resourceResolver, request, outputStream);
+ byte[] bytes = outputStream.toByteArray();
+ assertNotNull(bytes);
+ assertTrue(bytes.length > 0);
+ }
+
+ @Test
+ public void testImport() throws Exception {
+ AvroContentSerializer avroContentSerializer = new AvroContentSerializer("avro");
+ InputStream inputStream = getClass().getResourceAsStream("/avro/dp.avro");
+ avroContentSerializer.importFromStream(resourceResolver, inputStream);
+ }
+}
Propchange: sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/distribution/serialization/impl/avro/AvroContentSerializerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/distribution/serialization/impl/kryo/KryoContentSerializerTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/distribution/serialization/impl/kryo/KryoContentSerializerTest.java?rev=1739936&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/distribution/serialization/impl/kryo/KryoContentSerializerTest.java (added)
+++ sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/distribution/serialization/impl/kryo/KryoContentSerializerTest.java Tue Apr 19 14:25:51 2016
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.serialization.impl.kryo;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.distribution.DistributionRequest;
+import org.apache.sling.distribution.DistributionRequestType;
+import org.apache.sling.distribution.SimpleDistributionRequest;
+import org.apache.sling.distribution.serialization.impl.avro.AvroContentSerializer;
+import org.apache.sling.testing.resourceresolver.MockHelper;
+import org.apache.sling.testing.resourceresolver.MockResourceResolverFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Tests for {@link KryoContentSerializer}
+ */
+public class KryoContentSerializerTest {
+
+ private MockHelper helper;
+ private ResourceResolver resourceResolver;
+
+ @Before
+ public void setUp() throws Exception {
+ resourceResolver = new MockResourceResolverFactory().getResourceResolver(null);
+ helper = MockHelper.create(resourceResolver).resource("/libs").p("prop", "value")
+ .resource("sub").p("sub", "hello")
+ .resource(".sameLevel")
+ .resource("/apps").p("foo", "baa");
+ helper.commit();
+ }
+
+ @Test
+ public void testExtract() throws Exception {
+ KryoContentSerializer kryoContentSerializer = new KryoContentSerializer("kryo");
+ DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, "/libs");
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ kryoContentSerializer.exportToStream(resourceResolver, request, outputStream);
+ byte[] bytes = outputStream.toByteArray();
+ assertNotNull(bytes);
+ }
+
+ @Test
+ public void testImport() throws Exception {
+ KryoContentSerializer kryoContentSerializer = new KryoContentSerializer("avro");
+ InputStream inputStream = getClass().getResourceAsStream("/kryo/dp.kryo");
+ kryoContentSerializer.importFromStream(resourceResolver, inputStream);
+ }
+}
Propchange: sling/trunk/contrib/extensions/distribution/extensions/src/test/java/org/apache/sling/distribution/serialization/impl/kryo/KryoContentSerializerTest.java
------------------------------------------------------------------------------
svn:eol-style = native