You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by je...@apache.org on 2013/08/23 10:53:50 UTC
svn commit: r1516753 [5/8] - in
/chemistry/opencmis/trunk/chemistry-opencmis-server:
chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/
chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis...
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java?rev=1516753&r1=1516752&r2=1516753&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java Fri Aug 23 08:53:49 2013
@@ -141,7 +141,6 @@ public class ObjectServiceTest extends A
public static final String TEST_POLICY_TYPE_ID = "AuditPolicy";
public static final String TEST_POLICY_PROPERTY_ID = "AuditSettings";
-
ObjectCreator fCreator;
@Override
@@ -185,8 +184,8 @@ public class ObjectServiceTest extends A
// test create a document with an illegal name, should fail:
try {
Properties props = createDocumentProperties("abc (:*)", DOCUMENT_TYPE_ID);
- fObjSvc.createDocument(fRepositoryId, props, fRootFolderId, null, VersioningState.NONE, null, null,
- null, null);
+ fObjSvc.createDocument(fRepositoryId, props, fRootFolderId, null, VersioningState.NONE, null, null, null,
+ null);
fail("Creating document with an illegal name should fail.");
} catch (Exception e) {
assertTrue(e instanceof CmisInvalidArgumentException);
@@ -243,7 +242,9 @@ public class ObjectServiceTest extends A
}
try {
- createFolderNoCatch("/(%#$���������������������������������������������������������������������������������", fRootFolderId, FOLDER_TYPE_ID);
+ createFolderNoCatch(
+ "/(%#$���������������������������������������������������������������������������������",
+ fRootFolderId, FOLDER_TYPE_ID);
fail("Folder creation with ilegal name should fail.");
} catch (Exception e) {
assertTrue(e instanceof CmisInvalidArgumentException);
@@ -340,23 +341,23 @@ public class ObjectServiceTest extends A
String changeToken = (String) props.getProperties().get(PropertyIds.CHANGE_TOKEN).getFirstValue();
Holder<String> tokenHolder = new Holder<String>(changeToken);
fObjSvc.deleteContentStream(fRepositoryId, idHolder, tokenHolder, null);
-
+
try {
props = fObjSvc.getProperties(fRepositoryId, id, PropertyIds.CHANGE_TOKEN, null);
changeToken = (String) props.getProperties().get(PropertyIds.CHANGE_TOKEN).getFirstValue();
tokenHolder = new Holder<String>(changeToken);
- sd = fObjSvc.getContentStream(fRepositoryId, id, null, BigInteger.valueOf(-1) /* offset */, BigInteger
- .valueOf(-1) /* length */, null);
+ sd = fObjSvc.getContentStream(fRepositoryId, id, null, BigInteger.valueOf(-1) /* offset */,
+ BigInteger.valueOf(-1) /* length */, null);
fail("getContentStream with non existing content should raise a CmisConstraintException");
} catch (Exception e) {
assertTrue(e instanceof CmisConstraintException);
}
-
+
// create content again in a second call
ContentStream contentStream = createContent();
fObjSvc.setContentStream(fRepositoryId, idHolder, true, tokenHolder, contentStream, null);
- sd = fObjSvc.getContentStream(fRepositoryId, id, null, BigInteger.valueOf(-1) /* offset */, BigInteger
- .valueOf(-1) /* length */, null);
+ sd = fObjSvc.getContentStream(fRepositoryId, id, null, BigInteger.valueOf(-1) /* offset */,
+ BigInteger.valueOf(-1) /* length */, null);
verifyContentResult(sd);
// update content and do not set overwrite flag, expect failure
@@ -393,8 +394,8 @@ public class ObjectServiceTest extends A
String id = null;
try {
- id = fObjSvc.createDocument(fRepositoryId, props, fRootFolderId, contentStream, VersioningState.NONE, policies,
- addACEs, removeACEs, extension);
+ id = fObjSvc.createDocument(fRepositoryId, props, fRootFolderId, contentStream, VersioningState.NONE,
+ policies, addACEs, removeACEs, extension);
if (null == id) {
fail("createDocument failed.");
}
@@ -665,7 +666,8 @@ public class ObjectServiceTest extends A
@Test
public void testUpdateProperties() {
- // TODO add test rename root folder and non root folder (must be a folder)
+ // TODO add test rename root folder and non root folder (must be a
+ // folder)
log.info("starting testUpdateProperties() ...");
String oldChangeToken, newChangeToken;
String id = createDocumentWithCustomType(MY_CUSTOM_NAME, fRootFolderId, false);
@@ -800,7 +802,7 @@ public class ObjectServiceTest extends A
} catch (Exception e) {
assertTrue(e instanceof CmisNameConstraintViolationException);
}
-
+
// test an invalid name
properties = new ArrayList<PropertyData<?>>();
properties.add(fFactory.createPropertyIdData(PropertyIds.NAME, "Invalid/Name"));
@@ -853,20 +855,20 @@ public class ObjectServiceTest extends A
}
ObjectData res = getDocumentObjectData(id);
Map<String, PropertyData<?>> props = res.getProperties().getProperties();
- PropertyData<?> pd = props.get(TEST_DOCUMENT_MY_INT_PROP_ID);
+ PropertyData<?> pd = props.get(TEST_DOCUMENT_MY_INT_PROP_ID);
assertNotNull(pd);
Object bi = pd.getFirstValue();
assertNotNull(bi);
assertEquals(BigInteger.valueOf(100), bi);
- pd = props.get(TEST_DOCUMENT_MY_MULTI_STRING_PROP_ID);
+ pd = props.get(TEST_DOCUMENT_MY_MULTI_STRING_PROP_ID);
assertNotNull(pd);
List<String> valueList = (List<String>) pd.getValues();
assertNotNull(valueList);
assertTrue(valueList.contains("Apache"));
assertTrue(valueList.contains("CMIS"));
- pd = props.get(TEST_DOCUMENT_MY_INT_PROP_ID_MANDATORY_DEFAULT);
+ pd = props.get(TEST_DOCUMENT_MY_INT_PROP_ID_MANDATORY_DEFAULT);
assertNotNull(pd);
bi = pd.getFirstValue();
assertNotNull(bi);
@@ -884,20 +886,20 @@ public class ObjectServiceTest extends A
}
ObjectData res = getDocumentObjectData(id);
Map<String, PropertyData<?>> props = res.getProperties().getProperties();
- PropertyData<?> pd = props.get(TEST_FOLDER_MY_INT_PROP_ID);
+ PropertyData<?> pd = props.get(TEST_FOLDER_MY_INT_PROP_ID);
assertNotNull(pd);
Object bi = pd.getFirstValue();
assertNotNull(bi);
assertEquals(BigInteger.valueOf(100), bi);
- pd = props.get(TEST_FOLDER_MY_MULTI_STRING_PROP_ID);
+ pd = props.get(TEST_FOLDER_MY_MULTI_STRING_PROP_ID);
assertNotNull(pd);
List<String> valueList = (List<String>) pd.getValues();
assertNotNull(valueList);
assertTrue(valueList.contains("Apache"));
assertTrue(valueList.contains("CMIS"));
- pd = props.get(TEST_FOLDER_MY_INT_PROP_ID_MANDATORY_DEFAULT);
+ pd = props.get(TEST_FOLDER_MY_INT_PROP_ID_MANDATORY_DEFAULT);
assertNotNull(pd);
bi = pd.getFirstValue();
assertNotNull(bi);
@@ -917,39 +919,41 @@ public class ObjectServiceTest extends A
log.info(" getting object");
String filter = PropertyIds.NAME + "," + PropertyIds.CREATION_DATE + "," + PropertyIds.LAST_MODIFICATION_DATE;
- ObjectData res = fObjSvc.getObject(fRepositoryId, id, filter, false, IncludeRelationships.NONE, null, false, false, null);
+ ObjectData res = fObjSvc.getObject(fRepositoryId, id, filter, false, IncludeRelationships.NONE, null, false,
+ false, null);
String returnedId = res.getId();
assertEquals(id, returnedId);
log.info("... testGetObjectNoObjectIdInFilter() finished.");
}
-
+
@Test
public void testSpecialChars() {
- log.info("starting testGetObjectByPath() with specal chars...");
- log.info(" creating object");
+ log.info("starting testGetObjectByPath() with specal chars...");
+ log.info(" creating object");
- String docID = createDocument("H��nschen", fRootFolderId, false);
- log.info(" getting object by path with special chars");
- try {
- ObjectData res = fObjSvc.getObjectByPath(fRepositoryId, "/H��nschen", "*", false, IncludeRelationships.NONE, null, false,
- false, null);
- assertNotNull(res);
- assertNotNull(res.getId());
- } catch (Exception e) {
- fail("getObject() failed with exception: " + e);
- }
+ String docID = createDocument("H��nschen", fRootFolderId, false);
+ log.info(" getting object by path with special chars");
+ try {
+ ObjectData res = fObjSvc.getObjectByPath(fRepositoryId, "/H��nschen", "*", false,
+ IncludeRelationships.NONE, null, false, false, null);
+ assertNotNull(res);
+ assertNotNull(res.getId());
+ } catch (Exception e) {
+ fail("getObject() failed with exception: " + e);
+ }
}
-
+
@Test
public void testNoContentAllowed() {
log.info("starting testNoContentAllowed() ...");
String id = createDocument("NoContentAllowedDoc1", fRootFolderId, TEST_CUSTOM_NO_CONTENT_TYPE_ID, false);
- assertNotNull (id);
+ assertNotNull(id);
try {
- id = createDocumentNoCatch("NoContentAllowedDoc2", fRootFolderId, TEST_CUSTOM_NO_CONTENT_TYPE_ID, VersioningState.NONE, true);
+ id = createDocumentNoCatch("NoContentAllowedDoc2", fRootFolderId, TEST_CUSTOM_NO_CONTENT_TYPE_ID,
+ VersioningState.NONE, true);
fail("Creating document with content and type allows no content should fail.");
} catch (Exception e) {
assertTrue(e instanceof CmisConstraintException);
@@ -962,10 +966,11 @@ public class ObjectServiceTest extends A
public void testMustHaveContent() {
log.info("starting testMustHaveContent() ...");
String id = createDocument("MustHaveContentAllowedDoc1", fRootFolderId, TEST_CUSTOM_MUST_CONTENT_TYPE_ID, true);
- assertNotNull (id);
+ assertNotNull(id);
try {
- id = createDocumentNoCatch("MustHaveContentAllowedDoc2", fRootFolderId, TEST_CUSTOM_MUST_CONTENT_TYPE_ID, VersioningState.NONE, false);
+ id = createDocumentNoCatch("MustHaveContentAllowedDoc2", fRootFolderId, TEST_CUSTOM_MUST_CONTENT_TYPE_ID,
+ VersioningState.NONE, false);
fail("Creating document without content and type requires content should fail.");
} catch (Exception e) {
assertTrue(e instanceof CmisConstraintException);
@@ -973,7 +978,7 @@ public class ObjectServiceTest extends A
}
log.info("... testMustHaveContent finished.");
}
-
+
@Test
public void testMaxContentSize() {
log.info("starting testMaxContentSize() ...");
@@ -1005,16 +1010,17 @@ public class ObjectServiceTest extends A
public void testRenditionImage() {
// upload an image as JPEG picture
log.info("starting testRendition() ...");
-
+
try {
InputStream imageStream = this.getClass().getResourceAsStream("/image.jpg");
- assertNotNull("Test setup failure no 'image.jpg' in test resources, getResourceAsStream failed", imageStream);
- String id = createDocumentFromStream("TestJpegImage", fRootFolderId, DOCUMENT_TYPE_ID, imageStream,
- JPEG);
+ assertNotNull("Test setup failure no 'image.jpg' in test resources, getResourceAsStream failed",
+ imageStream);
+ String id = createDocumentFromStream("TestJpegImage", fRootFolderId, DOCUMENT_TYPE_ID, imageStream, JPEG);
- assertNotNull (id);
+ assertNotNull(id);
String renditionFilter = "*";
- List<RenditionData> renditions = fObjSvc.getRenditions(fRepositoryId, id, renditionFilter, null, null, null);
+ List<RenditionData> renditions = fObjSvc
+ .getRenditions(fRepositoryId, id, renditionFilter, null, null, null);
assertNotNull(renditions);
assertEquals(1, renditions.size());
RenditionData rd = renditions.get(0);
@@ -1026,30 +1032,33 @@ public class ObjectServiceTest extends A
assertEquals(DocumentImpl.THUMBNAIL_SIZE, rd.getBigHeight().longValue());
assertEquals(DocumentImpl.THUMBNAIL_SIZE, rd.getBigWidth().longValue());
assertNotNull(rd.getStreamId());
- ContentStream renditionContent = fObjSvc.getContentStream(fRepositoryId, id, rd.getStreamId(), null, null, null);
+ ContentStream renditionContent = fObjSvc.getContentStream(fRepositoryId, id, rd.getStreamId(), null, null,
+ null);
assertEquals(rd.getMimeType(), renditionContent.getMimeType());
readThumbnailStream(renditionContent.getStream());
} catch (Exception e) {
log.error("testRendition failed with exception ", e);
fail("testRendition failed with exceetion " + e);
}
- log.info("... testRendition finished.");
+ log.info("... testRendition finished.");
}
-
+
@Test
public void testRenditionIcon() {
// fake an office document
log.info("starting testRendition() ...");
-
+
try {
- ContentStream content = createContent(4, 0, "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
+ ContentStream content = createContent(4, 0,
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
Properties props = createDocumentProperties("TestJOffice", DOCUMENT_TYPE_ID);
String id = fObjSvc.createDocument(fRepositoryId, props, fRootFolderId, content, VersioningState.NONE,
null, null, null, null);
- assertNotNull (id);
+ assertNotNull(id);
String renditionFilter = "*";
- List<RenditionData> renditions = fObjSvc.getRenditions(fRepositoryId, id, renditionFilter, null, null, null);
+ List<RenditionData> renditions = fObjSvc
+ .getRenditions(fRepositoryId, id, renditionFilter, null, null, null);
assertNotNull(renditions);
assertEquals(1, renditions.size());
RenditionData rd = renditions.get(0);
@@ -1061,28 +1070,32 @@ public class ObjectServiceTest extends A
assertEquals(StoredObjectImpl.ICON_SIZE, rd.getBigHeight().longValue());
assertEquals(StoredObjectImpl.ICON_SIZE, rd.getBigWidth().longValue());
assertNotNull(rd.getStreamId());
- ContentStream renditionContent = fObjSvc.getContentStream(fRepositoryId, id, rd.getStreamId(), null, null, null);
+ ContentStream renditionContent = fObjSvc.getContentStream(fRepositoryId, id, rd.getStreamId(), null, null,
+ null);
assertEquals(rd.getMimeType(), renditionContent.getMimeType());
readThumbnailStream(renditionContent.getStream());
} catch (Exception e) {
log.error("testRendition failed with exception ", e);
fail("testRendition failed with exceetion " + e);
}
- log.info("... testRendition finished.");
+ log.info("... testRendition finished.");
}
+
@Test
public void testFolderRendition() {
// upload an image as JPEG picture
log.info("starting testFolderRendition() ...");
-
+
try {
InputStream imageStream = this.getClass().getResourceAsStream("/image.jpg");
- assertNotNull("Test setup failure no 'image.jpg' in test resources, getResourceAsStream failed", imageStream);
- String id = createFolder();
+ assertNotNull("Test setup failure no 'image.jpg' in test resources, getResourceAsStream failed",
+ imageStream);
+ String id = createFolder();
- assertNotNull (id);
+ assertNotNull(id);
String renditionFilter = "*";
- List<RenditionData> renditions = fObjSvc.getRenditions(fRepositoryId, id, renditionFilter, null, null, null);
+ List<RenditionData> renditions = fObjSvc
+ .getRenditions(fRepositoryId, id, renditionFilter, null, null, null);
assertNotNull(renditions);
assertEquals(1, renditions.size());
RenditionData rd = renditions.get(0);
@@ -1094,7 +1107,8 @@ public class ObjectServiceTest extends A
assertEquals(StoredObjectImpl.ICON_SIZE, rd.getBigHeight().longValue());
assertEquals(StoredObjectImpl.ICON_SIZE, rd.getBigWidth().longValue());
assertNotNull(rd.getStreamId());
- ContentStream renditionContent = fObjSvc.getContentStream(fRepositoryId, id, rd.getStreamId(), null, null, null);
+ ContentStream renditionContent = fObjSvc.getContentStream(fRepositoryId, id, rd.getStreamId(), null, null,
+ null);
assertEquals(rd.getMimeType(), renditionContent.getMimeType());
readThumbnailStream(renditionContent.getStream());
} catch (Exception e) {
@@ -1102,9 +1116,9 @@ public class ObjectServiceTest extends A
fail("testFolderRendition failed with exceetion " + e);
}
log.info("... testFolderRendition finished.");
-
+
}
-
+
@Test
public void testAppendContent() {
log.info("starting testAppendContent() ...");
@@ -1115,7 +1129,7 @@ public class ObjectServiceTest extends A
// append content again in a second call
Holder<String> idHolder = new Holder<String>(id);
-
+
ContentStream contentStream = createContent();
fObjSvc.appendContentStream(fRepositoryId, idHolder, null, contentStream, false, null);
ContentStream sd = fObjSvc.getContentStream(fRepositoryId, id, null, null, null, null);
@@ -1141,8 +1155,8 @@ public class ObjectServiceTest extends A
Map<String, PropertyData<?>> props = res.getProperties().getProperties();
changeToken1 = (String) props.get(PropertyIds.CHANGE_TOKEN).getFirstValue();
- res = fObjSvc.getObject(fRepositoryId, id2, "*", false, IncludeRelationships.NONE, null, false,
- false, null);
+ res = fObjSvc
+ .getObject(fRepositoryId, id2, "*", false, IncludeRelationships.NONE, null, false, false, null);
assertNotNull(res);
props = res.getProperties().getProperties();
changeToken2 = (String) props.get(PropertyIds.CHANGE_TOKEN).getFirstValue();
@@ -1152,7 +1166,6 @@ public class ObjectServiceTest extends A
log.info(" return property id: " + pd.getId() + ", value: " + pd.getValues());
}
-
// update properties:
log.info("updating property");
List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
@@ -1160,7 +1173,7 @@ public class ObjectServiceTest extends A
properties.add(fFactory.createPropertyIntegerData(TEST_DOCUMENT_MY_INT_PROP_ID, NEW_INT_PROP_VAL));
Properties newProps = fFactory.createPropertiesData(properties);
// wait some time to get a newer change token
-
+
List<BulkUpdateObjectIdAndChangeToken> objs = new ArrayList<BulkUpdateObjectIdAndChangeToken>();
objs.add(new BulkUpdateObjectIdAndChangeTokenImpl(id1, changeToken1));
objs.add(new BulkUpdateObjectIdAndChangeTokenImpl(id2, changeToken2));
@@ -1169,15 +1182,14 @@ public class ObjectServiceTest extends A
newObjs = fObjSvc.bulkUpdateProperties(fRepositoryId, objs, newProps, null, null, null);
assertNotNull(newObjs);
assertEquals(objs.size(), newObjs.size());
- for (int i=0; i<newObjs.size(); i++) {
+ for (int i = 0; i < newObjs.size(); i++) {
assertEquals(objs.get(i).getId(), newObjs.get(i).getId());
- assertTrue(! objs.get(i).getChangeToken().equals(newObjs.get(i).getChangeToken()));
+ assertTrue(!objs.get(i).getChangeToken().equals(newObjs.get(i).getChangeToken()));
}
// check that new propertie are set
verifyUpdatedProperties(id1, MY_CUSTOM_NAME);
verifyUpdatedProperties(id2, MY_CUSTOM_NAME_2);
-
} catch (Exception e) {
fail("testBulkUpdateProperties() failed with exception: " + e);
}
@@ -1187,7 +1199,7 @@ public class ObjectServiceTest extends A
// CMIS 1.1: test item typpe
@Test
public void testItemCreation() {
-
+
log.info("starting testItemCreation() ...");
String propVal = "abc123";
String name = "CoolItem";
@@ -1196,7 +1208,7 @@ public class ObjectServiceTest extends A
log.info("testItemCreation succeeded with created id: " + id);
}
log.info("... testCreateObject() finished.");
-
+
// read document again and check properties
ObjectData res = getDocumentObjectData(id);
String returnedId = res.getId();
@@ -1204,17 +1216,18 @@ public class ObjectServiceTest extends A
testReturnedProperties(returnedId, name, TEST_ITEM_TYPE_ID, props);
PropertyData<?> pd = props.get(ITEM_STRING_PROP);
assertEquals(propVal, pd.getFirstValue());
- assertEquals(12, props.size()); // should not contain all the document properties
+ assertEquals(12, props.size()); // should not contain all the document
+ // properties
log.info("... finished testItemCreation()");
}
-
+
@Test
public void testSecondaryTypes() {
log.info("starting testItemCreation() ...");
final String strPropVal = "Secondary";
final BigInteger intPropVal = BigInteger.valueOf(100);
final String primaryPropVal = "Sample Doc String Property";
-
+
List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
properties.add(fFactory.createPropertyStringData(PropertyIds.NAME, "ObjectWithSecondaryType"));
properties.add(fFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, TEST_DOCUMENT_TYPE_ID));
@@ -1223,11 +1236,11 @@ public class ObjectServiceTest extends A
properties.add(fFactory.createPropertyStringData(SECONDARY_STRING_PROP, strPropVal));
properties.add(fFactory.createPropertyIntegerData(SECONDARY_INTEGER_PROP, intPropVal));
Properties props = fFactory.createPropertiesData(properties);
-
- String id = fObjSvc.createDocument(fRepositoryId, props, fRootFolderId, null, VersioningState.NONE, null,
- null, null, null);
+
+ String id = fObjSvc.createDocument(fRepositoryId, props, fRootFolderId, null, VersioningState.NONE, null, null,
+ null, null);
assertNotNull(id);
-
+
Properties res = fObjSvc.getProperties(fRepositoryId, id, "*", null);
assertNotNull(res.getProperties());
Map<String, PropertyData<?>> returnedProps = res.getProperties();
@@ -1238,7 +1251,7 @@ public class ObjectServiceTest extends A
assertEquals(intPropVal, returnedValueInt);
String returnedPrimaryPropVal = (String) returnedProps.get(TEST_DOCUMENT_STRING_PROP_ID).getFirstValue();
assertEquals(primaryPropVal, returnedPrimaryPropVal);
-
+
// test updating properties
final String strPropVal2 = "Secondary updated";
final String primaryPropVal2 = "Sample Doc String Property updated";
@@ -1247,7 +1260,7 @@ public class ObjectServiceTest extends A
properties.add(fFactory.createPropertyStringData(TEST_DOCUMENT_STRING_PROP_ID, primaryPropVal2));
props = fFactory.createPropertiesData(properties);
fObjSvc.updateProperties(fRepositoryId, new Holder<String>(id), new Holder<String>(), props, null);
-
+
res = fObjSvc.getProperties(fRepositoryId, id, "*", null);
assertNotNull(res.getProperties());
returnedProps = res.getProperties();
@@ -1258,26 +1271,27 @@ public class ObjectServiceTest extends A
assertEquals(intPropVal, returnedValueInt);
returnedPrimaryPropVal = (String) returnedProps.get(TEST_DOCUMENT_STRING_PROP_ID).getFirstValue();
assertEquals(primaryPropVal2, returnedPrimaryPropVal);
-
- log.info("... finished testSecondaryTypes()");
+
+ log.info("... finished testSecondaryTypes()");
}
+
@Test
public void testSecondaryTypePropertiesNotSet() {
log.info("starting testSecondaryTypePropertiesNotSet() ...");
final String primaryPropVal = "Sample Doc String Property";
-
+
List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
properties.add(fFactory.createPropertyStringData(PropertyIds.NAME, "ObjectWithSecondaryType"));
properties.add(fFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, TEST_DOCUMENT_TYPE_ID));
properties.add(fFactory.createPropertyStringData(TEST_DOCUMENT_STRING_PROP_ID, primaryPropVal));
properties.add(fFactory.createPropertyIdData(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, TEST_SECONDARY_TYPE_ID));
Properties props = fFactory.createPropertiesData(properties);
-
- String id = fObjSvc.createDocument(fRepositoryId, props, fRootFolderId, null, VersioningState.NONE, null,
- null, null, null);
+
+ String id = fObjSvc.createDocument(fRepositoryId, props, fRootFolderId, null, VersioningState.NONE, null, null,
+ null, null);
assertNotNull(id);
-
+
Properties res = fObjSvc.getProperties(fRepositoryId, id, "*", null);
assertNotNull(res.getProperties());
Map<String, PropertyData<?>> returnedProps = res.getProperties();
@@ -1292,27 +1306,27 @@ public class ObjectServiceTest extends A
returnedValue = returnedProps.get(SECONDARY_INTEGER_PROP);
assertNotNull(returnedValue);
assertTrue(returnedValue.getValues().isEmpty());
-
- log.info("... finished testSecondaryTypePropertiesNotSet()");
- }
-
+
+ log.info("... finished testSecondaryTypePropertiesNotSet()");
+ }
+
@Test
- public void testUpdatePropertiesWithTypeCreation () {
+ public void testUpdatePropertiesWithTypeCreation() {
final String strPropVal = "Secondary";
final BigInteger intPropVal = BigInteger.valueOf(100);
final String primaryPropVal = "Sample Doc String Property";
final String primaryPropVal2 = "Sample Doc String Property updated";
log.info("starting testUpdatePropertiesWithTypeCreation() ...");
-
+
List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
properties.add(fFactory.createPropertyStringData(PropertyIds.NAME, "SimpleDocument"));
properties.add(fFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, TEST_DOCUMENT_TYPE_ID));
properties.add(fFactory.createPropertyStringData(TEST_DOCUMENT_STRING_PROP_ID, primaryPropVal));
Properties props = fFactory.createPropertiesData(properties);
-
- String id = fObjSvc.createDocument(fRepositoryId, props, fRootFolderId, null, VersioningState.NONE, null,
- null, null, null);
+
+ String id = fObjSvc.createDocument(fRepositoryId, props, fRootFolderId, null, VersioningState.NONE, null, null,
+ null, null);
assertNotNull(id);
properties = new ArrayList<PropertyData<?>>();
@@ -1322,7 +1336,7 @@ public class ObjectServiceTest extends A
properties.add(fFactory.createPropertyIntegerData(SECONDARY_INTEGER_PROP, intPropVal));
props = fFactory.createPropertiesData(properties);
fObjSvc.updateProperties(fRepositoryId, new Holder<String>(id), new Holder<String>(), props, null);
-
+
Properties res = fObjSvc.getProperties(fRepositoryId, id, "*", null);
assertNotNull(res.getProperties());
Map<String, PropertyData<?>> returnedProps = res.getProperties();
@@ -1336,19 +1350,19 @@ public class ObjectServiceTest extends A
assertEquals(intPropVal, returnedValueInt);
String returnedPrimaryPropVal = (String) returnedProps.get(TEST_DOCUMENT_STRING_PROP_ID).getFirstValue();
assertEquals(primaryPropVal2, returnedPrimaryPropVal);
-
- log.info("... finished testUpdatePropertiesWithTypeCreation()");
+
+ log.info("... finished testUpdatePropertiesWithTypeCreation()");
}
-
+
@Test
- public void testDeleteSecondaryType () {
+ public void testDeleteSecondaryType() {
final String primaryPropVal = "Sample Doc String Property";
final String primaryPropVal2 = "Sample Doc String Property updated";
final String strPropVal = "Secondary";
final BigInteger intPropVal = BigInteger.valueOf(100);
log.info("starting testDeleteSecondaryType() ...");
-
+
// create a document with a secondary type
List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
properties.add(fFactory.createPropertyStringData(PropertyIds.NAME, "ObjectWithSecondaryType"));
@@ -1358,18 +1372,21 @@ public class ObjectServiceTest extends A
properties.add(fFactory.createPropertyStringData(SECONDARY_STRING_PROP, strPropVal));
properties.add(fFactory.createPropertyIntegerData(SECONDARY_INTEGER_PROP, intPropVal));
Properties props = fFactory.createPropertiesData(properties);
-
- String id = fObjSvc.createDocument(fRepositoryId, props, fRootFolderId, null, VersioningState.NONE, null,
- null, null, null);
+
+ String id = fObjSvc.createDocument(fRepositoryId, props, fRootFolderId, null, VersioningState.NONE, null, null,
+ null, null);
assertNotNull(id);
// delete the secondary type
properties = new ArrayList<PropertyData<?>>();
properties.add(fFactory.createPropertyStringData(TEST_DOCUMENT_STRING_PROP_ID, primaryPropVal2));
- properties.add(fFactory.createPropertyIdData(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, (String)null)); // set list to empty
+ properties.add(fFactory.createPropertyIdData(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, (String) null)); // set
+ // list
+ // to
+ // empty
props = fFactory.createPropertiesData(properties);
fObjSvc.updateProperties(fRepositoryId, new Holder<String>(id), new Holder<String>(), props, null);
-
+
// test that properties are gone
Properties res = fObjSvc.getProperties(fRepositoryId, id, "*", null);
assertNotNull(res.getProperties());
@@ -1378,33 +1395,36 @@ public class ObjectServiceTest extends A
assertEquals(0, returnedProps.get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS).getValues().size());
PropertyData<?> pd = returnedProps.get(SECONDARY_STRING_PROP);
assertNull(pd); // property must not exist any longer
- pd = returnedProps.get(SECONDARY_INTEGER_PROP);
- assertNull(pd); // property must not exist any longer
+ pd = returnedProps.get(SECONDARY_INTEGER_PROP);
+ assertNull(pd); // property must not exist any longer
String returnedPrimaryPropVal = (String) returnedProps.get(TEST_DOCUMENT_STRING_PROP_ID).getFirstValue();
- assertEquals(primaryPropVal2, returnedPrimaryPropVal); // other properties should be updated
+ assertEquals(primaryPropVal2, returnedPrimaryPropVal); // other
+ // properties
+ // should be
+ // updated
// test that system properties are there
pd = returnedProps.get(PropertyIds.NAME);
- assertNotNull(pd);
+ assertNotNull(pd);
pd = returnedProps.get(PropertyIds.OBJECT_ID);
- assertNotNull(pd);
+ assertNotNull(pd);
pd = returnedProps.get(PropertyIds.OBJECT_TYPE_ID);
- assertNotNull(pd);
-
- log.info("... finished testDeleteSecondaryType()");
+ assertNotNull(pd);
+
+ log.info("... finished testDeleteSecondaryType()");
}
-
+
// TODO: test constraints on secondary types
-
-
+
private void verifyUpdatedProperties(String id, String name) {
-
- ObjectData res = fObjSvc.getObject(fRepositoryId, id, "*", false, IncludeRelationships.NONE, null, false, false, null);
+
+ ObjectData res = fObjSvc.getObject(fRepositoryId, id, "*", false, IncludeRelationships.NONE, null, false,
+ false, null);
assertNotNull(res);
Map<String, PropertyData<?>> props = res.getProperties().getProperties();
for (PropertyData<?> pd2 : props.values()) {
log.info(" return property id: " + pd2.getId() + ", value: " + pd2.getValues());
}
-
+
PropertyData<?> pd;
pd = props.get(PropertyIds.NAME);
assertNotNull(pd);
@@ -1427,27 +1447,27 @@ public class ObjectServiceTest extends A
content.setMimeType(contentType);
ByteArrayOutputStream ba = new ByteArrayOutputStream();
- byte[] buffer = new byte [65536];
+ byte[] buffer = new byte[65536];
int noBytesRead = 0;
- while ((noBytesRead = is.read(buffer)) >=0 ) {
+ while ((noBytesRead = is.read(buffer)) >= 0) {
ba.write(buffer, 0, noBytesRead);
}
-
+
content.setContent(new ByteArrayInputStream(ba.toByteArray()));
- String id = fObjSvc.createDocument(fRepositoryId, props, folderId, content, VersioningState.NONE, null,
- null, null, null);
+ String id = fObjSvc.createDocument(fRepositoryId, props, folderId, content, VersioningState.NONE, null, null,
+ null, null);
return id;
}
private void readThumbnailStream(InputStream stream) {
-
- byte[] buffer = new byte [65536];
+
+ byte[] buffer = new byte[65536];
int noBytesRead = 0;
int count = 0;
try {
- while ((noBytesRead = stream.read(buffer)) >=0 ) {
+ while ((noBytesRead = stream.read(buffer)) >= 0) {
count += noBytesRead;
}
} catch (IOException e) {
@@ -1513,7 +1533,7 @@ public class ObjectServiceTest extends A
}
private void moveObjectTest(boolean isFolder) {
- final String propertyFilter = PropertyIds.OBJECT_ID + "," + PropertyIds.NAME;
+ final String propertyFilter = PropertyIds.OBJECT_ID + "," + PropertyIds.NAME;
String rootFolderId = createFolder();
ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepSvc, fRepositoryId,
ObjectGenerator.ContentKind.LOREM_IPSUM_TEXT);
@@ -1571,7 +1591,7 @@ public class ObjectServiceTest extends A
}
private String createItem(String name, String folderId, String itemPropVal) {
-
+
// create the properties:
List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
properties.add(fFactory.createPropertyStringData(PropertyIds.NAME, name));
@@ -1685,25 +1705,27 @@ public class ObjectServiceTest extends A
public static class ObjectTestTypeSystemCreator implements TypeCreator {
- static final TypeDefinitionFactory typeFactory = DocumentTypeCreationHelper.getTypeDefinitionFactory();
+ static final TypeDefinitionFactory typeFactory = DocumentTypeCreationHelper.getTypeDefinitionFactory();
/**
* create root types and a sample type for folder and document
- *
+ *
* @return typesMap map filled with created types
*/
@Override
- public List<TypeDefinition> createTypesList() {
+ public List<TypeDefinition> createTypesList() {
List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
-
+
try {
- MutableTypeDefinition cmisDocumentType;
- cmisDocumentType = typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), TEST_DOCUMENT_TYPE_ID);
+ MutableTypeDefinition cmisDocumentType;
+ cmisDocumentType = typeFactory.createChildTypeDefinition(
+ DocumentTypeCreationHelper.getCmisDocumentType(), TEST_DOCUMENT_TYPE_ID);
cmisDocumentType.setDisplayName("My Document Type");
cmisDocumentType.setDescription("InMemory test type definition " + TEST_DOCUMENT_TYPE_ID);
-
- MutableFolderTypeDefinition cmisFolderType;
- cmisFolderType = typeFactory.createFolderTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisFolderType().getId());
+
+ MutableFolderTypeDefinition cmisFolderType;
+ cmisFolderType = typeFactory.createFolderTypeDefinition(CmisVersion.CMIS_1_1,
+ DocumentTypeCreationHelper.getCmisFolderType().getId());
cmisFolderType.setId(TEST_FOLDER_TYPE_ID);
cmisFolderType.setDisplayName("My Folder Type");
cmisFolderType.setDescription("InMemory test type definition " + TEST_FOLDER_TYPE_ID);
@@ -1715,13 +1737,13 @@ public class ObjectServiceTest extends A
TEST_DOCUMENT_STRING_PROP_ID, "Sample Doc String Property", Updatability.READWRITE);
propertyDefinitions.put(prop.getId(), prop);
cmisDocumentType.addPropertyDefinition(prop);
-
+
propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
prop = PropertyCreationHelper.createStringDefinition(TEST_FOLDER_STRING_PROP_ID,
"Sample Folder String Property", Updatability.READWRITE);
propertyDefinitions.put(prop.getId(), prop);
cmisFolderType.addPropertyDefinition(prop);
-
+
DocumentTypeDefinition customDocType = createCustomTypeWithStringIntProperty();
TypeDefinition noContentType = createCustomTypeNoContent();
TypeDefinition mustHaveContentType = createCustomTypeMustHaveContent();
@@ -1729,7 +1751,7 @@ public class ObjectServiceTest extends A
TypeDefinition relTypeRestricted = createRelationshipTypeRestricted();
TypeDefinition verType = createVersionableType();
TypeDefinition polType = createPolicyType();
-
+
// add type to types collection
typesList.add(cmisDocumentType);
typesList.add(cmisFolderType);
@@ -1751,12 +1773,14 @@ public class ObjectServiceTest extends A
}
}
- private static DocumentTypeDefinition createCustomTypeWithStringIntProperty() throws InstantiationException, IllegalAccessException {
- MutableDocumentTypeDefinition cmisDocumentType;
- cmisDocumentType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), TEST_CUSTOM_DOCUMENT_TYPE_ID);
+ private static DocumentTypeDefinition createCustomTypeWithStringIntProperty() throws InstantiationException,
+ IllegalAccessException {
+ MutableDocumentTypeDefinition cmisDocumentType;
+ cmisDocumentType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(
+ DocumentTypeCreationHelper.getCmisDocumentType(), TEST_CUSTOM_DOCUMENT_TYPE_ID);
cmisDocumentType.setDisplayName("My Custom Document Type");
cmisDocumentType.setDescription("InMemory test type definition " + TEST_CUSTOM_DOCUMENT_TYPE_ID);
-
+
PropertyStringDefinitionImpl prop = PropertyCreationHelper.createStringDefinition(
TEST_DOCUMENT_MY_STRING_PROP_ID, "My String Property", Updatability.READWRITE);
prop.setIsRequired(false);
@@ -1772,12 +1796,13 @@ public class ObjectServiceTest extends A
return cmisDocumentType;
}
- private static TypeDefinition createCustomInheritedType(DocumentTypeDefinition baseType) throws InstantiationException, IllegalAccessException {
- MutableTypeDefinition cmisDocumentType;
+ private static TypeDefinition createCustomInheritedType(DocumentTypeDefinition baseType)
+ throws InstantiationException, IllegalAccessException {
+ MutableTypeDefinition cmisDocumentType;
cmisDocumentType = typeFactory.createChildTypeDefinition(baseType, TEST_INHERITED_CUSTOM_DOCUMENT_TYPE_ID);
cmisDocumentType.setDisplayName("My Custom Document Type");
cmisDocumentType.setDescription("InMemory test type definition " + TEST_INHERITED_CUSTOM_DOCUMENT_TYPE_ID);
-
+
PropertyStringDefinitionImpl prop = PropertyCreationHelper.createStringDefinition(
TEST_DOCUMENT_MY_SUB_STRING_PROP_ID, "Subtype String Property", Updatability.READWRITE);
prop.setIsRequired(false);
@@ -1790,58 +1815,79 @@ public class ObjectServiceTest extends A
return cmisDocumentType;
}
- private static TypeDefinition createDocumentTypeWithDefault() throws InstantiationException, IllegalAccessException {
- MutableTypeDefinition cmisDocumentType;
- cmisDocumentType = typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), TEST_DOC_TYPE_WITH_DEFAULTS_ID);
+ private static TypeDefinition createDocumentTypeWithDefault() throws InstantiationException,
+ IllegalAccessException {
+ MutableTypeDefinition cmisDocumentType;
+ cmisDocumentType = typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(),
+ TEST_DOC_TYPE_WITH_DEFAULTS_ID);
cmisDocumentType.setDisplayName("Document Type With default values");
cmisDocumentType.setDescription("InMemory test type definition " + TEST_DOC_TYPE_WITH_DEFAULTS_ID);
PropertyStringDefinitionImpl prop = PropertyCreationHelper.createStringMultiDefinition(
TEST_DOCUMENT_MY_MULTI_STRING_PROP_ID, "Test Multi String Property", Updatability.READWRITE);
prop.setIsRequired(false);
- List<String> defValS = new ArrayList<String>() {{ add("Apache"); add("CMIS"); }};
+ List<String> defValS = new ArrayList<String>() {
+ {
+ add("Apache");
+ add("CMIS");
+ }
+ };
prop.setDefaultValue(defValS);
cmisDocumentType.addPropertyDefinition(prop);
PropertyIntegerDefinitionImpl prop2 = PropertyCreationHelper.createIntegerDefinition(
TEST_DOCUMENT_MY_INT_PROP_ID, "Test Integer Property", Updatability.READWRITE);
prop2.setIsRequired(false);
- List<BigInteger> defVal = new ArrayList<BigInteger>() {{ add(BigInteger.valueOf(100)); }};
+ List<BigInteger> defVal = new ArrayList<BigInteger>() {
+ {
+ add(BigInteger.valueOf(100));
+ }
+ };
prop2.setDefaultValue(defVal);
cmisDocumentType.addPropertyDefinition(prop2);
PropertyIntegerDefinitionImpl prop3 = PropertyCreationHelper.createIntegerDefinition(
- TEST_DOCUMENT_MY_INT_PROP_ID_MANDATORY_DEFAULT, "Test Integer Property Mandatory default", Updatability.READWRITE);
+ TEST_DOCUMENT_MY_INT_PROP_ID_MANDATORY_DEFAULT, "Test Integer Property Mandatory default",
+ Updatability.READWRITE);
prop3.setIsRequired(true);
- List<BigInteger> defVal2 = new ArrayList<BigInteger>() {{ add(BigInteger.valueOf(100)); }};
+ List<BigInteger> defVal2 = new ArrayList<BigInteger>() {
+ {
+ add(BigInteger.valueOf(100));
+ }
+ };
prop3.setDefaultValue(defVal2);
cmisDocumentType.addPropertyDefinition(prop3);
return cmisDocumentType;
}
- private static TypeDefinition createCustomTypeNoContent() throws InstantiationException, IllegalAccessException {
- MutableDocumentTypeDefinition cmisDocumentType;
- cmisDocumentType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), TEST_CUSTOM_NO_CONTENT_TYPE_ID);
+ private static TypeDefinition createCustomTypeNoContent() throws InstantiationException, IllegalAccessException {
+ MutableDocumentTypeDefinition cmisDocumentType;
+ cmisDocumentType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(
+ DocumentTypeCreationHelper.getCmisDocumentType(), TEST_CUSTOM_NO_CONTENT_TYPE_ID);
cmisDocumentType.setDisplayName("No Content Document Type");
cmisDocumentType.setDescription("InMemory test type definition " + TEST_CUSTOM_NO_CONTENT_TYPE_ID);
cmisDocumentType.setContentStreamAllowed(ContentStreamAllowed.NOTALLOWED);
return cmisDocumentType;
}
-
- private static TypeDefinition createCustomTypeMustHaveContent() throws InstantiationException, IllegalAccessException {
- MutableDocumentTypeDefinition cmisDocumentType;
- cmisDocumentType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), TEST_CUSTOM_MUST_CONTENT_TYPE_ID);
+
+ private static TypeDefinition createCustomTypeMustHaveContent() throws InstantiationException,
+ IllegalAccessException {
+ MutableDocumentTypeDefinition cmisDocumentType;
+ cmisDocumentType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(
+ DocumentTypeCreationHelper.getCmisDocumentType(), TEST_CUSTOM_MUST_CONTENT_TYPE_ID);
cmisDocumentType.setDisplayName("Must Have Content Document Type");
cmisDocumentType.setDescription("InMemory test type definition " + TEST_CUSTOM_MUST_CONTENT_TYPE_ID);
cmisDocumentType.setContentStreamAllowed(ContentStreamAllowed.NOTALLOWED);
cmisDocumentType.setContentStreamAllowed(ContentStreamAllowed.REQUIRED);
return cmisDocumentType;
}
-
- private static TypeDefinition createFolderTypeWithDefault() throws InstantiationException, IllegalAccessException {
- MutableFolderTypeDefinition cmisFolderType;
- cmisFolderType = typeFactory.createFolderTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisFolderType().getId());
+
+ private static TypeDefinition createFolderTypeWithDefault() throws InstantiationException,
+ IllegalAccessException {
+ MutableFolderTypeDefinition cmisFolderType;
+ cmisFolderType = typeFactory.createFolderTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper
+ .getCmisFolderType().getId());
cmisFolderType.setId(TEST_FOLDER_TYPE_WITH_DEFAULTS_ID);
cmisFolderType.setDisplayName("Folder Type With default values");
cmisFolderType.setDescription("InMemory test type definition " + TEST_FOLDER_TYPE_WITH_DEFAULTS_ID);
@@ -1849,30 +1895,45 @@ public class ObjectServiceTest extends A
PropertyStringDefinitionImpl prop = PropertyCreationHelper.createStringMultiDefinition(
TEST_FOLDER_MY_MULTI_STRING_PROP_ID, "Test Multi String Property", Updatability.READWRITE);
prop.setIsRequired(false);
- List<String> defValS = new ArrayList<String>() {{ add("Apache"); add("CMIS"); }};
+ List<String> defValS = new ArrayList<String>() {
+ {
+ add("Apache");
+ add("CMIS");
+ }
+ };
prop.setDefaultValue(defValS);
cmisFolderType.addPropertyDefinition(prop);
PropertyIntegerDefinitionImpl prop2 = PropertyCreationHelper.createIntegerDefinition(
TEST_FOLDER_MY_INT_PROP_ID, "Test Integer Property", Updatability.READWRITE);
prop2.setIsRequired(false);
- List<BigInteger> defVal = new ArrayList<BigInteger>() {{ add(BigInteger.valueOf(100)); }};
+ List<BigInteger> defVal = new ArrayList<BigInteger>() {
+ {
+ add(BigInteger.valueOf(100));
+ }
+ };
prop2.setDefaultValue(defVal);
cmisFolderType.addPropertyDefinition(prop2);
PropertyIntegerDefinitionImpl prop3 = PropertyCreationHelper.createIntegerDefinition(
- TEST_FOLDER_MY_INT_PROP_ID_MANDATORY_DEFAULT, "Test Integer Property Mandatory default", Updatability.READWRITE);
+ TEST_FOLDER_MY_INT_PROP_ID_MANDATORY_DEFAULT, "Test Integer Property Mandatory default",
+ Updatability.READWRITE);
prop3.setIsRequired(true);
- List<BigInteger> defVal2 = new ArrayList<BigInteger>() {{ add(BigInteger.valueOf(100)); }};
+ List<BigInteger> defVal2 = new ArrayList<BigInteger>() {
+ {
+ add(BigInteger.valueOf(100));
+ }
+ };
prop3.setDefaultValue(defVal2);
cmisFolderType.addPropertyDefinition(prop3);
return cmisFolderType;
}
-
- private TypeDefinition createRelationshipType() throws InstantiationException, IllegalAccessException {
- MutableRelationshipTypeDefinition cmisRelType;
- cmisRelType = typeFactory.createRelationshipTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisRelationshipType().getId());
+
+ private TypeDefinition createRelationshipType() throws InstantiationException, IllegalAccessException {
+ MutableRelationshipTypeDefinition cmisRelType;
+ cmisRelType = typeFactory.createRelationshipTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper
+ .getCmisRelationshipType().getId());
cmisRelType.setId(TEST_RELATION_TYPE_ID);
cmisRelType.setDisplayName("MyRelationshipType");
cmisRelType.setDescription("InMemory test type definition " + TEST_RELATION_TYPE_ID);
@@ -1884,13 +1945,14 @@ public class ObjectServiceTest extends A
PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(REL_STRING_PROP,
"CrossReferenceType", Updatability.READWRITE);
cmisRelType.addPropertyDefinition(prop1);
-
- return cmisRelType;
+
+ return cmisRelType;
}
- private TypeDefinition createRelationshipTypeRestricted() throws InstantiationException, IllegalAccessException {
- MutableRelationshipTypeDefinition cmisRelType;
- cmisRelType = typeFactory.createRelationshipTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisRelationshipType().getId());
+ private TypeDefinition createRelationshipTypeRestricted() throws InstantiationException, IllegalAccessException {
+ MutableRelationshipTypeDefinition cmisRelType;
+ cmisRelType = typeFactory.createRelationshipTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper
+ .getCmisRelationshipType().getId());
cmisRelType.setId(TEST_RESTRICTED_RELATION_TYPE_ID);
cmisRelType.setDisplayName("RestrictedRelationshipType");
cmisRelType.setDescription("InMemory test type definition " + TEST_RESTRICTED_RELATION_TYPE_ID);
@@ -1900,30 +1962,33 @@ public class ObjectServiceTest extends A
List<String> allowedTypeIds = Collections.singletonList(TEST_CUSTOM_DOCUMENT_TYPE_ID);
cmisRelType.setAllowedSourceTypes(allowedTypeIds);
cmisRelType.setAllowedTargetTypes(allowedTypeIds);
- return cmisRelType;
+ return cmisRelType;
+ }
+
+ private static TypeDefinition createItemType() throws InstantiationException, IllegalAccessException {
+ // CMIS 1.1 create an item item type
+ MutableItemTypeDefinition cmisItemType;
+ cmisItemType = typeFactory.createItemTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper
+ .getCmisItemType().getId()); // ???
+ // DocumentTypeCreationHelper.getCmisItemType());
+ cmisItemType.setId(TEST_ITEM_TYPE_ID);
+ cmisItemType.setDisplayName("MyItemType");
+ cmisItemType.setDescription("Builtin InMemory type definition " + TEST_ITEM_TYPE_ID);
+ DocumentTypeCreationHelper.setDefaultTypeCapabilities(cmisItemType);
+
+ // create a single String property definition
+ PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(ITEM_STRING_PROP,
+ "Item String Property", Updatability.READWRITE);
+ cmisItemType.addPropertyDefinition(prop1);
+ // add type to types collection
+ return cmisItemType;
}
- private static TypeDefinition createItemType() throws InstantiationException, IllegalAccessException {
- //CMIS 1.1 create an item item type
- MutableItemTypeDefinition cmisItemType;
- cmisItemType = typeFactory.createItemTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisItemType().getId()); // ??? DocumentTypeCreationHelper.getCmisItemType());
- cmisItemType.setId(TEST_ITEM_TYPE_ID);
- cmisItemType.setDisplayName("MyItemType");
- cmisItemType.setDescription("Builtin InMemory type definition " + TEST_ITEM_TYPE_ID);
- DocumentTypeCreationHelper.setDefaultTypeCapabilities(cmisItemType);
-
- // create a single String property definition
- PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(ITEM_STRING_PROP,
- "Item String Property", Updatability.READWRITE);
- cmisItemType.addPropertyDefinition(prop1);
- // add type to types collection
- return cmisItemType;
- }
-
- private static TypeDefinition createSecondaryType() throws InstantiationException, IllegalAccessException {
- //CMIS 1.1 create an item item type
- MutableSecondaryTypeDefinition cmisSecondaryType;
- cmisSecondaryType = typeFactory.createSecondaryTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisSecondaryType().getId());
+ private static TypeDefinition createSecondaryType() throws InstantiationException, IllegalAccessException {
+ // CMIS 1.1 create an item item type
+ MutableSecondaryTypeDefinition cmisSecondaryType;
+ cmisSecondaryType = typeFactory.createSecondaryTypeDefinition(CmisVersion.CMIS_1_1,
+ DocumentTypeCreationHelper.getCmisSecondaryType().getId());
cmisSecondaryType.setId(TEST_SECONDARY_TYPE_ID);
cmisSecondaryType.setDisplayName("MySecondaryType");
cmisSecondaryType.setDescription("InMemory test type definition " + TEST_SECONDARY_TYPE_ID);
@@ -1936,18 +2001,19 @@ public class ObjectServiceTest extends A
"Secondary String Property", Updatability.READWRITE);
cmisSecondaryType.addPropertyDefinition(prop1);
- PropertyIntegerDefinitionImpl prop2 = PropertyCreationHelper.createIntegerDefinition(SECONDARY_INTEGER_PROP,
- "Secondary Integer Property", Updatability.READWRITE);
+ PropertyIntegerDefinitionImpl prop2 = PropertyCreationHelper.createIntegerDefinition(
+ SECONDARY_INTEGER_PROP, "Secondary Integer Property", Updatability.READWRITE);
prop2.setIsRequired(true);
cmisSecondaryType.addPropertyDefinition(prop2);
-
- return cmisSecondaryType;
+
+ return cmisSecondaryType;
}
-
- private static TypeDefinition createVersionableType() throws InstantiationException, IllegalAccessException {
+
+ private static TypeDefinition createVersionableType() throws InstantiationException, IllegalAccessException {
// create a complex type with properties
- MutableDocumentTypeDefinition verType;
- verType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), TEST_VERSION_DOCUMENT_TYPE_ID);
+ MutableDocumentTypeDefinition verType;
+ verType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(
+ DocumentTypeCreationHelper.getCmisDocumentType(), TEST_VERSION_DOCUMENT_TYPE_ID);
verType.setDisplayName("VersionedType");
verType.setDescription("InMemory test type definition " + TEST_VERSION_DOCUMENT_TYPE_ID);
@@ -1959,21 +2025,22 @@ public class ObjectServiceTest extends A
verType.addPropertyDefinition(prop1);
return verType;
}
-
- private static TypeDefinition createPolicyType() throws InstantiationException, IllegalAccessException {
- MutablePolicyTypeDefinition polType;
- polType = typeFactory.createPolicyTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisPolicyType().getId());
+
+ private static TypeDefinition createPolicyType() throws InstantiationException, IllegalAccessException {
+ MutablePolicyTypeDefinition polType;
+ polType = typeFactory.createPolicyTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper
+ .getCmisPolicyType().getId());
polType.setId(TEST_POLICY_TYPE_ID);
polType.setDisplayName("Audit Policy");
polType.setDescription("InMemory type definition " + TEST_POLICY_TYPE_ID);
DocumentTypeCreationHelper.setDefaultTypeCapabilities(polType);
polType.setIsFileable(false);
-
+
// create a String property definition
PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(TEST_POLICY_PROPERTY_ID,
"Audit Kind Property", Updatability.READWRITE);
polType.addPropertyDefinition(prop1);
- return polType;
+ return polType;
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/PolicyTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/PolicyTest.java?rev=1516753&r1=1516752&r2=1516753&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/PolicyTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/PolicyTest.java Fri Aug 23 08:53:49 2013
@@ -56,7 +56,7 @@ public class PolicyTest extends Abstract
private String polId;
@Override
- @Before
+ @Before
public void setUp() {
super.setTypeCreatorClass(ObjectTestTypeSystemCreator.class.getName());
super.setUp();
@@ -64,7 +64,7 @@ public class PolicyTest extends Abstract
}
@Override
- @After
+ @After
public void tearDown() {
super.tearDown();
}
@@ -229,7 +229,7 @@ public class PolicyTest extends Abstract
} catch (Exception e) {
fail("Removing a non-existing policy should raise a CmisObjectNotFoundException, but was a " + e);
}
-
+
// try removing a non existing id
try {
fPolSvc.removePolicy(fRepositoryId, polId2, docId, null);
@@ -238,7 +238,7 @@ public class PolicyTest extends Abstract
} catch (Exception e) {
fail("Removing a non-existing policy should raise a CmisInvalidArgumentException, but was a " + e);
}
-
+
// try removing a non policy id
try {
fPolSvc.removePolicy(fRepositoryId, docId2, docId, null);
@@ -247,7 +247,7 @@ public class PolicyTest extends Abstract
} catch (Exception e) {
fail("Removing a non-policy should raise a CmisInvalidArgumentException, but was a " + e);
}
-
+
}
private void createPolicy() {
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RelationshipServiceTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RelationshipServiceTest.java?rev=1516753&r1=1516752&r2=1516753&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RelationshipServiceTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RelationshipServiceTest.java Fri Aug 23 08:53:49 2013
@@ -548,10 +548,10 @@ public class RelationshipServiceTest ext
targetId, null);
String statement = "SELECT * from cmis:document WHERE cmis:name = '" + MY_DOC_1 + "'";
- ObjectList res = fDiscSvc.query(fRepositoryId, statement, false, false, IncludeRelationships.SOURCE, null, null,
- null, null);
+ ObjectList res = fDiscSvc.query(fRepositoryId, statement, false, false, IncludeRelationships.SOURCE, null,
+ null, null, null);
assertEquals(1, res.getNumItems().intValue());
-
+
List<ObjectData> rels = res.getObjects().get(0).getRelationships();
assertEquals(1, rels.size());
ArrayList<String> ids = new ArrayList<String>(Collections.singletonList(id1));
@@ -571,10 +571,12 @@ public class RelationshipServiceTest ext
ObjectList res = fDiscSvc.query(fRepositoryId, statement, false, false, IncludeRelationships.NONE, null, null,
null, null);
assertEquals(2, res.getNumItems().intValue());
- ArrayList<String> ids = new ArrayList<String>() {{
- add(id1);
- add(id2);
- }};
+ ArrayList<String> ids = new ArrayList<String>() {
+ {
+ add(id1);
+ add(id2);
+ }
+ };
for (ObjectData od : res.getObjects()) {
ids.remove(od.getId());
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceMutabilityTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceMutabilityTest.java?rev=1516753&r1=1516752&r2=1516753&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceMutabilityTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceMutabilityTest.java Fri Aug 23 08:53:49 2013
@@ -53,9 +53,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Temporary test class until CMIS 1.1 bindings are completed. Until then
- * we use a special setup procedure to directly connect to the repository
- * service implementation of InMemory.
+ * Temporary test class until CMIS 1.1 bindings are completed. Until then we use
+ * a special setup procedure to directly connect to the repository service
+ * implementation of InMemory.
*
* @author Jens
*/
@@ -72,13 +72,13 @@ public class RepositoryServiceMutability
public void setUp() {
super.setTypeCreatorClass(UnitTestTypeSystemCreator.class.getName());
super.setUp();
-
+
Map<String, String> parameters = new HashMap<String, String>();
// attach repository info to the session:
parameters.put(ConfigConstants.TYPE_CREATOR_CLASS, getTypeCreatorClass());
parameters.put(ConfigConstants.REPOSITORY_ID, REPOSITORY_ID);
-
+
InMemoryServiceFactoryImpl factory = new InMemoryServiceFactoryImpl();
factory.init(parameters);
}
@@ -89,9 +89,11 @@ public class RepositoryServiceMutability
super.tearDown();
}
- // This test is just added because this test class uses a different setup to connect to the
- // server as long as the server bindings do not support the type mutability extension of
- // CMIS 1.1. If this test fails then the setUp() fails!
+ // This test is just added because this test class uses a different setup to
+ // connect to the
+ // server as long as the server bindings do not support the type mutability
+ // extension of
+ // CMIS 1.1. If this test fails then the setUp() fails!
@Test
public void testRepositoryInfo() {
log.info("starting testRepositoryInfo() ...");
@@ -110,7 +112,6 @@ public class RepositoryServiceMutability
log.info("... testRepositoryInfo() finished.");
}
-
@Test
public void testTypeMutabilityCreation() throws Exception {
@@ -129,7 +130,7 @@ public class RepositoryServiceMutability
RepositoryServiceTest.containsAllBasePropertyDefinitions(type);
log.info("... testTypeMutabilityCreation() finished.");
}
-
+
@Test
public void testTypeMutabilityCreateDuplicate() throws Exception {
log.info("");
@@ -145,20 +146,19 @@ public class RepositoryServiceMutability
assertEquals(typeDefRef.getId(), type.getId());
log.info("... testTypeMutabilityCreateDuplicate() finished.");
}
-
-
+
@Test
public void testTypeMutabilityTypeNameConstraints() throws Exception {
log.info("starting testTypeMutabilityTypeNameConstraints() ...");
-
+
String repositoryId = getRepositoryId();
-
+
// test illegal type id
MutableDocumentTypeDefinition typeDefRef = createTypeForAddingAtRuntime();
typeDefRef.setId(typeDefRef.getId() + "!!!");
TypeDefinition typeDefNew = fRepSvc.createType(repositoryId, typeDefRef, null);
assertEquals(TYPE_ID_MUTABILITY + "___", typeDefNew.getId());
- fRepSvc.deleteType(repositoryId, TYPE_ID_MUTABILITY+"___", null);
+ fRepSvc.deleteType(repositoryId, TYPE_ID_MUTABILITY + "___", null);
// test illegal parent type id
typeDefRef = createTypeForAddingAtRuntime();
@@ -171,7 +171,7 @@ public class RepositoryServiceMutability
typeDefNew = fRepSvc.createType(repositoryId, typeDefRef, null);
assertTrue(null != typeDefNew.getId() && typeDefNew.getId().length() > 0);
fRepSvc.deleteType(repositoryId, typeDefNew.getId(), null);
-
+
// test null query name
typeDefRef = createTypeForAddingAtRuntime();
typeDefRef.setQueryName(null);
@@ -200,21 +200,21 @@ public class RepositoryServiceMutability
typeDefNew = fRepSvc.createType(repositoryId, typeDefRef, null);
fRepSvc.deleteType(repositoryId, TYPE_ID_MUTABILITY, null);
- log.info("... testTypeMutabilityTypeNameConstraints() finished.");
+ log.info("... testTypeMutabilityTypeNameConstraints() finished.");
}
-
+
@Test
public void testTypeMutabilityPropertyNameConstraints() throws Exception {
log.info("starting testTypeMutabilityPropertyNameConstraints() ...");
-
+
String repositoryId = getRepositoryId();
-
+
// test null property id
DocumentTypeDefinition typeDef = createTypeForAddingAtRuntime();
PropertyStringDefinitionImpl pd = getPropertyDefinitionImpl(typeDef);
pd.setId(null);
checkAddingType(repositoryId, typeDef, CmisInvalidArgumentException.class);
-
+
// test illegal property id
typeDef = createTypeForAddingAtRuntime();
pd = getPropertyDefinitionImpl(typeDef);
@@ -245,19 +245,19 @@ public class RepositoryServiceMutability
pd.setLocalName(typeDef.getLocalName() + "!!!");
checkAddingType(repositoryId, typeDef, CmisInvalidArgumentException.class);
- log.info("... testTypeMutabilityPropertyNameConstraints() finished.");
+ log.info("... testTypeMutabilityPropertyNameConstraints() finished.");
}
-
+
private void checkAddingType(String repositoryId, TypeDefinition typeDef, Class<? extends Exception> clazz) {
- try {
+ try {
typeDef = fRepSvc.createType(repositoryId, typeDef, null);
fail("Illegal type should throw a " + clazz.getName());
} catch (RuntimeException e) {
assertTrue("Illegal type name threw wrong exception type (should be a " + clazz.getName() + ")",
clazz.isInstance(e));
- }
+ }
}
-
+
@Test
public void testTypeMutabilityUpdate() throws Exception {
log.info("");
@@ -270,11 +270,11 @@ public class RepositoryServiceMutability
fRepSvc.updateType(repositoryId, typeDefRef, null);
fail("updating a type should throw exception.");
} catch (Exception e) {
- assert(e instanceof CmisNotSupportedException);
+ assert (e instanceof CmisNotSupportedException);
}
log.info("... testTypeMutabilityUpdate() finished.");
}
-
+
@Test
public void testTypeMutabilityDeletion() throws Exception {
log.info("");
@@ -282,25 +282,25 @@ public class RepositoryServiceMutability
TypeDefinition typeDefRef = createTypeForAddingAtRuntime();
String repositoryId = getRepositoryId();
fRepSvc.createType(repositoryId, typeDefRef, null);
-
+
String docId = createDoc("Book1", getRootFolderId(REPOSITORY_ID), TYPE_ID_MUTABILITY);
-
+
// try deleting type, should fail, because in use.
try {
fRepSvc.deleteType(repositoryId, TYPE_ID_MUTABILITY, null);
fail("deleting a type which is in use should throw exception.");
} catch (Exception e) {
- assert(e instanceof CmisInvalidArgumentException);
+ assert (e instanceof CmisInvalidArgumentException);
}
fObjSvc.deleteObject(fRepositoryId, docId, true, null);
-
+
try {
fRepSvc.deleteType(repositoryId, TYPE_ID_MUTABILITY, null);
} catch (Exception e) {
fail("deleting a type which is in not in use should not throw exception! Exception is: " + e);
}
-
+
try {
fRepSvc.getTypeDefinition(repositoryId, TYPE_ID_MUTABILITY, null);
fail("getting a type after it was deleted should fail.");
@@ -311,13 +311,13 @@ public class RepositoryServiceMutability
fRepSvc.deleteType(repositoryId, BaseTypeId.CMIS_DOCUMENT.name(), null);
fail("deleting a CMIS base type throw exception.");
} catch (Exception e) {
- assert(e instanceof CmisInvalidArgumentException);
+ assert (e instanceof CmisInvalidArgumentException);
}
try {
fRepSvc.deleteType(repositoryId, BaseTypeId.CMIS_FOLDER.name(), null);
fail("deleting a CMIS base type throw exception.");
} catch (Exception e) {
- assert(e instanceof CmisInvalidArgumentException);
+ assert (e instanceof CmisInvalidArgumentException);
}
log.info("... testTypeMutabilityDeletion() finished.");
@@ -337,19 +337,20 @@ public class RepositoryServiceMutability
}
private PropertyStringDefinitionImpl getPropertyDefinitionImpl(TypeDefinition typeDef) {
- PropertyStringDefinitionImpl pd = (PropertyStringDefinitionImpl) typeDef.getPropertyDefinitions().get(PROPERTY_ID_TITLE);
+ PropertyStringDefinitionImpl pd = (PropertyStringDefinitionImpl) typeDef.getPropertyDefinitions().get(
+ PROPERTY_ID_TITLE);
return pd;
}
-
+
private MutableDocumentTypeDefinition createTypeForAddingAtRuntime() {
try {
MutableDocumentTypeDefinition cmisLaterType;
- cmisLaterType = DocumentTypeCreationHelper.createDocumentTypeDefinitionWithoutBaseProperties(DocumentTypeCreationHelper.getCmisDocumentType());
+ cmisLaterType = DocumentTypeCreationHelper
+ .createDocumentTypeDefinitionWithoutBaseProperties(DocumentTypeCreationHelper.getCmisDocumentType());
cmisLaterType.setId(TYPE_ID_MUTABILITY);
cmisLaterType.setDisplayName("Type with two properties");
cmisLaterType.setDescription("Builtin InMemory type definition " + TYPE_ID_MUTABILITY);
-
PropertyIntegerDefinitionImpl prop1 = PropertyCreationHelper.createIntegerDefinition(PROPERTY_ID_NUMBER,
"Sample Int Property", Updatability.READWRITE);
cmisLaterType.addPropertyDefinition(prop1);
@@ -364,7 +365,6 @@ public class RepositoryServiceMutability
}
}
-
String createDoc(String name, String folderId, String typeId) {
ContentStream contentStream = null;
List<String> policies = null;
@@ -372,8 +372,8 @@ public class RepositoryServiceMutability
Properties props = createDocumentProperties(name, typeId);
- String id = fObjSvc.createDocument(fRepositoryId, props, folderId, contentStream,
- VersioningState.NONE, policies, null, null, extension);
- return id;
+ String id = fObjSvc.createDocument(fRepositoryId, props, folderId, contentStream, VersioningState.NONE,
+ policies, null, null, extension);
+ return id;
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java?rev=1516753&r1=1516752&r2=1516753&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java Fri Aug 23 08:53:49 2013
@@ -146,10 +146,12 @@ public class RepositoryServiceTest exten
String repositoryId = getRepositoryId();
// get types
- List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(repositoryId, BaseTypeId.CMIS_DOCUMENT.value(), BigInteger.valueOf(-1),
- Boolean.FALSE, null);
-// List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(repositoryId, "MyDocType1", BigInteger.valueOf(-1),
-// Boolean.FALSE, null);
+ List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(repositoryId,
+ BaseTypeId.CMIS_DOCUMENT.value(), BigInteger.valueOf(-1), Boolean.FALSE, null);
+ // List<TypeDefinitionContainer> types =
+ // fRepSvc.getTypeDescendants(repositoryId, "MyDocType1",
+ // BigInteger.valueOf(-1),
+ // Boolean.FALSE, null);
assertNotNull(types);
int totalSize = getRecursiveSize(types);
@@ -223,8 +225,8 @@ public class RepositoryServiceTest exten
// get types
int depth = 2;
String typeId = "MyDocType1";
- List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(repositoryId, typeId, BigInteger
- .valueOf(depth), Boolean.TRUE, null);
+ List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(repositoryId, typeId,
+ BigInteger.valueOf(depth), Boolean.TRUE, null);
assertNotNull(types);
log.info("Found in repository " + repositoryId + " for type " + typeId + ", " + types.size()
+ " type(s) with depth " + depth + ".");
@@ -326,8 +328,8 @@ public class RepositoryServiceTest exten
}
try {
- List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(repositoryId, "CMISDocument", BigInteger
- .valueOf(0), Boolean.TRUE, null);
+ List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(repositoryId, "CMISDocument",
+ BigInteger.valueOf(0), Boolean.TRUE, null);
log.debug("getTypeDescendants(): " + types);
fail("getTypeDescendants() with depth 0 should throw InvalidArgumentException.");
} catch (CmisInvalidArgumentException e) {
@@ -335,8 +337,8 @@ public class RepositoryServiceTest exten
}
try {
- List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(repositoryId, wrongTypeId, BigInteger
- .valueOf(depth), Boolean.TRUE, null);
+ List<TypeDefinitionContainer> types = fRepSvc.getTypeDescendants(repositoryId, wrongTypeId,
+ BigInteger.valueOf(depth), Boolean.TRUE, null);
log.debug("getTypeDescendants(): " + types);
fail("getTypeDescendants() with unknown type should throw exception.");
} catch (CmisInvalidArgumentException e) {
@@ -369,8 +371,8 @@ public class RepositoryServiceTest exten
}
try {
- TypeDefinitionList types = fRepSvc.getTypeChildren(repositoryId, wrongTypeId, Boolean.TRUE, BigInteger
- .valueOf(100), BigInteger.ZERO, null);
+ TypeDefinitionList types = fRepSvc.getTypeChildren(repositoryId, wrongTypeId, Boolean.TRUE,
+ BigInteger.valueOf(100), BigInteger.ZERO, null);
log.debug("getTypeChildren(): " + types);
fail("getTypeDescendants() with unknown type should throw exception.");
} catch (CmisInvalidArgumentException e) {
@@ -426,7 +428,6 @@ public class RepositoryServiceTest exten
log.info("... testInheritedProperties() finished.");
}
-
private String getRepositoryId() {
List<RepositoryInfo> repositories = fRepSvc.getRepositoryInfos(null);
RepositoryInfo repository = repositories.get(0);
@@ -519,7 +520,7 @@ public class RepositoryServiceTest exten
private List<TypeDefinition> getTypeDefsFlattened(List<TypeDefinitionContainer> types) {
List<TypeDefinition> flattened = new ArrayList<TypeDefinition>();
-
+
for (TypeDefinitionContainer type : types) {
flattened.add(type.getTypeDefinition());
if (null != type.getChildren()) {
@@ -530,5 +531,5 @@ public class RepositoryServiceTest exten
return flattened;
}
-
+
}