Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/RenditionInfoImpl.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/RenditionInfoImpl.java?rev=936933&r1=936932&r2=936933&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/RenditionInfoImpl.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/RenditionInfoImpl.java Thu Apr 22 16:18:22 2010 @@ -27,49 +27,49 @@ import org.apache.chemistry.opencmis.com */ public class RenditionInfoImpl implements RenditionInfo { - private String id; - private String contentType; - private String kind; - private String title; - private BigInteger length; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getContenType() { - return contentType; - } - - public void setContentType(String contentType) { - this.contentType = contentType; - } - - public String getKind() { - return kind; - } - - public void setKind(String kind) { - this.kind = kind; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public BigInteger getLength() { - return length; - } - - public void setLength(BigInteger length) { - this.length = length; - } + private String id; + private String contentType; + private String kind; + private String title; + private BigInteger length; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getContenType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + + public String getKind() { + return kind; + } + + public void setKind(String kind) { + this.kind = kind; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public BigInteger getLength() { + return length; + } + + public void setLength(BigInteger length) { + this.length = length; + } }
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/ConverterTest.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/ConverterTest.java?rev=936933&r1=936932&r2=936933&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/ConverterTest.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/ConverterTest.java Thu Apr 22 16:18:22 2010 @@ -62,184 +62,184 @@ import org.apache.chemistry.opencmis.com */ public class ConverterTest extends TestCase { - public void testRepositoryInfo() throws Exception { - // dry run - RepositoryInfoImpl obj1 = new RepositoryInfoImpl(); - RepositoryInfo obj2 = Converter.convert(Converter.convert(obj1)); - - assertDataObjectsEquals("RepositoryInfo", obj1, obj2); - - // values - obj1 = new RepositoryInfoImpl(); - obj1.setChangesIncomplete(Boolean.TRUE); - obj1.setChangesOnType(Collections.singletonList(BaseTypeId.CMIS_DOCUMENT)); - obj1.setCmisVersionSupported("1.0"); - obj1.setLatestChangeLogToken("changeLogToken"); - obj1.setPrincipalAnonymous("principalAnonymous"); - obj1.setPrincipalAnyone("principalAnyone"); - obj1.setProductName("productName"); - obj1.setProductVersion("productVersion"); - obj1.setRepositoryDescription("description"); - obj1.setRepositoryId("id"); - obj1.setRepositoryName("name"); - obj1.setRootFolder("rootFolderId"); - obj1.setThinClientUri("thinClientUri"); - obj1.setVendorName("vendorName"); - - RepositoryCapabilitiesImpl cap1 = new RepositoryCapabilitiesImpl(); - cap1.setAllVersionsSearchable(Boolean.TRUE); - cap1.setCapabilityAcl(CapabilityAcl.DISCOVER); - cap1.setCapabilityChanges(CapabilityChanges.ALL); - cap1.setCapabilityContentStreamUpdates(CapabilityContentStreamUpdates.ANYTIME); - cap1.setCapabilityJoin(CapabilityJoin.INNERANDOUTER); - cap1.setCapabilityQuery(CapabilityQuery.BOTHCOMBINED); - cap1.setCapabilityRendition(CapabilityRenditions.READ); - cap1.setIsPwcSearchable(Boolean.TRUE); - cap1.setIsPwcUpdatable(Boolean.TRUE); - cap1.setSupportsGetDescendants(Boolean.TRUE); - cap1.setSupportsGetFolderTree(Boolean.TRUE); - cap1.setSupportsMultifiling(Boolean.TRUE); - cap1.setSupportsUnfiling(Boolean.TRUE); - cap1.setSupportsVersionSpecificFiling(Boolean.TRUE); - obj1.setRepositoryCapabilities(cap1); - - AclCapabilitiesDataImpl acl1 = new AclCapabilitiesDataImpl(); - acl1.setAclPropagation(AclPropagation.PROPAGATE); - List<PermissionDefinition> pddList = new ArrayList<PermissionDefinition>(); - PermissionDefinitionDataImpl pdd1 = new PermissionDefinitionDataImpl(); - pdd1.setPermission("test:perm1"); - pdd1.setDescription("Permission1"); - pddList.add(pdd1); - PermissionDefinitionDataImpl pdd2 = new PermissionDefinitionDataImpl(); - pdd2.setPermission("test:perm2"); - pdd2.setDescription("Permission2"); - pddList.add(pdd2); - acl1.setPermissionDefinitionData(pddList); - Map<String, PermissionMapping> pmd = new LinkedHashMap<String, PermissionMapping>(); - PermissionMappingDataImpl pmd1 = new PermissionMappingDataImpl(); - pmd1.setKey(PermissionMapping.CAN_CREATE_DOCUMENT_FOLDER); - pmd1.setPermissions(Arrays.asList(new String[] { "p1", "p2" })); - pmd.put(pmd1.getKey(), pmd1); - PermissionMappingDataImpl pmd2 = new PermissionMappingDataImpl(); - pmd2.setKey(PermissionMapping.CAN_DELETE_OBJECT); - pmd2.setPermissions(Arrays.asList(new String[] { "p3", "p4" })); - pmd.put(pmd2.getKey(), pmd2); - acl1.setPermissionMappingData(pmd); - obj1.setAclCapabilities(acl1); - - obj2 = Converter.convert(Converter.convert(obj1)); - - assertDataObjectsEquals("RepositoryInfo", obj1, obj2); - } - - public void testTypeDefinition() throws Exception { - // dry run - DocumentTypeDefinitionImpl obj1 = new DocumentTypeDefinitionImpl(); - TypeDefinition obj2 = Converter.convert(Converter.convert(obj1)); - - assertDataObjectsEquals("TypeDefinition", obj1, obj2); - - // simple values - obj1 = new DocumentTypeDefinitionImpl(); - obj1.setBaseTypeId(BaseTypeId.CMIS_DOCUMENT); - obj1.setContentStreamAllowed(ContentStreamAllowed.ALLOWED); - obj1.setDescription("description"); - obj1.setDisplayName("displayName"); - obj1.setId("id"); - obj1.setIsControllableAcl(Boolean.TRUE); - obj1.setIsControllablePolicy(Boolean.TRUE); - obj1.setIsCreatable(Boolean.TRUE); - obj1.setIsFileable(Boolean.TRUE); - obj1.setIsIncludedInSupertypeQuery(Boolean.TRUE); - obj1.setIsQueryable(Boolean.TRUE); - obj1.setIsVersionable(Boolean.TRUE); - obj1.setLocalName("localName"); - obj1.setLocalNamespace("localNamespace"); - obj1.setParentTypeId("parentId"); - obj1.setQueryName("queryName"); - - obj2 = Converter.convert(Converter.convert(obj1)); - - assertDataObjectsEquals("TypeDefinition", obj1, obj2); - } - - public void testObject() throws Exception { - // dry run - ObjectDataImpl obj1 = new ObjectDataImpl(); - ObjectData obj2 = Converter.convert(Converter.convert(obj1)); - - assertDataObjectsEquals("Object", obj1, obj2); - } - - /** - * Asserts OpenCMIS data objects. - */ - protected void assertDataObjectsEquals(String name, Object expected, Object actual) throws Exception { - System.out.println(name); - - if ((expected == null) && (actual == null)) { - return; - } - - if ((expected == null) && (actual instanceof Collection<?>)) { - assertTrue(((Collection<?>) actual).isEmpty()); - return; - } else if ((expected instanceof Collection<?>) && (actual == null)) { - assertTrue(((Collection<?>) expected).isEmpty()); - return; - } else if ((expected == null) || (actual == null)) { - fail("Data object is null! name: " + name + " / expected: " + expected + " / actual: " + actual); - } - - // handle simple types - if ((expected instanceof String) || (expected instanceof Boolean) || (expected instanceof BigInteger) - || (expected instanceof BigDecimal) || (expected instanceof Enum<?>)) { - assertEquals(expected, actual); - - return; - } else if (expected instanceof List<?>) { - List<?> expectedList = (List<?>) expected; - List<?> actualList = (List<?>) actual; - - assertEquals(expectedList.size(), actualList.size()); - - for (int i = 0; i < expectedList.size(); i++) { - assertDataObjectsEquals(name + "[" + i + "]", expectedList.get(i), actualList.get(i)); - } - - return; - } else if (expected instanceof Map<?, ?>) { - Map<?, ?> expectedMap = (Map<?, ?>) expected; - Map<?, ?> actualMap = (Map<?, ?>) actual; - - assertEquals(expectedMap.size(), actualMap.size()); - - for (Map.Entry<?, ?> entry : expectedMap.entrySet()) { - assertTrue(actualMap.containsKey(entry.getKey())); - assertDataObjectsEquals(name + "[" + entry.getKey() + "]", entry.getValue(), actualMap.get(entry - .getKey())); - } - - return; - } - - for (Method m : expected.getClass().getMethods()) { - if (!m.getName().startsWith("get") && !m.getName().startsWith("supports")) { - continue; - } - - if (m.getName().equals("getClass")) { - continue; - } - - if (m.getParameterTypes().length != 0) { - continue; - } - - Object expectedValue = m.invoke(expected, new Object[0]); - Object actualValue = m.invoke(actual, new Object[0]); - - assertDataObjectsEquals(name + "." + m.getName(), expectedValue, actualValue); - } - } + public void testRepositoryInfo() throws Exception { + // dry run + RepositoryInfoImpl obj1 = new RepositoryInfoImpl(); + RepositoryInfo obj2 = Converter.convert(Converter.convert(obj1)); + + assertDataObjectsEquals("RepositoryInfo", obj1, obj2); + + // values + obj1 = new RepositoryInfoImpl(); + obj1.setChangesIncomplete(Boolean.TRUE); + obj1.setChangesOnType(Collections.singletonList(BaseTypeId.CMIS_DOCUMENT)); + obj1.setCmisVersionSupported("1.0"); + obj1.setLatestChangeLogToken("changeLogToken"); + obj1.setPrincipalAnonymous("principalAnonymous"); + obj1.setPrincipalAnyone("principalAnyone"); + obj1.setProductName("productName"); + obj1.setProductVersion("productVersion"); + obj1.setRepositoryDescription("description"); + obj1.setRepositoryId("id"); + obj1.setRepositoryName("name"); + obj1.setRootFolder("rootFolderId"); + obj1.setThinClientUri("thinClientUri"); + obj1.setVendorName("vendorName"); + + RepositoryCapabilitiesImpl cap1 = new RepositoryCapabilitiesImpl(); + cap1.setAllVersionsSearchable(Boolean.TRUE); + cap1.setCapabilityAcl(CapabilityAcl.DISCOVER); + cap1.setCapabilityChanges(CapabilityChanges.ALL); + cap1.setCapabilityContentStreamUpdates(CapabilityContentStreamUpdates.ANYTIME); + cap1.setCapabilityJoin(CapabilityJoin.INNERANDOUTER); + cap1.setCapabilityQuery(CapabilityQuery.BOTHCOMBINED); + cap1.setCapabilityRendition(CapabilityRenditions.READ); + cap1.setIsPwcSearchable(Boolean.TRUE); + cap1.setIsPwcUpdatable(Boolean.TRUE); + cap1.setSupportsGetDescendants(Boolean.TRUE); + cap1.setSupportsGetFolderTree(Boolean.TRUE); + cap1.setSupportsMultifiling(Boolean.TRUE); + cap1.setSupportsUnfiling(Boolean.TRUE); + cap1.setSupportsVersionSpecificFiling(Boolean.TRUE); + obj1.setRepositoryCapabilities(cap1); + + AclCapabilitiesDataImpl acl1 = new AclCapabilitiesDataImpl(); + acl1.setAclPropagation(AclPropagation.PROPAGATE); + List<PermissionDefinition> pddList = new ArrayList<PermissionDefinition>(); + PermissionDefinitionDataImpl pdd1 = new PermissionDefinitionDataImpl(); + pdd1.setPermission("test:perm1"); + pdd1.setDescription("Permission1"); + pddList.add(pdd1); + PermissionDefinitionDataImpl pdd2 = new PermissionDefinitionDataImpl(); + pdd2.setPermission("test:perm2"); + pdd2.setDescription("Permission2"); + pddList.add(pdd2); + acl1.setPermissionDefinitionData(pddList); + Map<String, PermissionMapping> pmd = new LinkedHashMap<String, PermissionMapping>(); + PermissionMappingDataImpl pmd1 = new PermissionMappingDataImpl(); + pmd1.setKey(PermissionMapping.CAN_CREATE_DOCUMENT_FOLDER); + pmd1.setPermissions(Arrays.asList(new String[] { "p1", "p2" })); + pmd.put(pmd1.getKey(), pmd1); + PermissionMappingDataImpl pmd2 = new PermissionMappingDataImpl(); + pmd2.setKey(PermissionMapping.CAN_DELETE_OBJECT); + pmd2.setPermissions(Arrays.asList(new String[] { "p3", "p4" })); + pmd.put(pmd2.getKey(), pmd2); + acl1.setPermissionMappingData(pmd); + obj1.setAclCapabilities(acl1); + + obj2 = Converter.convert(Converter.convert(obj1)); + + assertDataObjectsEquals("RepositoryInfo", obj1, obj2); + } + + public void testTypeDefinition() throws Exception { + // dry run + DocumentTypeDefinitionImpl obj1 = new DocumentTypeDefinitionImpl(); + TypeDefinition obj2 = Converter.convert(Converter.convert(obj1)); + + assertDataObjectsEquals("TypeDefinition", obj1, obj2); + + // simple values + obj1 = new DocumentTypeDefinitionImpl(); + obj1.setBaseTypeId(BaseTypeId.CMIS_DOCUMENT); + obj1.setContentStreamAllowed(ContentStreamAllowed.ALLOWED); + obj1.setDescription("description"); + obj1.setDisplayName("displayName"); + obj1.setId("id"); + obj1.setIsControllableAcl(Boolean.TRUE); + obj1.setIsControllablePolicy(Boolean.TRUE); + obj1.setIsCreatable(Boolean.TRUE); + obj1.setIsFileable(Boolean.TRUE); + obj1.setIsIncludedInSupertypeQuery(Boolean.TRUE); + obj1.setIsQueryable(Boolean.TRUE); + obj1.setIsVersionable(Boolean.TRUE); + obj1.setLocalName("localName"); + obj1.setLocalNamespace("localNamespace"); + obj1.setParentTypeId("parentId"); + obj1.setQueryName("queryName"); + + obj2 = Converter.convert(Converter.convert(obj1)); + + assertDataObjectsEquals("TypeDefinition", obj1, obj2); + } + + public void testObject() throws Exception { + // dry run + ObjectDataImpl obj1 = new ObjectDataImpl(); + ObjectData obj2 = Converter.convert(Converter.convert(obj1)); + + assertDataObjectsEquals("Object", obj1, obj2); + } + + /** + * Asserts OpenCMIS data objects. + */ + protected void assertDataObjectsEquals(String name, Object expected, Object actual) throws Exception { + System.out.println(name); + + if ((expected == null) && (actual == null)) { + return; + } + + if ((expected == null) && (actual instanceof Collection<?>)) { + assertTrue(((Collection<?>) actual).isEmpty()); + return; + } else if ((expected instanceof Collection<?>) && (actual == null)) { + assertTrue(((Collection<?>) expected).isEmpty()); + return; + } else if ((expected == null) || (actual == null)) { + fail("Data object is null! name: " + name + " / expected: " + expected + " / actual: " + actual); + } + + // handle simple types + if ((expected instanceof String) || (expected instanceof Boolean) || (expected instanceof BigInteger) + || (expected instanceof BigDecimal) || (expected instanceof Enum<?>)) { + assertEquals(expected, actual); + + return; + } else if (expected instanceof List<?>) { + List<?> expectedList = (List<?>) expected; + List<?> actualList = (List<?>) actual; + + assertEquals(expectedList.size(), actualList.size()); + + for (int i = 0; i < expectedList.size(); i++) { + assertDataObjectsEquals(name + "[" + i + "]", expectedList.get(i), actualList.get(i)); + } + + return; + } else if (expected instanceof Map<?, ?>) { + Map<?, ?> expectedMap = (Map<?, ?>) expected; + Map<?, ?> actualMap = (Map<?, ?>) actual; + + assertEquals(expectedMap.size(), actualMap.size()); + + for (Map.Entry<?, ?> entry : expectedMap.entrySet()) { + assertTrue(actualMap.containsKey(entry.getKey())); + assertDataObjectsEquals(name + "[" + entry.getKey() + "]", entry.getValue(), actualMap.get(entry + .getKey())); + } + + return; + } + + for (Method m : expected.getClass().getMethods()) { + if (!m.getName().startsWith("get") && !m.getName().startsWith("supports")) { + continue; + } + + if (m.getName().equals("getClass")) { + continue; + } + + if (m.getParameterTypes().length != 0) { + continue; + } + + Object expectedValue = m.invoke(expected, new Object[0]); + Object actualValue = m.invoke(actual, new Object[0]); + + assertDataObjectsEquals(name + "." + m.getName(), expectedValue, actualValue); + } + } } Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/MiscTest.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/MiscTest.java?rev=936933&r1=936932&r2=936933&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/MiscTest.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/MiscTest.java Thu Apr 22 16:18:22 2010 @@ -30,31 +30,31 @@ import junit.framework.TestCase; */ public class MiscTest extends TestCase { - public void testUrlBuilder() { - assertEquals("http://host/test", (new UrlBuilder("http://host/test")).toString()); - assertEquals("http://host/test?query=value", (new UrlBuilder("http://host/test?query=value")).toString()); - assertEquals("http://host/test", (new UrlBuilder("http://host/test?")).toString()); - - UrlBuilder urlBuilder; - - urlBuilder = new UrlBuilder("http://host/test"); - urlBuilder.addParameter("query", "value"); - assertEquals("http://host/test?query=value", urlBuilder.toString()); - - urlBuilder = new UrlBuilder("http://host/test"); - urlBuilder.addPath("path"); - assertEquals("http://host/test/path", urlBuilder.toString()); - - urlBuilder = new UrlBuilder("http://host/test/"); - urlBuilder.addPath("path"); - assertEquals("http://host/test/path", urlBuilder.toString()); - - urlBuilder = new UrlBuilder("http://host/test"); - urlBuilder.addPath("/path"); - assertEquals("http://host/test/path", urlBuilder.toString()); - - urlBuilder = new UrlBuilder("http://host/test/"); - urlBuilder.addPath("/path"); - assertEquals("http://host/test/path", urlBuilder.toString()); - } + public void testUrlBuilder() { + assertEquals("http://host/test", (new UrlBuilder("http://host/test")).toString()); + assertEquals("http://host/test?query=value", (new UrlBuilder("http://host/test?query=value")).toString()); + assertEquals("http://host/test", (new UrlBuilder("http://host/test?")).toString()); + + UrlBuilder urlBuilder; + + urlBuilder = new UrlBuilder("http://host/test"); + urlBuilder.addParameter("query", "value"); + assertEquals("http://host/test?query=value", urlBuilder.toString()); + + urlBuilder = new UrlBuilder("http://host/test"); + urlBuilder.addPath("path"); + assertEquals("http://host/test/path", urlBuilder.toString()); + + urlBuilder = new UrlBuilder("http://host/test/"); + urlBuilder.addPath("path"); + assertEquals("http://host/test/path", urlBuilder.toString()); + + urlBuilder = new UrlBuilder("http://host/test"); + urlBuilder.addPath("/path"); + assertEquals("http://host/test/path", urlBuilder.toString()); + + urlBuilder = new UrlBuilder("http://host/test/"); + urlBuilder.addPath("/path"); + assertEquals("http://host/test/path", urlBuilder.toString()); + } }
