You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2013/08/28 16:50:00 UTC

svn commit: r1518222 - in /chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src: main/java/org/apache/chemistry/opencmis/commons/impl/ test/java/org/apache/chemistry/opencmis/commons/impl/misc/ test/java/org/apache/ch...

Author: fmui
Date: Wed Aug 28 14:49:59 2013
New Revision: 1518222

URL: http://svn.apache.org/r1518222
Log:
more unit test

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/Base64Test.java   (with props)
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/UrlBuilderTest.java   (with props)
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/UrlBuilder.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/MimeHelperTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/BukUpdateConverterTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/ObjectConvertTest.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/UrlBuilder.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/UrlBuilder.java?rev=1518222&r1=1518221&r2=1518222&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/UrlBuilder.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/UrlBuilder.java Wed Aug 28 14:49:59 2013
@@ -89,8 +89,15 @@ public class UrlBuilder {
         if (port > 0) {
             urlPart.append(':').append(port);
         }
-        if (path != null) {
-            urlPart.append(path);
+        if (path != null && path.length() > 0) {
+            if (urlPart.charAt(urlPart.length() - 1) != '/') {
+                urlPart.append('/');
+            }
+            if (path.charAt(0) == '/') {
+                path = path.substring(1);
+            }
+
+            urlPart.append(quoteURIPathComponent(path, true));
         }
     }
 
@@ -98,6 +105,10 @@ public class UrlBuilder {
      * Copy constructor.
      */
     public UrlBuilder(UrlBuilder urlBuilder) {
+        if (urlBuilder == null) {
+            throw new IllegalArgumentException("UrlBuilder must be set");
+        }
+
         urlPart = new StringBuilder(urlBuilder.urlPart);
         queryPart = new StringBuilder(urlBuilder.queryPart);
     }

Added: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/Base64Test.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/Base64Test.java?rev=1518222&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/Base64Test.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/Base64Test.java Wed Aug 28 14:49:59 2013
@@ -0,0 +1,63 @@
+/*
+ * 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.chemistry.opencmis.commons.impl.misc;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import org.apache.chemistry.opencmis.commons.impl.Base64;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
+import org.junit.Test;
+
+/**
+ * Base64 tests. (Placeholder for more tests.)
+ */
+public class Base64Test {
+
+    @Test
+    public void testSimpleBase64() throws Exception {
+        byte[] input = IOUtils.getUTF8Bytes("test");
+
+        assertEquals("dGVzdA==", Base64.encodeBytes(input, 0, input.length));
+        assertArrayEquals(input, Base64.decode("dGVzdA=="));
+        assertArrayEquals(input, Base64.decode(Base64.encodeBytes(input)));
+    }
+
+    @Test
+    public void testBase64Stream() throws Exception {
+        ByteArrayInputStream stream = new ByteArrayInputStream("dGVzdA==".getBytes("US-ASCII"));
+        InputStream base64stream = new Base64.InputStream(stream);
+
+        ByteArrayOutputStream output = new ByteArrayOutputStream();
+
+        int b;
+        byte[] buffer = new byte[4096];
+        while ((b = base64stream.read(buffer)) > -1) {
+            output.write(buffer, 0, b);
+        }
+
+        base64stream.close();
+
+        assertArrayEquals("test".getBytes("US-ASCII"), output.toByteArray());
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/Base64Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/MimeHelperTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/MimeHelperTest.java?rev=1518222&r1=1518221&r2=1518222&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/MimeHelperTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/MimeHelperTest.java Wed Aug 28 14:49:59 2013
@@ -24,6 +24,8 @@ package org.apache.chemistry.opencmis.co
 import static org.apache.chemistry.opencmis.commons.impl.MimeHelper.decodeContentDisposition;
 import static org.apache.chemistry.opencmis.commons.impl.MimeHelper.decodeContentDispositionFilename;
 import static org.apache.chemistry.opencmis.commons.impl.MimeHelper.encodeContentDisposition;
+import static org.apache.chemistry.opencmis.commons.impl.MimeHelper.*;
+import static org.junit.Assert.assertArrayEquals;
 
 import java.util.Collections;
 import java.util.HashMap;
@@ -82,4 +84,19 @@ public class MimeHelperTest extends Test
         assertEquals("caf\u00e9.pdf", decodeContentDispositionFilename("bar; filename*=ISO-8859-1''caf%E9.pdf"));
     }
 
+    @Test
+    public void testCharsetFromContentType() {
+        assertEquals("utf-8", getCharsetFromContentType("text/plain;charset=utf-8"));
+        assertEquals("utf-8", getCharsetFromContentType("text/plain;charset=\"utf-8\""));
+        assertEquals("utf-8", getCharsetFromContentType("text/plain  ;  charset    =    \"utf-8\"   "));
+    }
+
+    @Test
+    public void testBoundaryFromMultiPart() throws Exception {
+        byte boundary[] = "thisisaBoundary".getBytes("ISO-8859-1");
+
+        assertNull(getBoundaryFromMultiPart("multipart/form-data"));
+        assertArrayEquals(boundary, getBoundaryFromMultiPart("multipart/form-data;boundary="
+                + new String(boundary, "ISO-8859-1")));
+    }
 }

Added: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/UrlBuilderTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/UrlBuilderTest.java?rev=1518222&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/UrlBuilderTest.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/UrlBuilderTest.java Wed Aug 28 14:49:59 2013
@@ -0,0 +1,106 @@
+/*
+ * 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.chemistry.opencmis.commons.impl.misc;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.impl.ReturnVersion;
+import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
+import org.junit.Test;
+
+/**
+ * UrlBuilder tests.
+ */
+public class UrlBuilderTest {
+
+    @Test
+    public void testUrls() {
+        assertEquals("http://example.com", new UrlBuilder("http://example.com").toString());
+
+        // path
+        assertEquals("http://example.com/path", (new UrlBuilder("http://example.com")).addPath("path").toString());
+        assertEquals("http://example.com/path?param=value", (new UrlBuilder("http://example.com")).addPath("path")
+                .addParameter("param", "value").toString());
+        assertEquals("http://example.com/path?param=value",
+                (new UrlBuilder("http://example.com")).addParameter("param", "value").addPath("path").toString());
+        assertEquals("http://example.com/path", (new UrlBuilder("http://example.com")).addPath("/path").toString());
+        assertEquals("http://example.com/path", (new UrlBuilder("http://example.com/")).addPath("path").toString());
+        assertEquals("http://example.com/path", (new UrlBuilder("http://example.com/")).addPath("/path").toString());
+        assertEquals("http://example.com/path1/path2",
+                new UrlBuilder((new UrlBuilder("http://example.com")).addPath("path1").addPath("path2")).toString());
+        assertEquals("http://example.com", new UrlBuilder("http://example.com").addPath("").toString());
+        assertEquals("http://example.com", new UrlBuilder("http://example.com").addPath(null).toString());
+
+        // path segments
+        assertEquals("http://example.com/path1/path2", (new UrlBuilder("http://example.com")).addPath("path1/path2")
+                .toString());
+        assertEquals("http://example.com/path1%2Fpath2",
+                (new UrlBuilder("http://example.com")).addPathSegment("path1/path2").toString());
+
+        // parameters
+        assertEquals("http://example.com?param", (new UrlBuilder("http://example.com")).addParameter("param")
+                .toString());
+        assertEquals("http://example.com?param=value",
+                (new UrlBuilder("http://example.com")).addParameter("param", "value").toString());
+        assertEquals("http://example.com?x=y&param=value",
+                (new UrlBuilder("http://example.com?x=y")).addParameter("param", "value").toString());
+        assertEquals(
+                "http://example.com?param=both",
+                (new UrlBuilder("http://example.com")).addParameter("param",
+                        UrlBuilder.normalizeParameter(IncludeRelationships.BOTH)).toString());
+        assertEquals(
+                "http://example.com?param=latest",
+                (new UrlBuilder("http://example.com")).addParameter("param",
+                        UrlBuilder.normalizeParameter(ReturnVersion.LATEST)).toString());
+        assertEquals("http://example.com", (new UrlBuilder("http://example.com")).addParameter(null).toString());
+        assertEquals("http://example.com", (new UrlBuilder("http://example.com")).addParameter(null, "value")
+                .toString());
+        assertEquals("http://example.com", (new UrlBuilder("http://example.com")).addParameter("param", null)
+                .toString());
+        assertEquals("http://example.com?param=&param2=value2",
+                (new UrlBuilder("http://example.com")).addParameter("param", "").addParameter("param2", "value2")
+                        .toString());
+        assertEquals("http://example.com/path?param=value", (new UrlBuilder("http://example.com")).addPath("path")
+                .addParameter("param", "value").toString());
+
+        // other constructor
+        assertEquals("http://example.com/path?param=value", (new UrlBuilder("http", "example.com", 80, "path"))
+                .addParameter("param", "value").toString());
+        assertEquals("https://example.com/path?param=value", (new UrlBuilder("https", "example.com", 443, "path"))
+                .addParameter("param", "value").toString());
+        assertEquals("http://example.com:1234/path?param=value", (new UrlBuilder("http", "example.com", 1234, "path"))
+                .addParameter("param", "value").toString());
+    }
+
+    @Test
+    public void testInvalid() {
+        try {
+            new UrlBuilder((String) null);
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try {
+            new UrlBuilder((UrlBuilder) null);
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/UrlBuilderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/BukUpdateConverterTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/BukUpdateConverterTest.java?rev=1518222&r1=1518221&r2=1518222&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/BukUpdateConverterTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/BukUpdateConverterTest.java Wed Aug 28 14:49:59 2013
@@ -20,10 +20,13 @@ package org.apache.chemistry.opencmis.co
 
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayOutputStream;
+import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
@@ -31,10 +34,14 @@ import javax.xml.stream.XMLStreamWriter;
 import org.apache.chemistry.opencmis.commons.data.BulkUpdateObjectIdAndChangeToken;
 import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.enums.PropertyType;
+import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
+import org.apache.chemistry.opencmis.commons.impl.WSConverter;
 import org.apache.chemistry.opencmis.commons.impl.XMLConverter;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.BulkUpdateImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.BulkUpdateObjectIdAndChangeTokenImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl;
+import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectIdAndChangeTokenType;
+import org.apache.chemistry.opencmis.commons.impl.json.parser.JSONParser;
 import org.junit.Test;
 
 public class BukUpdateConverterTest extends AbstractXMLConverterTest {
@@ -77,6 +84,12 @@ public class BukUpdateConverterTest exte
     }
 
     protected void assertBulkUpdate11(BulkUpdateImpl bulkUpdate, boolean validate) throws Exception {
+        assertXmlBulkUpdate11(bulkUpdate, validate);
+        assertWsBulkUpdate11(bulkUpdate);
+        assertJsonBulkUpdate11(bulkUpdate);
+    }
+
+    protected void assertXmlBulkUpdate11(BulkUpdateImpl bulkUpdate, boolean validate) throws Exception {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
 
         XMLStreamWriter writer = createWriter(out);
@@ -97,4 +110,29 @@ public class BukUpdateConverterTest exte
         assertDataObjectsEquals("BulkUpdate", bulkUpdate, result, null);
         assertNull(result.getExtensions());
     }
+
+    protected void assertWsBulkUpdate11(BulkUpdateImpl bulkUpdate) throws Exception {
+        CmisObjectIdAndChangeTokenType ws = WSConverter.convert(bulkUpdate.getObjectIdAndChangeToken().get(0));
+
+        BulkUpdateObjectIdAndChangeToken result = WSConverter.convert(ws);
+
+        assertNotNull(result);
+        assertDataObjectsEquals("BulkUpdate", bulkUpdate.getObjectIdAndChangeToken().get(0), result, null);
+        assertNull(result.getExtensions());
+    }
+
+    protected void assertJsonBulkUpdate11(BulkUpdateImpl bulkUpdate) throws Exception {
+        StringWriter sw = new StringWriter();
+
+        JSONConverter.convert(bulkUpdate.getObjectIdAndChangeToken().get(0)).writeJSONString(sw);
+
+        Object json = (new JSONParser()).parse(sw.toString());
+        assertTrue(json instanceof Map<?, ?>);
+        @SuppressWarnings("unchecked")
+        BulkUpdateObjectIdAndChangeToken result = JSONConverter.convertBulkUpdate((Map<String, Object>) json);
+
+        assertNotNull(result);
+        assertDataObjectsEquals("BulkUpdate", bulkUpdate.getObjectIdAndChangeToken().get(0), result, null);
+        assertNull(result.getExtensions());
+    }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/ObjectConvertTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/ObjectConvertTest.java?rev=1518222&r1=1518221&r2=1518222&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/ObjectConvertTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/ObjectConvertTest.java Wed Aug 28 14:49:59 2013
@@ -37,6 +37,7 @@ import javax.xml.stream.XMLStreamWriter;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.data.Ace;
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
+import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
 import org.apache.chemistry.opencmis.commons.data.ObjectList;
@@ -56,12 +57,14 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AllowableActionsImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChangeEventInfoDataImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectDataImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderContainerImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderDataImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderListImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectListImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PolicyIdListImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.RenditionDataImpl;
+import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectInFolderContainerType;
 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectInFolderListType;
 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectListType;
 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectType;
@@ -125,6 +128,35 @@ public class ObjectConvertTest extends A
         }
     }
 
+    @Test
+    public void testDescendants() throws Exception {
+        // run the test a few times with different values
+        for (int i = 0; i < 5; i++) {
+            ObjectInFolderContainer container = createObjectInFolderContainer(randomInt(7) + 2);
+            assertObjectContainer(container);
+        }
+    }
+
+    private ObjectInFolderContainer createObjectInFolderContainer(int level) {
+        ObjectInFolderContainerImpl result = new ObjectInFolderContainerImpl();
+
+        ObjectInFolderDataImpl dataInFolder = new ObjectInFolderDataImpl(createObjectData(true, CmisVersion.CMIS_1_1,
+                false, false));
+        dataInFolder.setPathSegment(randomString());
+        result.setObject(dataInFolder);
+
+        if (level > 0) {
+            List<ObjectInFolderContainer> children = new ArrayList<ObjectInFolderContainer>();
+            for (int i = 0; i < randomInt(3); i++) {
+                children.add(createObjectInFolderContainer(level - 1));
+            }
+
+            result.setChildren(children);
+        }
+
+        return result;
+    }
+
     protected ObjectDataImpl createObjectData(boolean addRelationships, CmisVersion cmisVersion, boolean withChanges,
             boolean withExtensions) {
         ObjectDataImpl result = new ObjectDataImpl();
@@ -397,4 +429,34 @@ public class ObjectConvertTest extends A
         assertNotNull(result);
         assertDataObjectsEquals("ObjectInFolderList", children, result, null);
     }
+
+    protected void assertObjectContainer(ObjectInFolderContainer container) throws Exception {
+        assertWsObjectContainer(container);
+        assertJsonObjectContainer(container);
+    }
+
+    protected void assertWsObjectContainer(ObjectInFolderContainer container) {
+        CmisObjectInFolderContainerType ws = WSConverter.convert(container, CmisVersion.CMIS_1_1);
+
+        ObjectInFolderContainer result = WSConverter.convert(ws);
+
+        assertNotNull(result);
+        assertDataObjectsEquals("ObjectContainer", container, result, null);
+    }
+
+    protected void assertJsonObjectContainer(ObjectInFolderContainer container) throws Exception {
+        TypeCache typeCache = null;
+
+        StringWriter sw = new StringWriter();
+
+        JSONConverter.convert(container, typeCache, false).writeJSONString(sw);
+
+        Object json = (new JSONParser()).parse(sw.toString());
+        assertTrue(json instanceof Map<?, ?>);
+        @SuppressWarnings("unchecked")
+        ObjectInFolderContainer result = JSONConverter.convertDescendant((Map<String, Object>) json, typeCache);
+
+        assertNotNull(result);
+        assertDataObjectsEquals("ObjectContainer", container, result, null);
+    }
 }