felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlean...@apache.org
Subject svn commit: r1791668 [2/2] - in /felix/trunk/converter/schematizer: ./ src/main/java/org/apache/felix/schematizer/ src/main/java/org/apache/felix/schematizer/impl/ src/main/java/org/apache/felix/serializer/impl/json/ src/test/java/org/apache/felix/sche...
Date Mon, 17 Apr 2017 08:52:05 GMT
Modified: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/SchematizerServiceTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/SchematizerServiceTest.java?rev=1791668&r1=1791667&r2=1791668&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/SchematizerServiceTest.java
(original)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/SchematizerServiceTest.java
Mon Apr 17 08:52:05 2017
@@ -23,9 +23,8 @@ import org.apache.felix.schematizer.Node
 import org.apache.felix.schematizer.Schema;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
-import org.osgi.util.converter.Converter;
-import org.osgi.util.converter.StandardConverter;
 import org.osgi.util.converter.TypeReference;
 
 import static org.junit.Assert.assertEquals;
@@ -34,13 +33,10 @@ import static org.junit.Assert.assertTru
 
 public class SchematizerServiceTest {
     private SchematizerImpl schematizer;
-    @SuppressWarnings( "unused" )
-    private Converter converter;
 
     @Before
     public void setUp() {
         schematizer = new SchematizerImpl();
-        converter = new StandardConverter();
     }
 
     @After
@@ -50,13 +46,9 @@ public class SchematizerServiceTest {
 
     @Test
     public void testSchematizeDTO() {
-        Optional<Schema> opt = schematizer
-                .rule("MyDTO", new TypeReference<MyDTO>(){})
-                .rule("MyDTO", "/embedded", new TypeReference<MyEmbeddedDTO>(){})
+        Schema s = schematizer
+                .schematize("MyDTO", new TypeReference<MyDTO>(){})
                 .get("MyDTO");
-
-        assertTrue(opt.isPresent());
-        Schema s = opt.get();
         assertNotNull(s);
         Node root = s.rootNode();
         assertNodeEquals("", "/", false, MyDTO.class, false, root);
@@ -77,34 +69,31 @@ public class SchematizerServiceTest {
         Node alphaNode = embeddedNode.children().get("/alpha");
         assertNodeEquals("alpha", "/embedded/alpha", false, MyEmbeddedDTO.Alpha.class, true,
alphaNode);
 
-        Node sRoot = s.nodeAtPath("/").get();
+        Node sRoot = s.nodeAtPath("/");
         assertNodeEquals("", "/", false, MyDTO.class, false, sRoot);
-        Node sPingNode = s.nodeAtPath("/ping").get();
+        Node sPingNode = s.nodeAtPath("/ping");
         assertNodeEquals("ping", "/ping", false, String.class, true, sPingNode);
-        Node sPongNode = s.nodeAtPath("/pong").get();
+        Node sPongNode = s.nodeAtPath("/pong");
         assertNodeEquals("pong", "/pong", false, Long.class, true, sPongNode);
-        Node sCountNode = s.nodeAtPath("/count").get();
+        Node sCountNode = s.nodeAtPath("/count");
         assertNodeEquals("count", "/count", false, MyDTO.Count.class, true, sCountNode);
-        Node sEmbeddedNode = s.nodeAtPath("/embedded").get();
+        Node sEmbeddedNode = s.nodeAtPath("/embedded");
         assertNodeEquals("embedded", "/embedded", false, MyEmbeddedDTO.class, true, sEmbeddedNode);
-        Node sMarcoNode = s.nodeAtPath("/embedded/marco").get();
+        Node sMarcoNode = s.nodeAtPath("/embedded/marco");
         assertNodeEquals("marco", "/embedded/marco", false, String.class, true, sMarcoNode);
-        Node sPoloNode = s.nodeAtPath("/embedded/polo").get();
+        Node sPoloNode = s.nodeAtPath("/embedded/polo");
         assertNodeEquals("polo", "/embedded/polo", false, Long.class, true, sPoloNode);
-        Node sAlphaNode = s.nodeAtPath("/embedded/alpha").get();
+        Node sAlphaNode = s.nodeAtPath("/embedded/alpha");
         assertNodeEquals("alpha", "/embedded/alpha", false, MyEmbeddedDTO.Alpha.class, true,
sAlphaNode);
     }
 
     @Test
     public void testSchematizeDTOWithColletion() {
-        Optional<Schema> opt = schematizer
-                .rule("MyDTO", new TypeReference<MyDTO3<MyEmbeddedDTO2<String>>>(){})
-                .rule("MyDTO", "/embedded", new TypeReference<MyEmbeddedDTO2<String>>(){})
-                .rule("MyDTO", "/embedded/value", String.class)
+        Schema s = schematizer
+                .type("MyDTO", "/embedded", new TypeReference<MyEmbeddedDTO2<String>>(){})
+                .type("MyDTO", "/embedded/value", String.class)
+                .schematize("MyDTO", new TypeReference<MyDTO3<MyEmbeddedDTO2<String>>>(){})
                 .get("MyDTO");
-
-        assertTrue(opt.isPresent());
-        Schema s = opt.get();
         assertNotNull(s);
         Node root = s.rootNode();
         assertNodeEquals("", "/", false, new TypeReference<MyDTO3<MyEmbeddedDTO2<String>>>(){}.getType(),
false, root);
@@ -121,28 +110,25 @@ public class SchematizerServiceTest {
         Node valueNode = embeddedNode.children().get("/value");
         assertNodeEquals("value", "/embedded/value", false, String.class, true, valueNode);
 
-        Node sRoot = s.nodeAtPath("/").get();
+        Node sRoot = s.nodeAtPath("/");
         assertNodeEquals("", "/", false, new TypeReference<MyDTO3<MyEmbeddedDTO2<String>>>(){}.getType(),
false, sRoot);
-        Node sPingNode = s.nodeAtPath("/ping").get();
+        Node sPingNode = s.nodeAtPath("/ping");
         assertNodeEquals("ping", "/ping", false, String.class, true, sPingNode);
-        Node sPongNode = s.nodeAtPath("/pong").get();
+        Node sPongNode = s.nodeAtPath("/pong");
         assertNodeEquals("pong", "/pong", false, Long.class, true, sPongNode);
-        Node sCountNode = s.nodeAtPath("/count").get();
+        Node sCountNode = s.nodeAtPath("/count");
         assertNodeEquals("count", "/count", false, MyDTO3.Count.class, true, sCountNode);
-        Node sEmbeddedNode = s.nodeAtPath("/embedded").get();
+        Node sEmbeddedNode = s.nodeAtPath("/embedded");
         assertNodeEquals("embedded", "/embedded", true, new TypeReference<MyEmbeddedDTO2<String>>(){}.getType(),
true, sEmbeddedNode);
-        Node sValueNode = s.nodeAtPath("/embedded/value").get();
+        Node sValueNode = s.nodeAtPath("/embedded/value");
         assertNodeEquals("value", "/embedded/value", false, String.class, true, sValueNode);
     }
 
     @Test
     public void testSchematizeDTOWithAnnotatedColletion() {
-        Optional<Schema> opt = schematizer
-                .rule("MyDTO4", new TypeReference<MyDTO4>(){})
+        Schema s = schematizer
+                .schematize("MyDTO4", new TypeReference<MyDTO4>(){})
                 .get("MyDTO4");
-
-        assertTrue(opt.isPresent());
-        Schema s = opt.get();
         assertNotNull(s);
         Node root = s.rootNode();
         assertNodeEquals("", "/", false, MyDTO4.class, false, root);
@@ -163,33 +149,29 @@ public class SchematizerServiceTest {
         Node alphaNode = embeddedNode.children().get("/alpha");
         assertNodeEquals("alpha", "/embedded/alpha", false, MyEmbeddedDTO.Alpha.class, true,
alphaNode);
 
-        Node sRoot = s.nodeAtPath("/").get();
+        Node sRoot = s.nodeAtPath("/");
         assertNodeEquals("", "/", false, MyDTO4.class, false, sRoot);
-        Node sPingNode = s.nodeAtPath("/ping").get();
+        Node sPingNode = s.nodeAtPath("/ping");
         assertNodeEquals("ping", "/ping", false, String.class, true, sPingNode);
-        Node sPongNode = s.nodeAtPath("/pong").get();
+        Node sPongNode = s.nodeAtPath("/pong");
         assertNodeEquals("pong", "/pong", false, Long.class, true, sPongNode);
-        Node sCountNode = s.nodeAtPath("/count").get();
+        Node sCountNode = s.nodeAtPath("/count");
         assertNodeEquals("count", "/count", false, MyDTO4.Count.class, true, sCountNode);
-        Node sEmbeddedNode = s.nodeAtPath("/embedded").get();
+        Node sEmbeddedNode = s.nodeAtPath("/embedded");
         assertNodeEquals("embedded", "/embedded", true, MyEmbeddedDTO.class, true, sEmbeddedNode);
-        Node sMarcoNode = s.nodeAtPath("/embedded/marco").get();
+        Node sMarcoNode = s.nodeAtPath("/embedded/marco");
         assertNodeEquals("marco", "/embedded/marco", false, String.class, true, sMarcoNode);
-        Node sPoloNode = s.nodeAtPath("/embedded/polo").get();
+        Node sPoloNode = s.nodeAtPath("/embedded/polo");
         assertNodeEquals("polo", "/embedded/polo", false, Long.class, true, sPoloNode);
-        Node sAlphaNode = s.nodeAtPath("/embedded/alpha").get();
+        Node sAlphaNode = s.nodeAtPath("/embedded/alpha");
         assertNodeEquals("alpha", "/embedded/alpha", false, MyEmbeddedDTO.Alpha.class, true,
sAlphaNode);
     }
 
     @Test
     public void testSchematizeToMap() {
-        Optional<Schema> opt = schematizer
-                .rule("MyDTO", new TypeReference<MyDTO>(){})
-                .rule("MyDTO", "/embedded", new TypeReference<MyEmbeddedDTO>(){})
+        Schema s = schematizer
+                .schematize("MyDTO", new TypeReference<MyDTO>(){})
                 .get("MyDTO");
-
-        assertTrue(opt.isPresent());
-        Schema s = opt.get();
         Map<String, Node.DTO> map = s.toMap();
         testMapValues(map);
     }
@@ -218,20 +200,15 @@ public class SchematizerServiceTest {
     }
 
     @Test
+    @Ignore("Probably no longer necessary...")
     public void testSchemaFromMap() {
-        Optional<Schema> opt1 = schematizer
-                .rule("MyDTO", new TypeReference<MyDTO>(){})
-                .rule("MyDTO", "/embedded", new TypeReference<MyEmbeddedDTO>(){})
+        Schema s1 = schematizer
+                .schematize("MyDTO", new TypeReference<MyDTO>(){})
                 .get("MyDTO");
-
-        assertTrue(opt1.isPresent());
-        Schema s1 = opt1.get();
         Map<String, Node.DTO> map = s1.toMap();
 
-        Optional<Schema> opt2 = schematizer.from("MyDTO", map);
-        assertTrue(opt1.isPresent());
-        Schema s2 = opt2.get();
-        testSchema(s2);
+//        Schema s2 = schematizer.from("MyDTO", map);
+//        testSchema(s2);
     }
 
     private void testSchema(Schema s) {
@@ -256,34 +233,29 @@ public class SchematizerServiceTest {
         Node alphaNode = embeddedNode.children().get("/alpha");
         assertNodeEquals("alpha", "/embedded/alpha", false, MyEmbeddedDTO.Alpha.class, true,
alphaNode);
 
-        Node sRoot = s.nodeAtPath("/").get();
+        Node sRoot = s.nodeAtPath("/");
         assertNodeEquals("", "/", false, MyDTO.class, false, sRoot);
-        Node sPingNode = s.nodeAtPath("/ping").get();
+        Node sPingNode = s.nodeAtPath("/ping");
         assertNodeEquals("ping", "/ping", false, String.class, true, sPingNode);
-        Node sPongNode = s.nodeAtPath("/pong").get();
+        Node sPongNode = s.nodeAtPath("/pong");
         assertNodeEquals("pong", "/pong", false, Long.class, true, sPongNode);
-        Node sCountNode = s.nodeAtPath("/count").get();
+        Node sCountNode = s.nodeAtPath("/count");
         assertNodeEquals("count", "/count", false, MyDTO.Count.class, true, sCountNode);
-        Node sEmbeddedNode = s.nodeAtPath("/embedded").get();
+        Node sEmbeddedNode = s.nodeAtPath("/embedded");
         assertNodeEquals("embedded", "/embedded", false, MyEmbeddedDTO.class, true, sEmbeddedNode);
-        Node sMarcoNode = s.nodeAtPath("/embedded/marco").get();
+        Node sMarcoNode = s.nodeAtPath("/embedded/marco");
         assertNodeEquals("marco", "/embedded/marco", false, String.class, true, sMarcoNode);
-        Node sPoloNode = s.nodeAtPath("/embedded/polo").get();
+        Node sPoloNode = s.nodeAtPath("/embedded/polo");
         assertNodeEquals("polo", "/embedded/polo", false, Long.class, true, sPoloNode);
-        Node sAlphaNode = s.nodeAtPath("/embedded/alpha").get();
+        Node sAlphaNode = s.nodeAtPath("/embedded/alpha");
         assertNodeEquals("alpha", "/embedded/alpha", false, MyEmbeddedDTO.Alpha.class, true,
sAlphaNode);
     }
 
     @Test
     public void testVisitor() {
-        Optional<Schema> opt = schematizer
-                .rule("MyDTO", new TypeReference<MyDTO>(){})
-                .rule("MyDTO", "/embedded", new TypeReference<MyEmbeddedDTO>(){})
+        Schema s = schematizer
+                .schematize("MyDTO", new TypeReference<MyDTO>(){})
                 .get("MyDTO");
-
-        assertTrue(opt.isPresent());
-        Schema s = opt.get();
-
         StringBuilder sb = new StringBuilder();
         s.visit( n -> sb.append("::").append(n.name()));
         assertEquals("::::count::embedded::alpha::marco::polo::ping::pong", sb.toString());
@@ -291,41 +263,34 @@ public class SchematizerServiceTest {
 
     @Test
     public void testGetParentNode() {
-        Optional<Schema> opt = schematizer
-                .rule("MyDTO", new TypeReference<MyDTO>(){})
-                .rule("MyDTO", "/embedded", new TypeReference<MyEmbeddedDTO>(){})
+        Schema s = schematizer
+                .schematize("MyDTO", new TypeReference<MyDTO>(){})
                 .get("MyDTO");
-
-        assertTrue(opt.isPresent());
-        Schema s = opt.get();
         assertNotNull(s);
-        Optional<Node> embeddedNode = s.nodeAtPath("/embedded/marco");
-        assertTrue(embeddedNode.isPresent());
-        Optional<Node> parentNode = s.parentOf(embeddedNode.get());
-        assertTrue(parentNode.isPresent());
-        Optional<Node> grandparentNode = s.parentOf(parentNode.get());
-        assertTrue(grandparentNode.isPresent());
-        assertEquals("/", grandparentNode.get().absolutePath());
+        Node embeddedNode = s.nodeAtPath("/embedded/marco");
+        assertTrue(!"ERROR".equals(embeddedNode.name()));
+        Node parentNode = s.parentOf(embeddedNode);
+        assertTrue(!"ERROR".equals(parentNode.name()));
+        Node grandparentNode = s.parentOf(parentNode);
+        assertTrue(!"ERROR".equals(grandparentNode.name()));
+        assertEquals("/", grandparentNode.absolutePath());
     }
 
     @Test
-    public void testGetParentNode2() {
-        Optional<Schema> opt = schematizer
-                .rule("MyDTO", new TypeReference<MyDTO3<MyEmbeddedDTO2<String>>>(){})
-                .rule("MyDTO", "/embedded", new TypeReference<MyEmbeddedDTO2<String>>(){})
-                .rule("MyDTO", "/embedded/value", String.class)
+    public void testTypeRules() {
+        Schema s = schematizer
+                .type("MyDTO", "/embedded", new TypeReference<MyEmbeddedDTO2<String>>(){})
+                .type("MyDTO", "/embedded/value", String.class)
+                .schematize("MyDTO", new TypeReference<MyDTO3<MyEmbeddedDTO2<String>>>(){})
                 .get("MyDTO");
-
-        assertTrue(opt.isPresent());
-        Schema s = opt.get();
         assertNotNull(s);
-        Optional<Node> embeddedNode = s.nodeAtPath("/embedded/value");
-        assertTrue(embeddedNode.isPresent());
-        Optional<Node> parentNode = s.parentOf(embeddedNode.get());
-        assertTrue(parentNode.isPresent());
-        Optional<Node> grandparentNode = s.parentOf(parentNode.get());
-        assertTrue(grandparentNode.isPresent());
-        assertEquals("/", grandparentNode.get().absolutePath());
+        Node embeddedNode = s.nodeAtPath("/embedded/value");
+        assertTrue(!"ERROR".equals(embeddedNode.name()));
+        Node parentNode = s.parentOf(embeddedNode);
+        assertTrue(!"ERROR".equals(parentNode.name()));
+        Node grandparentNode = s.parentOf(parentNode);
+        assertTrue(!"ERROR".equals(grandparentNode.name()));
+        assertEquals("/", grandparentNode.absolutePath());
     }
 
     private void assertNodeEquals(String name, String path, boolean isCollection, Object
type, boolean fieldNotNull, Node node) {

Modified: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/JsonDeserializationTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/JsonDeserializationTest.java?rev=1791668&r1=1791667&r2=1791668&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/JsonDeserializationTest.java
(original)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/JsonDeserializationTest.java
Mon Apr 17 08:52:05 2017
@@ -17,32 +17,26 @@
 package org.apache.felix.serializer.impl.json;
 
 import java.util.ArrayList;
-import java.util.Optional;
 
-import org.apache.felix.schematizer.Schema;
-import org.apache.felix.schematizer.SchematizingConverter;
 import org.apache.felix.schematizer.impl.SchematizerImpl;
 import org.apache.felix.serializer.impl.json.MyDTO.Count;
 import org.apache.felix.serializer.impl.json.MyEmbeddedDTO.Alpha;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.osgi.util.converter.Converter;
 import org.osgi.util.converter.TypeReference;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 public class JsonDeserializationTest {
-    private SchematizingConverter converter;
 
     @Before
     public void setUp() {
-        converter = new SchematizingConverter();
     }
 
     @After
     public void tearDown() {
-        converter = null;
     }
 
     @Test
@@ -58,20 +52,13 @@ public class JsonDeserializationTest {
         dto.count = Count.TWO;
         dto.embedded = embedded;
 
-        // TODO
-        Optional<Schema> opt = new SchematizerImpl()
-            .rule("MyDTO", new TypeReference<MyDTO>(){})
-            .rule("MyDTO", "/embedded", new TypeReference<MyEmbeddedDTO>(){})
-            .get("MyDTO");
-
-        assertTrue(opt.isPresent());
-
-        Schema s = opt.get();
-
-        String serialized = new JsonSerializerImpl().serialize(dto).with(converter.withSchema(s)).toString();
+        Converter c = new SchematizerImpl()
+                .schematize("MyDTO", new TypeReference<MyDTO>(){})
+                .converterFor("MyDTO");
+        String serialized = new JsonSerializerImpl().serialize(dto).with(c).toString();
         MyDTO result = new JsonSerializerImpl()
                 .deserialize(MyDTO.class)
-                .with(converter.withSchema(s))
+                .with(c)
                 .from(serialized);
 
         assertEquals(dto.ping, result.ping);
@@ -95,19 +82,13 @@ public class JsonDeserializationTest {
 
         String serialized = new JsonSerializerImpl().serialize(dto).toString();
 
-        Optional<Schema> opt = new SchematizerImpl()
-                .rule("MyDTO", new TypeReference<MyDTO2<MyEmbeddedDTO2<String>>>(){})
-                .rule("MyDTO", "/embedded", new TypeReference<MyEmbeddedDTO2<String>>(){})
-                .rule("MyDTO", "/embedded/value", String.class)
-                .get("MyDTO");
-
-        assertTrue(opt.isPresent());
-
-        Schema s = opt.get();
-        MyDTO2<MyEmbeddedDTO2<String>> result =
-                new JsonSerializerImpl()
+        Converter c = new SchematizerImpl()
+                .type("MyDTO", "/embedded", new TypeReference<MyEmbeddedDTO2<String>>(){})
+                .schematize("MyDTO", new TypeReference<MyDTO2<MyEmbeddedDTO2<String>>>(){})
+                .converterFor("MyDTO");
+        MyDTO2<MyEmbeddedDTO2<String>> result = new JsonSerializerImpl()
                 .deserialize(new TypeReference<MyDTO2<MyEmbeddedDTO2<String>>>(){})
-                .with(converter.withSchema(s))
+                .with(c)
                 .from(serialized);
 
         assertEquals(dto.ping, result.ping);

Modified: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyEmbeddedDTO2.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyEmbeddedDTO2.java?rev=1791668&r1=1791667&r2=1791668&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyEmbeddedDTO2.java
(original)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyEmbeddedDTO2.java
Mon Apr 17 08:52:05 2017
@@ -16,8 +16,10 @@
  */
 package org.apache.felix.serializer.impl.json;
 
+import org.apache.felix.schematizer.AsDTO;
 import org.osgi.dto.DTO;
 
+@AsDTO
 public class MyEmbeddedDTO2<T> extends DTO {
     public T value;
 }

Modified: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/RepositorySerializationTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/RepositorySerializationTest.java?rev=1791668&r1=1791667&r2=1791668&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/RepositorySerializationTest.java
(original)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/RepositorySerializationTest.java
Mon Apr 17 08:52:05 2017
@@ -55,7 +55,6 @@ import static org.junit.Assert.assertTru
  *
  * @author David Leangen
  */
-@Ignore("This test fails, need to fix")
 public class RepositorySerializationTest
 {
     private SimpleManager simpleManager;
@@ -75,6 +74,7 @@ public class RepositorySerializationTest
 	}
 
     @Test
+    @Ignore("temporary")
 	public void shouldPutAndRemoveSimpleEntitiesFromStore() {
 		simpleManager.clear();
 		final SimpleTopEntity e1 = factory.newSimpleTop( "ID01", "Value01", null );
@@ -115,6 +115,7 @@ public class RepositorySerializationTest
 	}
 
     @Test
+    @Ignore("temporary")
     public void shouldPutAndRemoveComplexEntityFromStore() {
         complexManager.clear();
         assertTrue( complexManager.list().isEmpty() );
@@ -155,6 +156,7 @@ public class RepositorySerializationTest
     }
 
     @Test
+    @Ignore("temporary")
     public void shouldPutAllToStore() {
         complexManager.clear();
         assertTrue( complexManager.list().isEmpty() );
@@ -205,6 +207,7 @@ public class RepositorySerializationTest
     }
 
     @Test
+    @Ignore("temporary")
 	public void shouldIterateThroughKeysAndValues() {
 	    simpleManager.clear();
 

Modified: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexManagerService.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexManagerService.java?rev=1791668&r1=1791667&r2=1791668&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexManagerService.java
(original)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexManagerService.java
Mon Apr 17 08:52:05 2017
@@ -16,19 +16,15 @@
  */
 package org.apache.felix.serializer.test.objects.provider;
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Optional;
 import java.util.stream.Collectors;
 
-import org.apache.felix.schematizer.TypeRule;
 import org.apache.felix.serializer.test.objects.ComplexManager;
 import org.apache.felix.serializer.test.objects.ComplexTop;
-import org.apache.felix.serializer.test.prevayler.AggregateTypeReference;
 import org.apache.felix.serializer.test.prevayler.MockPrevaylerBackedRepository;
 import org.apache.felix.serializer.test.prevayler.Repository;
-import org.osgi.util.converter.TypeReference;
 
 public class ComplexManagerService
 	implements ComplexManager
@@ -36,14 +32,7 @@ public class ComplexManagerService
     private final Repository<ComplexTopEntity> repository;
 
     public ComplexManagerService() {
-        final List<TypeRule<?>> rules = new ArrayList<>();
-        rules.add( new TypeRule<>( "/entity", new TypeReference<Object>(){
-            @Override
-            public java.lang.reflect.Type getType()
-            {
-                return new AggregateTypeReference( null, ComplexTopEntity.class, new java.lang.reflect.Type(){}
).getType();
-            }} ) );
-        repository = new MockPrevaylerBackedRepository<>(rules, ComplexTopEntity.class);
+        repository = new MockPrevaylerBackedRepository<>(ComplexTopEntity.class);
     }
 
     @Override

Modified: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleManagerService.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleManagerService.java?rev=1791668&r1=1791667&r2=1791668&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleManagerService.java
(original)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleManagerService.java
Mon Apr 17 08:52:05 2017
@@ -16,18 +16,14 @@
  */
 package org.apache.felix.serializer.test.objects.provider;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
 import java.util.stream.Collectors;
 
-import org.apache.felix.schematizer.TypeRule;
 import org.apache.felix.serializer.test.objects.SimpleManager;
 import org.apache.felix.serializer.test.objects.SimpleTop;
-import org.apache.felix.serializer.test.prevayler.AggregateTypeReference;
 import org.apache.felix.serializer.test.prevayler.MockPrevaylerBackedRepository;
 import org.apache.felix.serializer.test.prevayler.Repository;
-import org.osgi.util.converter.TypeReference;
 
 public class SimpleManagerService
 	implements SimpleManager
@@ -37,14 +33,7 @@ public class SimpleManagerService
 	private final Repository<SimpleTopEntity> repository;
 
 	public SimpleManagerService() {
-        final List<TypeRule<?>> rules = new ArrayList<>();
-        rules.add( new TypeRule<>( "/entity", new TypeReference<Object>(){
-            @Override
-            public java.lang.reflect.Type getType()
-            {
-                return new AggregateTypeReference( null, SimpleTopEntity.class, new java.lang.reflect.Type(){}
).getType();
-            }} ) );
-	    repository = new MockPrevaylerBackedRepository<>(rules, SimpleTopEntity.class);
+	    repository = new MockPrevaylerBackedRepository<>(SimpleTopEntity.class);
     }
 
 	@Override

Modified: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/DTOSerializer.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/DTOSerializer.java?rev=1791668&r1=1791667&r2=1791668&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/DTOSerializer.java
(original)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/DTOSerializer.java
Mon Apr 17 08:52:05 2017
@@ -18,38 +18,22 @@ package org.apache.felix.serializer.test
 
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.lang.reflect.Type;
 import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-import org.apache.felix.schematizer.Schema;
 import org.apache.felix.schematizer.Schematizer;
-import org.apache.felix.schematizer.SchematizingConverter;
-import org.apache.felix.schematizer.TypeRule;
 import org.apache.felix.schematizer.impl.SchematizerImpl;
 import org.apache.felix.serializer.impl.json.JsonSerializerImpl;
-import org.osgi.util.converter.TypeReference;
+import org.osgi.util.converter.Converter;
 
 public class DTOSerializer<C extends CommandDTO<?>>
 {
     private static final int MARKER_LENGTH = 10;
 
-    private final SchematizingConverter converter = new SchematizingConverter();
+    private final Schematizer schematizer = new SchematizerImpl();
     private final JsonSerializerImpl serializer = new JsonSerializerImpl();
-    private final List<TypeRule<?>> rules;
-    private final Map<String, Schema> schemas = new HashMap<>();
     private final Class<?> entityType;
 
-    public DTOSerializer(
-            List<TypeRule<?>> aRulesList,
-            Class<?> anEntityType )
+    public DTOSerializer(Class<?> anEntityType)
     {
-        rules = new ArrayList<>();
-        rules.addAll( aRulesList );
         entityType = anEntityType;
     }
 
@@ -58,44 +42,22 @@ public class DTOSerializer<C extends Com
             throws Exception
     {
         Command command = parseCommandFrom( in );
-        Schema s = schemas.get( command.name() );
+        Converter c = schematizer.converterFor( command.name() );
         return (C)serializer
                 .deserialize( CommandDTO.class )
-                .with( converter.withSchema( s ) )
+                .with( c )
                 .from( in );
     }
 
-    @SuppressWarnings( { "unchecked", "rawtypes" } )
     public void serialize( OutputStream out, C command )
             throws Exception
     {
         // Lazy load the schemas as we collect new types to serialize
         String name = command.command.name();
-        if( !schemas.containsKey( name ) )
-        {
-            Schematizer s = new SchematizerImpl()
-                    .rule( name, new TypeReference(){
-                        @Override
-                        public Type getType()
-                        {
-                            return new AggregateTypeReference( null, command.getClass(),
entityType ).getType();
-                        }
-                    } );
-            rules.stream()
-                .forEach( r -> s.rule( name, (TypeRule)r ) );
-            Optional<Schema> opt = s.get( name );
-
-            // TODO: What do we do if there is no schema?? Just continue anyway?
-            if( opt.isPresent() )
-            {
-                Schema schema = opt.get();
-                schemas.put( name, schema );
-            }
-        }
-
+        schematizer.schematize( name, entityType ).get( name );
         out.write( markerFor( command.command ) );
-        Schema s = schemas.get( name );
-        serializer.serialize( command ).with( converter.withSchema( s ) ).to( out );
+        Converter c = schematizer.converterFor(name);
+        serializer.serialize( command ).with( c ).to( out );
     }
 
     private final byte[] markerFor( Command command )

Modified: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/MockPrevaylerBackedRepository.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/MockPrevaylerBackedRepository.java?rev=1791668&r1=1791667&r2=1791668&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/MockPrevaylerBackedRepository.java
(original)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/prevayler/MockPrevaylerBackedRepository.java
Mon Apr 17 08:52:05 2017
@@ -24,8 +24,6 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.stream.Collectors;
 
-import org.apache.felix.schematizer.TypeRule;
-
 public class MockPrevaylerBackedRepository<E>
     implements Repository<E>
 {
@@ -33,8 +31,8 @@ public class MockPrevaylerBackedReposito
     private final DTOSerializer<CommandDTO<?>> serializer;
     private final MockPrevaylerSerializer prevayler;
 
-    public MockPrevaylerBackedRepository(List<TypeRule<?>> rules, Class<E>
anEntityType) {
-        serializer = new DTOSerializer<>(rules, anEntityType);
+    public MockPrevaylerBackedRepository(Class<E> anEntityType) {
+        serializer = new DTOSerializer<>(anEntityType);
         prevayler = new SerializerAdapter(serializer);
     }
 



Mime
View raw message