You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by da...@apache.org on 2016/09/26 12:46:49 UTC

svn commit: r1762334 [2/3] - in /felix/trunk/converter: ./ schematizer/ schematizer/src/ schematizer/src/main/ schematizer/src/main/java/ schematizer/src/main/java/org/ schematizer/src/main/java/org/apache/ schematizer/src/main/java/org/apache/felix/ s...

Added: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializingImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializingImpl.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializingImpl.java (added)
+++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonSerializingImpl.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,163 @@
+/*
+ * 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.felix.serializer.impl.json;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.reflect.Array;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.osgi.dto.DTO;
+import org.osgi.service.converter.ConversionException;
+import org.osgi.service.converter.Converter;
+import org.osgi.service.serializer.Serializing;
+
+public class JsonSerializingImpl implements Serializing {
+    private volatile Converter converter;
+    private final Map<String, Object> configuration;
+    private final Object object;
+    private final boolean ignoreNull;
+
+    JsonSerializingImpl(Converter c, Map<String, Object> cfg, Object obj) {
+        converter = c;
+        configuration = cfg;
+        ignoreNull = Boolean.TRUE.equals(Boolean.parseBoolean((String) configuration.get("ignoreNull")));
+        object = obj;
+    }
+
+    @Override
+    public Appendable to(Appendable out) {
+        try {
+            out.append(encode(object));
+            return out;
+        } catch (IOException e) {
+            throw new ConversionException("Problem converting to JSON", e);
+        }
+    }
+
+    @Override
+    public void to(OutputStream os, Charset charset) {
+        try {
+            os.write(encode(object).getBytes(charset));
+        } catch (IOException e) {
+            throw new ConversionException("Problem converting to JSON", e);
+        }
+    }
+
+    @Override
+    public void to(OutputStream out) throws IOException {
+        to(out, StandardCharsets.UTF_8);
+    }
+
+    @Override
+    public String toString() {
+        return encode(object);
+    }
+
+    @SuppressWarnings("rawtypes")
+    private String encode(Object obj) {
+        if (obj == null) {
+            return ignoreNull ? "" : "null";
+        }
+
+        if (obj instanceof Map) {
+            return encodeMap((Map) obj);
+        } else if (obj instanceof Collection) {
+            return encodeCollection((Collection) obj);
+        } else if (obj instanceof DTO) {
+            return encodeMap(converter.convert(obj).to(Map.class));
+        } else if (obj.getClass().isArray()) {
+            return encodeCollection(asCollection(obj));
+        } else if (obj instanceof Number) {
+            return obj.toString();
+        } else if (obj instanceof Boolean) {
+            return obj.toString();
+        }
+
+        return "\"" + converter.convert(obj).to(String.class) + "\"";
+    }
+
+    private Collection<?> asCollection(Object arr) {
+        // Arrays.asList() doesn't work for primitive arrays
+        int len = Array.getLength(arr);
+        List<Object> l = new ArrayList<>(len);
+        for (int i=0; i<len; i++) {
+            l.add(Array.get(arr, i));
+        }
+        return l;
+    }
+
+    private String encodeCollection(Collection<?> collection) {
+        StringBuilder sb = new StringBuilder("[");
+
+        boolean first = true;
+        for (Object o : collection) {
+            if (first)
+                first = false;
+            else
+                sb.append(',');
+
+            sb.append(encode(o));
+        }
+
+        sb.append("]");
+        return sb.toString();
+    }
+
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    private String encodeMap(Map m) {
+        StringBuilder sb = new StringBuilder("{");
+        for (Entry entry : (Set<Entry>) m.entrySet()) {
+            if (entry.getKey() == null || entry.getValue() == null)
+                if (ignoreNull)
+                    continue;
+
+            if (sb.length() > 1)
+                sb.append(',');
+            sb.append('"');
+            sb.append(entry.getKey().toString());
+            sb.append("\":");
+            sb.append(encode(entry.getValue()));
+        }
+        sb.append("}");
+
+        return sb.toString();
+    }
+
+    @Override
+    public Serializing ignoreNull() {
+        return this;
+    }
+
+    @Override
+    public Serializing pretty() {
+        return this;
+    }
+
+    @Override
+    public Serializing with(Converter c) {
+        converter = c;
+        return this;
+    }
+}

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyBean.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyBean.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyBean.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyBean.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,61 @@
+/*
+ * 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.felix.schematizer.impl;
+
+public class MyBean {
+    String me;
+    boolean enabled;
+    Boolean f;
+    int[] numbers;
+
+    public String get() {
+        return "Not a bean accessor because no camel casing";
+    }
+    public String gettisburgh() {
+        return "Not a bean accessor because no camel casing";
+    }
+    public int issue() {
+        return -1; // not a bean accessor as no camel casing
+    }
+    public void sets(String s) {
+        throw new RuntimeException("Not a bean accessor because no camel casing");
+    }
+    public String getMe() {
+        return me;
+    }
+    public void setMe(String me) {
+        this.me = me;
+    }
+    public boolean isEnabled() {
+        return enabled;
+    }
+    public void setEnabled(boolean enabled) {
+        this.enabled = enabled;
+    }
+    public Boolean getF() {
+        return f;
+    }
+    public void setF(Boolean f) {
+        this.f = f;
+    }
+    public int[] getNumbers() {
+        return numbers;
+    }
+    public void setNumbers(int[] numbers) {
+        this.numbers = numbers;
+    }
+}

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyDTO.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyDTO.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyDTO.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyDTO.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,32 @@
+/*
+ * 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.felix.schematizer.impl;
+
+import org.osgi.dto.DTO;
+
+public class MyDTO extends DTO {
+    public enum Count { ONE, TWO, THREE }
+
+    public Count count;
+
+    public String ping;
+
+    public long pong;
+
+    public MyEmbeddedDTO embedded;
+}
+

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyDTO2.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyDTO2.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyDTO2.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyDTO2.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,26 @@
+/*
+ * 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.felix.schematizer.impl;
+
+import org.osgi.dto.DTO;
+
+public class MyDTO2<T1, T2> extends DTO {
+    public T1 value;
+
+    public T2 embedded;
+}
+

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyDTO3.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyDTO3.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyDTO3.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyDTO3.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,81 @@
+/*
+    @Test
+    public void testSchematizeDTO() {
+        Optional<Schema> opt = schematizer
+                .rule("MyDTO", new TypeReference<MyDTO>(){})
+                .rule("MyDTO", "/embedded", new TypeReference<MyEmbeddedDTO>(){})
+                .get("MyDTO");
+
+        assertTrue(opt.isPresent());
+        Schema s = opt.get();
+        assertNotNull(s);
+        Node root = s.rootNode();
+        assertNodeEquals("", "/", false, MyDTO.class, root);
+        assertEquals(4, root.children().size());
+        Node pingNode = root.children().get("/ping");
+        assertNodeEquals("ping", "/ping", false, String.class, pingNode);
+        Node pongNode = root.children().get("/pong");
+        assertNodeEquals("pong", "/pong", false, Long.class, pongNode);
+        Node countNode = root.children().get("/count");
+        assertNodeEquals("count", "/count", false, MyDTO.Count.class, countNode);
+        Node embeddedNode = root.children().get("/embedded");
+        assertEquals(3, embeddedNode.children().size());
+        assertNodeEquals("embedded", "/embedded", false, MyEmbeddedDTO.class, embeddedNode);
+        Node marcoNode = embeddedNode.children().get("/marco");
+        assertNodeEquals("marco", "/embedded/marco", false, String.class, marcoNode);
+        Node poloNode = embeddedNode.children().get("/polo");
+        assertNodeEquals("polo", "/embedded/polo", false, Long.class, poloNode);
+        Node alphaNode = embeddedNode.children().get("/alpha");
+        assertNodeEquals("alpha", "/embedded/alpha", false, MyEmbeddedDTO.Alpha.class, alphaNode);
+
+        Node sRoot = s.nodeAtPath("/").get();
+        assertNodeEquals("", "/", false, MyDTO.class, sRoot);
+        Node sPingNode = s.nodeAtPath("/ping").get();
+        assertNodeEquals("ping", "/ping", false, String.class, sPingNode);
+        Node sPongNode = s.nodeAtPath("/pong").get();
+        assertNodeEquals("pong", "/pong", false, Long.class, sPongNode);
+        Node sCountNode = s.nodeAtPath("/count").get();
+        assertNodeEquals("count", "/count", false, MyDTO.Count.class, sCountNode);
+        Node sEmbeddedNode = s.nodeAtPath("/embedded").get();
+        assertNodeEquals("embedded", "/embedded", false, MyEmbeddedDTO.class, sEmbeddedNode);
+        Node sMarcoNode = s.nodeAtPath("/embedded/marco").get();
+        assertNodeEquals("marco", "/embedded/marco", false, String.class, sMarcoNode);
+        Node sPoloNode = s.nodeAtPath("/embedded/polo").get();
+        assertNodeEquals("polo", "/embedded/polo", false, Long.class, sPoloNode);
+        Node sAlphaNode = s.nodeAtPath("/embedded/alpha").get();
+        assertNodeEquals("alpha", "/embedded/alpha", false, MyEmbeddedDTO.Alpha.class, sAlphaNode);
+    }
+
+ * 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.felix.schematizer.impl;
+
+import java.util.List;
+
+import org.osgi.dto.DTO;
+
+public class MyDTO3<T> extends DTO {
+    public enum Count { ONE, TWO, THREE }
+
+    public Count count;
+
+    public String ping;
+
+    public long pong;
+
+    public List<T> embedded;
+}
+

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyEmbeddedDTO.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyEmbeddedDTO.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyEmbeddedDTO.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyEmbeddedDTO.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,29 @@
+/*
+ * 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.felix.schematizer.impl;
+
+import org.osgi.dto.DTO;
+
+public class MyEmbeddedDTO extends DTO {
+    public enum Alpha { A, B, C }
+
+    public Alpha alpha;
+
+    public String marco;
+
+    public long polo;
+}

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyEmbeddedDTO2.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyEmbeddedDTO2.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyEmbeddedDTO2.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MyEmbeddedDTO2.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,24 @@
+/*
+ * 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.felix.schematizer.impl;
+
+import org.osgi.dto.DTO;
+
+public class MyEmbeddedDTO2<T> extends DTO {
+    public T value;
+}
+

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MySubDTO.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MySubDTO.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MySubDTO.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/MySubDTO.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,21 @@
+/*
+ * 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.felix.schematizer.impl;
+
+public class MySubDTO extends MyDTO {
+    public String ping;
+}

Added: 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=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/SchematizerServiceTest.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/schematizer/impl/SchematizerServiceTest.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,261 @@
+/*
+ * 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.felix.schematizer.impl;
+
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.felix.schematizer.Node;
+import org.apache.felix.schematizer.Schema;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.service.converter.Converter;
+import org.osgi.service.converter.StandardConverter;
+import org.osgi.service.converter.TypeReference;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class SchematizerServiceTest {
+    private SchematizerImpl schematizer;
+    @SuppressWarnings( "unused" )
+    private Converter converter;
+
+    @Before
+    public void setUp() {
+        schematizer = new SchematizerImpl();
+        converter = new StandardConverter();
+    }
+
+    @After
+    public void tearDown() {
+        schematizer = null;
+    }
+
+    @Test
+    public void testSchematizeDTO() {
+        Optional<Schema> opt = schematizer
+                .rule("MyDTO", new TypeReference<MyDTO>(){})
+                .rule("MyDTO", "/embedded", new TypeReference<MyEmbeddedDTO>(){})
+                .get("MyDTO");
+
+        assertTrue(opt.isPresent());
+        Schema s = opt.get();
+        assertNotNull(s);
+        Node root = s.rootNode();
+        assertNodeEquals("", "/", false, MyDTO.class, root);
+        assertEquals(4, root.children().size());
+        Node pingNode = root.children().get("/ping");
+        assertNodeEquals("ping", "/ping", false, String.class, pingNode);
+        Node pongNode = root.children().get("/pong");
+        assertNodeEquals("pong", "/pong", false, Long.class, pongNode);
+        Node countNode = root.children().get("/count");
+        assertNodeEquals("count", "/count", false, MyDTO.Count.class, countNode);
+        Node embeddedNode = root.children().get("/embedded");
+        assertEquals(3, embeddedNode.children().size());
+        assertNodeEquals("embedded", "/embedded", false, MyEmbeddedDTO.class, embeddedNode);
+        Node marcoNode = embeddedNode.children().get("/marco");
+        assertNodeEquals("marco", "/embedded/marco", false, String.class, marcoNode);
+        Node poloNode = embeddedNode.children().get("/polo");
+        assertNodeEquals("polo", "/embedded/polo", false, Long.class, poloNode);
+        Node alphaNode = embeddedNode.children().get("/alpha");
+        assertNodeEquals("alpha", "/embedded/alpha", false, MyEmbeddedDTO.Alpha.class, alphaNode);
+
+        Node sRoot = s.nodeAtPath("/").get();
+        assertNodeEquals("", "/", false, MyDTO.class, sRoot);
+        Node sPingNode = s.nodeAtPath("/ping").get();
+        assertNodeEquals("ping", "/ping", false, String.class, sPingNode);
+        Node sPongNode = s.nodeAtPath("/pong").get();
+        assertNodeEquals("pong", "/pong", false, Long.class, sPongNode);
+        Node sCountNode = s.nodeAtPath("/count").get();
+        assertNodeEquals("count", "/count", false, MyDTO.Count.class, sCountNode);
+        Node sEmbeddedNode = s.nodeAtPath("/embedded").get();
+        assertNodeEquals("embedded", "/embedded", false, MyEmbeddedDTO.class, sEmbeddedNode);
+        Node sMarcoNode = s.nodeAtPath("/embedded/marco").get();
+        assertNodeEquals("marco", "/embedded/marco", false, String.class, sMarcoNode);
+        Node sPoloNode = s.nodeAtPath("/embedded/polo").get();
+        assertNodeEquals("polo", "/embedded/polo", false, Long.class, sPoloNode);
+        Node sAlphaNode = s.nodeAtPath("/embedded/alpha").get();
+        assertNodeEquals("alpha", "/embedded/alpha", false, MyEmbeddedDTO.Alpha.class, 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)
+                .get("MyDTO");
+
+        assertTrue(opt.isPresent());
+        Schema s = opt.get();
+        assertNotNull(s);
+        Node root = s.rootNode();
+        assertNodeEquals("", "/", false, new TypeReference<MyDTO3<MyEmbeddedDTO2<String>>>(){}.getType(), root);
+        assertEquals(4, root.children().size());
+        Node pingNode = root.children().get("/ping");
+        assertNodeEquals("ping", "/ping", false, String.class, pingNode);
+        Node pongNode = root.children().get("/pong");
+        assertNodeEquals("pong", "/pong", false, Long.class, pongNode);
+        Node countNode = root.children().get("/count");
+        assertNodeEquals("count", "/count", false, MyDTO3.Count.class, countNode);
+        Node embeddedNode = root.children().get("/embedded");
+        assertEquals(1, embeddedNode.children().size());
+        assertNodeEquals("embedded", "/embedded", true, new TypeReference<MyEmbeddedDTO2<String>>(){}.getType(), embeddedNode);
+        Node valueNode = embeddedNode.children().get("/value");
+        assertNodeEquals("value", "/embedded/value", false, String.class, valueNode);
+
+        Node sRoot = s.nodeAtPath("/").get();
+        assertNodeEquals("", "/", false, new TypeReference<MyDTO3<MyEmbeddedDTO2<String>>>(){}.getType(), sRoot);
+        Node sPingNode = s.nodeAtPath("/ping").get();
+        assertNodeEquals("ping", "/ping", false, String.class, sPingNode);
+        Node sPongNode = s.nodeAtPath("/pong").get();
+        assertNodeEquals("pong", "/pong", false, Long.class, sPongNode);
+        Node sCountNode = s.nodeAtPath("/count").get();
+        assertNodeEquals("count", "/count", false, MyDTO3.Count.class, sCountNode);
+        Node sEmbeddedNode = s.nodeAtPath("/embedded").get();
+        assertNodeEquals("embedded", "/embedded", true, new TypeReference<MyEmbeddedDTO2<String>>(){}.getType(), sEmbeddedNode);
+        Node sValueNode = s.nodeAtPath("/embedded/value").get();
+        assertNodeEquals("value", "/embedded/value", false, String.class, sValueNode);
+    }
+
+    @Test
+    public void testSchematizeToMap() {
+        Optional<Schema> opt = schematizer
+                .rule("MyDTO", new TypeReference<MyDTO>(){})
+                .rule("MyDTO", "/embedded", new TypeReference<MyEmbeddedDTO>(){})
+                .get("MyDTO");
+
+        assertTrue(opt.isPresent());
+        Schema s = opt.get();
+        Map<String, Node.DTO> map = s.toMap();
+        testMapValues(map);
+    }
+
+    private void testMapValues(Map<String, Node.DTO> map) {
+        assertNotNull(map);
+        assertEquals(1, map.size());
+        Node.DTO root = map.get("/");
+        assertEquals(4, root.children.size());
+        assertNodeDTOEquals("", "/", false, MyDTO.class, root);
+        Node.DTO pingNode = root.children.get("ping");
+        assertNodeDTOEquals("ping", "/ping", false, String.class, pingNode);
+        Node.DTO pongNode = root.children.get("pong");
+        assertNodeDTOEquals("pong", "/pong", false, Long.class, pongNode);
+        Node.DTO countNode = root.children.get("count");
+        assertNodeDTOEquals("count", "/count", false, MyDTO.Count.class, countNode);
+        Node.DTO embeddedNode = root.children.get("embedded");
+        assertEquals(3, embeddedNode.children.size());
+        assertNodeDTOEquals("embedded", "/embedded", false, MyEmbeddedDTO.class, embeddedNode);
+        Node.DTO marcoNode = embeddedNode.children.get("marco");
+        assertNodeDTOEquals("marco", "/embedded/marco", false, String.class, marcoNode);
+        Node.DTO poloNode = embeddedNode.children.get("polo");
+        assertNodeDTOEquals("polo", "/embedded/polo", false, Long.class, poloNode);
+        Node.DTO alphaNode = embeddedNode.children.get("alpha");
+        assertNodeDTOEquals("alpha", "/embedded/alpha", false, MyEmbeddedDTO.Alpha.class, alphaNode);
+    }
+
+    @Test
+    public void testSchemaFromMap() {
+        Optional<Schema> opt1 = schematizer
+                .rule("MyDTO", new TypeReference<MyDTO>(){})
+                .rule("MyDTO", "/embedded", new TypeReference<MyEmbeddedDTO>(){})
+                .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);
+    }
+
+    private void testSchema(Schema s) {
+        // Assume that the map is serialized, then deserialized "as is".
+        assertNotNull(s);
+        Node root = s.rootNode();
+        assertEquals(4, root.children().size());
+        assertNodeEquals("", "/", false, MyDTO.class, root);
+        Node pingNode = root.children().get("/ping");
+        assertNodeEquals("ping", "/ping", false, String.class, pingNode);
+        Node pongNode = root.children().get("/pong");
+        assertNodeEquals("pong", "/pong", false, Long.class, pongNode);
+        Node countNode = root.children().get("/count");
+        assertNodeEquals("count", "/count", false, MyDTO.Count.class, countNode);
+        Node embeddedNode = root.children().get("/embedded");
+        assertEquals(3, embeddedNode.children().size());
+        assertNodeEquals("embedded", "/embedded", false, MyEmbeddedDTO.class, embeddedNode);
+        Node marcoNode = embeddedNode.children().get("/marco");
+        assertNodeEquals("marco", "/embedded/marco", false, String.class, marcoNode);
+        Node poloNode = embeddedNode.children().get("/polo");
+        assertNodeEquals("polo", "/embedded/polo", false, Long.class, poloNode);
+        Node alphaNode = embeddedNode.children().get("/alpha");
+        assertNodeEquals("alpha", "/embedded/alpha", false, MyEmbeddedDTO.Alpha.class, alphaNode);
+
+        Node sRoot = s.nodeAtPath("/").get();
+        assertNodeEquals("", "/", false, MyDTO.class, sRoot);
+        Node sPingNode = s.nodeAtPath("/ping").get();
+        assertNodeEquals("ping", "/ping", false, String.class, sPingNode);
+        Node sPongNode = s.nodeAtPath("/pong").get();
+        assertNodeEquals("pong", "/pong", false, Long.class, sPongNode);
+        Node sCountNode = s.nodeAtPath("/count").get();
+        assertNodeEquals("count", "/count", false, MyDTO.Count.class, sCountNode);
+        Node sEmbeddedNode = s.nodeAtPath("/embedded").get();
+        assertNodeEquals("embedded", "/embedded", false, MyEmbeddedDTO.class, sEmbeddedNode);
+        Node sMarcoNode = s.nodeAtPath("/embedded/marco").get();
+        assertNodeEquals("marco", "/embedded/marco", false, String.class, sMarcoNode);
+        Node sPoloNode = s.nodeAtPath("/embedded/polo").get();
+        assertNodeEquals("polo", "/embedded/polo", false, Long.class, sPoloNode);
+        Node sAlphaNode = s.nodeAtPath("/embedded/alpha").get();
+        assertNodeEquals("alpha", "/embedded/alpha", false, MyEmbeddedDTO.Alpha.class, sAlphaNode);
+    }
+
+    @Test
+    public void testVisitor() {
+        Optional<Schema> opt = schematizer
+                .rule("MyDTO", new TypeReference<MyDTO>(){})
+                .rule("MyDTO", "/embedded", new TypeReference<MyEmbeddedDTO>(){})
+                .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());
+    }
+
+    private void assertNodeEquals(String name, String path, boolean isCollection, Object type, Node node) {
+        assertNotNull(node);
+        assertEquals(name, node.name());
+        assertEquals(path, node.absolutePath());
+        assertEquals(isCollection, node.isCollection());
+        assertEquals(type, node.type());
+    }
+
+    private void assertNodeDTOEquals(String name, String path, boolean isCollection, Class<?> type, Node.DTO node) {
+        assertNotNull(node);
+        assertEquals(name, node.name);
+        assertEquals(path, node.path);
+        assertEquals(isCollection, node.isCollection);
+        assertEquals(type.getName(), node.type);
+    }
+}

Added: 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=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/JsonDeserializationTest.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/JsonDeserializationTest.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,119 @@
+/*
+ * 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.felix.serializer.impl.json;
+
+import org.apache.felix.schematizer.Schema;
+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.service.converter.Converter;
+import org.osgi.service.converter.StandardConverter;
+import org.osgi.service.converter.TypeReference;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Optional;
+
+public class JsonDeserializationTest {
+    private Converter converter;
+
+    @Before
+    public void setUp() {
+        converter = new StandardConverter();
+    }
+
+    @After
+    public void tearDown() {
+        converter = null;
+    }
+
+    @Test
+    public void testDeserialization() {
+        MyEmbeddedDTO embedded = new MyEmbeddedDTO();
+        embedded.marco = "mmmm";
+        embedded.polo = 24;
+        embedded.alpha = Alpha.B;
+
+        MyDTO dto = new MyDTO();
+        dto.ping = "pppping";
+        dto.pong = 42;
+        dto.count = Count.TWO;
+        dto.embedded = embedded;
+
+        String serialized = new JsonSerializerImpl().serialize(dto).toString();
+
+        // 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();
+        MyDTO result = new JsonSerializerImpl()
+                .deserialize(MyDTO.class)
+                .with(converter)
+                .withContext(s)
+                .from(serialized);
+
+        assertEquals(dto.ping, result.ping);
+        assertEquals(dto.pong, result.pong);
+        assertEquals(dto.count, result.count);
+        assertEquals(dto.embedded.marco, result.embedded.marco);
+        assertEquals(dto.embedded.polo, result.embedded.polo);
+        assertEquals(dto.embedded.alpha, result.embedded.alpha);
+    }
+
+    @Test
+    public void testDeserializationWithCollection() {
+        MyEmbeddedDTO2<String> embedded = new MyEmbeddedDTO2<>();
+        embedded.value = "one million dollars";
+
+        MyDTO2<MyEmbeddedDTO2<String>> dto = new MyDTO2<>();
+        dto.ping = "pppping";
+        dto.pong = 42;
+        dto.embedded = new ArrayList<>();
+        dto.embedded.add( embedded );
+
+        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()
+                .deserialize(new TypeReference<MyDTO2<MyEmbeddedDTO2<String>>>(){})
+                .with(converter)
+                .withContext(s)
+                .from(serialized);
+
+        assertEquals(dto.ping, result.ping);
+        assertEquals(dto.pong, result.pong);
+        assertEquals(dto.embedded.get(0).value, result.embedded.get(0).value);
+    }
+}

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyDTO.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyDTO.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyDTO.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyDTO.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,32 @@
+/*
+ * 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.felix.serializer.impl.json;
+
+import org.osgi.dto.DTO;
+
+public class MyDTO extends DTO {
+    public enum Count { ONE, TWO, THREE }
+
+    public Count count;
+
+    public String ping;
+
+    public long pong;
+
+    public MyEmbeddedDTO embedded;
+}
+

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyDTO2.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyDTO2.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyDTO2.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyDTO2.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,32 @@
+/*
+ * 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.felix.serializer.impl.json;
+
+import java.util.List;
+
+import org.osgi.dto.DTO;
+
+public class MyDTO2<T> extends DTO {
+    public enum Count { ONE, TWO, THREE }
+
+    public String ping;
+
+    public long pong;
+
+    public List<T> embedded;
+}
+

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyEmbeddedDTO.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyEmbeddedDTO.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyEmbeddedDTO.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyEmbeddedDTO.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,29 @@
+/*
+ * 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.felix.serializer.impl.json;
+
+import org.osgi.dto.DTO;
+
+public class MyEmbeddedDTO extends DTO {
+    public enum Alpha { A, B, C }
+
+    public Alpha alpha;
+
+    public String marco;
+
+    public long polo;
+}

Added: 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=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyEmbeddedDTO2.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/MyEmbeddedDTO2.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,24 @@
+/*
+ * 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.felix.serializer.impl.json;
+
+import org.osgi.dto.DTO;
+
+public class MyEmbeddedDTO2<T> extends DTO {
+    public T value;
+}
+

Added: 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=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/RepositorySerializationTest.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/impl/json/RepositorySerializationTest.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,255 @@
+/*
+ * 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.felix.serializer.impl.json;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.felix.serializer.test.objects.Bottom;
+import org.apache.felix.serializer.test.objects.ComplexManager;
+import org.apache.felix.serializer.test.objects.ComplexMiddle;
+import org.apache.felix.serializer.test.objects.ComplexTop;
+import org.apache.felix.serializer.test.objects.SimpleManager;
+import org.apache.felix.serializer.test.objects.SimpleTop;
+import org.apache.felix.serializer.test.objects.provider.BottomEntity;
+import org.apache.felix.serializer.test.objects.provider.ComplexManagerService;
+import org.apache.felix.serializer.test.objects.provider.ComplexMiddleEntity;
+import org.apache.felix.serializer.test.objects.provider.ComplexTopEntity;
+import org.apache.felix.serializer.test.objects.provider.ObjectFactory;
+import org.apache.felix.serializer.test.objects.provider.SimpleManagerService;
+import org.apache.felix.serializer.test.objects.provider.SimpleTopEntity;
+import org.apache.felix.serializer.test.prevayler.Repository;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * General class for testing any type of RepositoryStore.
+ * 
+ * @author David Leangen
+ */
+public class RepositorySerializationTest
+{
+    private SimpleManager simpleManager;
+    private ComplexManager complexManager;
+    private ObjectFactory factory;
+
+    @Before
+	public void configure() throws Exception {
+	    simpleManager = new SimpleManagerService();
+        complexManager = new ComplexManagerService();
+        factory = new ObjectFactory();
+	}
+
+    @After
+	public void cleanup() throws Exception {
+		simpleManager.clear();
+	}
+
+    @Test
+	public void shouldPutAndRemoveSimpleEntitiesFromStore() {
+		simpleManager.clear();
+		final SimpleTopEntity e1 = factory.newSimpleTop( "ID01", "Value01", null );
+		final SimpleTopEntity e2 = factory.newSimpleTop( "ID02", "Value02", null );
+		final SimpleTopEntity e3 = factory.newSimpleTop( "ID03", "Value03", null );
+		final SimpleTopEntity e4 = factory.newSimpleTop( "ID04", "Value04", null );
+		final SimpleTopEntity e5 = factory.newSimpleTop( "ID05", "Value05", null );
+
+		simpleManager.add( e1 );
+		simpleManager.add( e2 );
+		simpleManager.add( e3 );
+		simpleManager.add( e4 );
+		simpleManager.add( e5 );
+
+		assertEquals( 5, simpleManager.list().size() );
+
+		simpleManager.delete( e1.getId() );
+		simpleManager.delete( e2.getId() );
+		simpleManager.delete( e3.getId() );
+		simpleManager.delete( e4.getId() );
+		simpleManager.delete( e5.getId() );
+
+		assertTrue( simpleManager.list().isEmpty() );
+
+		final Map<String, SimpleTop> m = new HashMap<>();
+		m.put( e1.getId(), e1 );
+		m.put( e2.getId(), e2 );
+		m.put( e3.getId(), e3 );
+		m.put( e4.getId(), e4 );
+		m.put( e5.getId(), e5 );
+		simpleManager.repository().putAll( m );
+
+		assertEquals( 5, simpleManager.list().size() );
+
+		simpleManager.clear();
+
+		assertTrue( simpleManager.list().isEmpty() );
+	}
+
+    @Test
+    public void shouldPutAndRemoveComplexEntityFromStore() {
+        complexManager.clear();
+        assertTrue( complexManager.list().isEmpty() );
+
+        final BottomEntity b1 = factory.newBottom( "B01", "Bum01" );
+        final BottomEntity b2 = factory.newBottom( "B02", "Bum02" );
+        final BottomEntity b3 = factory.newBottom( "B03", "Bum03" );
+        final Collection<BottomEntity> bottoms = new ArrayList<>();
+        bottoms.add( b1 );
+        bottoms.add( b2 );
+        bottoms.add( b3 );
+
+        final ComplexMiddleEntity m = factory.newComplexMiddle( "M", "Middle", bottoms );
+
+        final ComplexTopEntity e = factory.newComplexTop( "ID01", "Value01", m );
+
+        complexManager.add( e );
+
+        assertEquals( 1, complexManager.list().size() );
+        final ComplexTop retrievedE = complexManager.get( "ID01" ).get();
+        assertEquals( "Value01", retrievedE.getValue() );
+        final ComplexMiddle retrievedM = retrievedE.getEmbeddedValue();
+        assertNotNull( retrievedM );
+        assertEquals( "M", retrievedM.getId() );
+        final Collection<Bottom> retrievedBs = retrievedM.getEmbeddedValue();
+        assertNotNull( retrievedBs );
+        assertEquals( 3, retrievedBs.size() );
+        final Set<String> ids = new HashSet<>();
+        for( final Bottom b : retrievedBs )
+            ids.add( b.getId() );
+        assertTrue( ids.contains( "B01" ) );
+        assertTrue( ids.contains( "B02" ) );
+        assertTrue( ids.contains( "B03" ) );
+
+        complexManager.delete( e.getId() );
+
+        assertTrue( complexManager.list().isEmpty() );
+    }
+
+    @Test
+    public void shouldPutAllToStore() {
+        complexManager.clear();
+        assertTrue( complexManager.list().isEmpty() );
+
+        final BottomEntity b1 = factory.newBottom( "B01", "Bum01" );
+        final BottomEntity b2 = factory.newBottom( "B02", "Bum02" );
+        final BottomEntity b3 = factory.newBottom( "B03", "Bum03" );
+        final Collection<BottomEntity> bottoms = new ArrayList<>();
+        bottoms.add( b1 );
+        bottoms.add( b2 );
+        bottoms.add( b3 );
+
+        final ComplexMiddleEntity m = factory.newComplexMiddle( "M", "Middle", bottoms );
+
+        final ComplexTopEntity e1 = factory.newComplexTop( "ID01", "Value01", m );
+        final ComplexTopEntity e2 = factory.newComplexTop( "ID02", "Value02", m );
+        final ComplexTopEntity e3 = factory.newComplexTop( "ID03", "Value03", m );
+
+        final List<ComplexTop> tops = new ArrayList<>();
+        tops.add( e1 );
+        tops.add( e2 );
+        tops.add( e3 );
+
+        complexManager.addAll( tops );
+
+        assertEquals( 3, complexManager.list().size() );
+        final ComplexTop retrievedE = complexManager.get( "ID01" ).get();
+        assertEquals( "Value01", retrievedE.getValue() );
+        final ComplexMiddle retrievedM = retrievedE.getEmbeddedValue();
+        assertNotNull( retrievedM );
+        assertEquals( "M", retrievedM.getId() );
+        final Collection<Bottom> retrievedBs = retrievedM.getEmbeddedValue();
+        assertNotNull( retrievedBs );
+        assertEquals( 3, retrievedBs.size() );
+        final Set<String> bottomIds = new HashSet<>();
+        for( final Bottom b : retrievedBs )
+            bottomIds.add( b.getId() );
+        assertTrue( bottomIds.contains( "B01" ) );
+        assertTrue( bottomIds.contains( "B02" ) );
+        assertTrue( bottomIds.contains( "B03" ) );
+
+        final List<String> ids = new ArrayList<>();
+        ids.add( "ID01" );
+        ids.add( "ID02" );
+        ids.add( "ID03" );
+
+        assertEquals(3, complexManager.list().size());
+    }
+
+    @Test
+	public void shouldIterateThroughKeysAndValues() {
+	    simpleManager.clear();
+
+	    final SimpleTopEntity e1 = factory.newSimpleTop( "ID01", "Value01", null );
+        final SimpleTopEntity e2 = factory.newSimpleTop( "ID02", "Value02", null );
+        final SimpleTopEntity e3 = factory.newSimpleTop( "ID03", "Value03", null );
+        final SimpleTopEntity e4 = factory.newSimpleTop( "ID04", "Value04", null );
+        final SimpleTopEntity e5 = factory.newSimpleTop( "ID05", "Value05", null );
+
+        simpleManager.add( e1 );
+        simpleManager.add( e2 );
+        simpleManager.add( e3 );
+        simpleManager.add( e4 );
+        simpleManager.add( e5 );
+
+        final Iterator<String> keys = simpleManager.repository().keys().iterator();
+
+		final Set<String> keySet = new TreeSet<String>();
+		while( keys.hasNext() )
+		{
+			keySet.add( keys.next() );
+		}
+
+		assertEquals( 5, keySet.size() );
+		assertTrue( keySet.contains( "ID01" ) );
+		assertTrue( keySet.contains( "ID02" ) );
+		assertTrue( keySet.contains( "ID03" ) );
+		assertTrue( keySet.contains( "ID04" ) );
+		assertTrue( keySet.contains( "ID05" ) );
+
+		final List<SimpleTop> list = new ArrayList<SimpleTop>();
+		for( final SimpleTop e : simpleManager.list() )
+		{
+			list.add( e );
+		}
+		Collections.sort(list, (st1, st2) -> st1.getId().compareTo(st2.getId()));
+
+		assertEquals( 5, list.size() );
+		assertEquals( "ID01", list.get( 0 ).getId() );
+		assertEquals( "ID02", list.get( 1 ).getId() );
+		assertEquals( "ID03", list.get( 2 ).getId() );
+		assertEquals( "ID04", list.get( 3 ).getId() );
+		assertEquals( "ID05", list.get( 4 ).getId() );
+
+		final Repository<SimpleTop> store = simpleManager.repository();
+		assertEquals( "Value01", store.get( "ID01" ).get().getValue() );
+		assertEquals( "Value02", store.get( "ID02" ).get().getValue() );
+		assertEquals( "Value03", store.get( "ID03" ).get().getValue() );
+		assertEquals( "Value04", store.get( "ID04" ).get().getValue() );
+		assertEquals( "Value05", store.get( "ID05" ).get().getValue() );
+	}
+}

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Bottom.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Bottom.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Bottom.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Bottom.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,23 @@
+/*
+ * 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.felix.serializer.test.objects;
+
+public interface Bottom
+{
+    String getId();
+    String getBum();
+}

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexManager.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexManager.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexManager.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,38 @@
+/*
+ * 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.felix.serializer.test.objects;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Optional;
+
+import org.apache.felix.serializer.test.prevayler.Repository;
+
+public interface ComplexManager
+{
+    List<String> keys();
+    List<ComplexTop> list();
+    Optional<ComplexTop> get( String key );
+
+    void add( ComplexTop top );
+    void addAll( Collection<ComplexTop> tops );
+    void delete( String key );
+    void clear();
+
+    // This is only for testing. It would normally not be part of an API.
+    Repository<ComplexTop> repository();
+}

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexMiddle.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexMiddle.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexMiddle.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexMiddle.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,25 @@
+/*
+ * 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.felix.serializer.test.objects;
+
+import java.util.Collection;
+
+public interface ComplexMiddle
+    extends Middle
+{
+    Collection<Bottom> getEmbeddedValue();
+}

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexTop.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexTop.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexTop.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/ComplexTop.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,24 @@
+/*
+ * 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.felix.serializer.test.objects;
+
+public interface ComplexTop
+{
+	String getId();
+    String getValue();
+    ComplexMiddle getEmbeddedValue();
+}

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Middle.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Middle.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Middle.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/Middle.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,23 @@
+/*
+ * 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.felix.serializer.test.objects;
+
+public interface Middle
+{
+    String getId();
+    String getSomeValue();
+}

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleManager.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleManager.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleManager.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,36 @@
+/*
+ * 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.felix.serializer.test.objects;
+
+import java.util.List;
+import java.util.Optional;
+
+import org.apache.felix.serializer.test.prevayler.Repository;
+
+public interface SimpleManager
+{
+    List<String> keys();
+    List<SimpleTop> list();
+    Optional<SimpleTop> get( String key );
+
+    void add( SimpleTop top );
+    void delete( String key );
+    void clear();
+
+    // This is only for testing. It would normally not be part of an API.
+    Repository<SimpleTop> repository();
+}

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleMiddle.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleMiddle.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleMiddle.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleMiddle.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,23 @@
+/*
+ * 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.felix.serializer.test.objects;
+
+public interface SimpleMiddle
+    extends Middle
+{
+    Bottom getEmbeddedValue();
+}

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleTop.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleTop.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleTop.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/SimpleTop.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,24 @@
+/*
+ * 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.felix.serializer.test.objects;
+
+public interface SimpleTop
+{
+    String getId();
+    String getValue();
+    Middle getEmbeddedValue();
+}

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/AbstractMiddleEntity.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/AbstractMiddleEntity.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/AbstractMiddleEntity.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/AbstractMiddleEntity.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,38 @@
+/*
+ * 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.felix.serializer.test.objects.provider;
+
+import org.apache.felix.serializer.test.objects.Middle;
+import org.osgi.dto.DTO;
+
+public class AbstractMiddleEntity
+    extends DTO
+	implements Middle
+{
+    public String id;
+    public String someValue;
+
+    public String getId()
+    {
+        return id;
+    }
+
+    public String getSomeValue()
+    {
+        return someValue;
+    }
+}

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/BottomEntity.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/BottomEntity.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/BottomEntity.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/BottomEntity.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,38 @@
+/*
+ * 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.felix.serializer.test.objects.provider;
+
+import org.apache.felix.serializer.test.objects.Bottom;
+import org.osgi.dto.DTO;
+
+public class BottomEntity
+    extends DTO
+	implements Bottom
+{
+	public String id;
+	public String bum;
+
+    public String getId()
+    {
+        return id;
+    }
+
+    public String getBum()
+    {
+        return bum;
+    }
+}

Added: 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=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexManagerService.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexManagerService.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,90 @@
+/*
+ * 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.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.service.converter.TypeReference;
+
+public class ComplexManagerService
+	implements ComplexManager
+{
+    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);
+    }
+
+    @Override
+	public void add(ComplexTop top) {
+        repository.put(top.getId(), (ComplexTopEntity)top);
+	}
+
+	@Override
+    public void addAll(Collection<ComplexTop> tops) {
+	    tops.stream().forEach(t -> add(t));
+    }
+
+	@Override
+    public List<String> keys() {
+        return repository.keys();
+    }
+
+    @Override
+	public List<ComplexTop> list()
+	{
+	    return repository.list().stream().map(e -> (ComplexTopEntity)e).collect(Collectors.toList());
+	}
+
+	@Override
+	public Optional<ComplexTop> get(String key) {
+		return Optional.of( repository.get( key ).get() );
+	}
+
+    @Override
+	public void delete(String key) {
+        repository.remove(key); 
+	}
+
+	@Override
+	public void clear() {
+	    repository.clear(); 
+	}
+
+    @SuppressWarnings( { "unchecked", "rawtypes" } )
+    @Override
+    public Repository<ComplexTop> repository() {
+        return (Repository)repository;
+    }
+}

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexMiddleEntity.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexMiddleEntity.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexMiddleEntity.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexMiddleEntity.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,37 @@
+/*
+ * 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.felix.serializer.test.objects.provider;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.felix.schematizer.Node.CollectionType;
+import org.apache.felix.serializer.test.objects.Bottom;
+import org.apache.felix.serializer.test.objects.ComplexMiddle;
+
+public class ComplexMiddleEntity
+    extends AbstractMiddleEntity
+    implements ComplexMiddle
+{
+    @CollectionType( BottomEntity.class )
+	public Collection<Bottom> embeddedValue = new ArrayList<>();
+
+    public Collection<Bottom> getEmbeddedValue()
+    {
+        return embeddedValue;
+    }
+}

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexTopEntity.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexTopEntity.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexTopEntity.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ComplexTopEntity.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,48 @@
+/*
+ * 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.felix.serializer.test.objects.provider;
+
+import org.apache.felix.serializer.test.objects.ComplexMiddle;
+import org.apache.felix.serializer.test.objects.ComplexTop;
+import org.osgi.dto.DTO;
+
+public class ComplexTopEntity
+    extends DTO
+	implements ComplexTop
+{
+	public String id;
+    public String value;
+    public ComplexMiddleEntity embeddedValue;
+
+    @Override
+    public String getId()
+    {
+        return id;
+    }
+
+    @Override
+    public String getValue()
+    {
+        return value;
+    }
+
+    @Override
+    public ComplexMiddle getEmbeddedValue()
+    {
+        return embeddedValue;
+    }
+}

Added: felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ObjectFactory.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ObjectFactory.java?rev=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ObjectFactory.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/ObjectFactory.java Mon Sep 26 12:46:48 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.felix.serializer.test.objects.provider;
+
+import java.util.Collection;
+
+import org.osgi.service.converter.Converter;
+import org.osgi.service.converter.StandardConverter;
+
+public class ObjectFactory
+{
+    private final Converter cnv = new StandardConverter();
+
+    public ComplexTopEntity newComplexTop( String anId, String aValue, ComplexMiddleEntity aMiddle )
+    {
+        final ComplexTopEntity top = new ComplexTopEntity();
+        top.id = anId;
+        top.value = aValue;
+        top.embeddedValue = cnv.convert( aMiddle ).to( ComplexMiddleEntity.class );
+        return top;
+    }
+
+    public SimpleTopEntity newSimpleTop( String anId, String aValue, SimpleMiddleEntity aMiddle )
+    {
+        final SimpleTopEntity top = new SimpleTopEntity();
+        top.id = anId;
+        top.value = aValue;
+        top.embeddedValue = cnv.convert( aMiddle ).to( SimpleMiddleEntity.class );
+        return top;
+    }
+
+    public ComplexMiddleEntity newComplexMiddle( String anId, String aValue, Collection<BottomEntity> bums )
+    {
+        final ComplexMiddleEntity middle = new ComplexMiddleEntity();
+        middle.id = anId;
+        middle.someValue = aValue;
+        bums.stream().forEach( b -> middle.embeddedValue.add( b ) );
+        return middle;
+    }
+
+    public SimpleMiddleEntity newSimpleMiddle( BottomEntity aBum )
+    {
+        final SimpleMiddleEntity middle = new SimpleMiddleEntity();
+        middle.embeddedValue = null;
+        return middle;
+    }
+
+    public BottomEntity newBottom( String anId, String aBum )
+    {
+        final BottomEntity bum = new BottomEntity();
+        bum.id = anId;
+        bum.bum = aBum;
+        return bum;
+    }
+}
+

Added: 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=1762334&view=auto
==============================================================================
--- felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleManagerService.java (added)
+++ felix/trunk/converter/schematizer/src/test/java/org/apache/felix/serializer/test/objects/provider/SimpleManagerService.java Mon Sep 26 12:46:48 2016
@@ -0,0 +1,85 @@
+/*
+ * 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.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.service.converter.TypeReference;
+
+public class SimpleManagerService
+	implements SimpleManager
+{
+	static final String COMPONENT_NAME = "net.leangen.expedition.platform.test.Simple";
+
+	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);
+    }
+
+	@Override
+	public void add( SimpleTop top ) {
+        repository.put( top.getId(), (SimpleTopEntity)top ); 
+	}
+
+	@Override
+    public List<String> keys() {
+        return repository.keys();
+    }
+
+    @Override
+	public List<SimpleTop> list() {
+	    return repository.list().stream().collect(Collectors.toList());
+	}
+
+	@Override
+	public Optional<SimpleTop> get(String key) {
+		return Optional.of( repository.get( key ).get() );
+	}
+
+	@Override
+	public void delete(String key) {
+        repository.remove(key); 
+	}
+
+	@Override
+	public void clear() {
+        repository.clear(); 
+	}
+
+    @SuppressWarnings( { "unchecked", "rawtypes" } )
+    @Override
+    public Repository<SimpleTop> repository() {
+        return (Repository)repository;
+    }
+}