Author: gabriele
Date: Wed Mar 31 10:18:29 2010
New Revision: 929460
URL: http://svn.apache.org/viewvc?rev=929460&view=rev
Log:
added property string definition specific test and added missing
decimal property definition getter
Modified:
incubator/chemistry/trunk/chemistry/chemistry-abdera/src/main/
java/org/apache/chemistry/abdera/ext/CMISConstants.java
incubator/chemistry/trunk/chemistry/chemistry-abdera/src/main/
java/org/apache/chemistry/abdera/ext/CMISPropertyDefinition.java
incubator/chemistry/trunk/chemistry/chemistry-abdera/src/test/
java/org/apache/chemistry/abdera/ext/test/TestAppModel.java
Modified: incubator/chemistry/trunk/chemistry/chemistry-abdera/src/
main/java/org/apache/chemistry/abdera/ext/CMISConstants.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-abdera/src/main/java/org/apache/chemistry/abdera/ext/CMISConstants.java?rev=929460&r1=929459&r2=929460&view=diff
=
=
=
=
=
=
=
=
=
=====================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-abdera/src/main/
java/org/apache/chemistry/abdera/ext/CMISConstants.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-abdera/src/main/
java/org/apache/chemistry/abdera/ext/CMISConstants.java Wed Mar 31
10:18:29 2010
@@ -185,10 +185,13 @@ public interface CMISConstants {
// Integer specific defs
public static final QName PROPDEF_INT_MIN_VALUE = new
QName(CMIS_NS, "minValue");
public static final QName PROPDEF_INT_MAX_VALUE = new
QName(CMIS_NS, "maxValue");
+ // Integer specific defs
+ public static final QName PROPDEF_DECIMAL_PRECISION = new
QName(CMIS_NS, "precision");
+
// Date specific defs
public static final QName PROPDEF_DATE_RESOLUTION = new
QName(CMIS_NS, "resolution");
// String specific defs
- public static final QName PROPDEF_STRING_RESOLUTION = new
QName(CMIS_NS, "maxLength");
+ public static final QName PROPDEF_STRING_MAX_LENGTH = new
QName(CMIS_NS, "maxLength");
// CMIS Number of Items
public static final QName NUM_ITEMS = new QName(CMISRA_NS,
"numItems");
Modified: incubator/chemistry/trunk/chemistry/chemistry-abdera/src/
main/java/org/apache/chemistry/abdera/ext/CMISPropertyDefinition.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-abdera/src/main/java/org/apache/chemistry/abdera/ext/CMISPropertyDefinition.java?rev=929460&r1=929459&r2=929460&view=diff
=
=
=
=
=
=
=
=
=
=====================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-abdera/src/main/
java/org/apache/chemistry/abdera/ext/CMISPropertyDefinition.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-abdera/src/main/
java/org/apache/chemistry/abdera/ext/CMISPropertyDefinition.java
Wed Mar 31 10:18:29 2010
@@ -279,8 +279,8 @@ public abstract class CMISPropertyDefini
*
* @return resolution AKA max length
*/
- public Integer getResolution() {
- Element child =
getFirstChild(CMISConstants.PROPDEF_STRING_RESOLUTION);
+ public Integer getMaxLength() {
+ Element child =
getFirstChild(CMISConstants.PROPDEF_STRING_MAX_LENGTH);
if (child != null) {
return Integer.parseInt(child.getText());
}
@@ -327,6 +327,18 @@ public abstract class CMISPropertyDefini
return null;
}
+ /**
+ * Gets the property's precision
+ *
+ * @return max value
+ */
+ public String getPrecision() {
+ Element child =
getFirstChild(CMISConstants.PROPDEF_DECIMAL_PRECISION);
+ if (child != null) {
+ return child.getText();
+ }
+ return null;
+ }
}
/**
Modified: incubator/chemistry/trunk/chemistry/chemistry-abdera/src/
test/java/org/apache/chemistry/abdera/ext/test/TestAppModel.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-abdera/src/test/java/org/apache/chemistry/abdera/ext/test/TestAppModel.java?rev=929460&r1=929459&r2=929460&view=diff
=
=
=
=
=
=
=
=
=
=====================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-abdera/src/test/
java/org/apache/chemistry/abdera/ext/test/TestAppModel.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-abdera/src/test/
java/org/apache/chemistry/abdera/ext/test/TestAppModel.java Wed Mar
31 10:18:29 2010
@@ -65,7 +65,7 @@ public class TestAppModel extends TestCa
* Tests constants for the type definition entry parsing
*/
public void testTypeDefinitionConstants() {
- CMISTypeDefinition type = loadCustomTypeDefinition();
+ CMISTypeDefinition type = loadTypeDefinition("/org/apache/
chemistry/abdera/ext/test/D_mycm_doc-type-definition-entry.xml");
assertNotNull(type);
assertTrue(type.getCreatable());
assertTrue(type.getFileable());
@@ -90,7 +90,7 @@ public class TestAppModel extends TestCa
* Tests constants for the property definition entry parsing
*/
public void testPropertyDefinitionConstants() {
- CMISTypeDefinition type = loadCustomTypeDefinition();
+ CMISTypeDefinition type = loadTypeDefinition("/org/apache/
chemistry/abdera/ext/test/D_mycm_doc-type-definition-entry.xml");
assertNotNull(type);
CMISPropertyDefinition property =
type.getPropertyDefinition("mycm:privacy");
assertNotNull(property);
@@ -111,12 +111,26 @@ public class TestAppModel extends TestCa
assertEquals("readwrite", property.getUpdatability());
assertEquals(CMISConstants.PROP_TYPE_STRING,
property.getPropertyType());
}
-
+
+ /**
+ * Tests string property definition specific constants and
behavior
+ */
+ public void testPropertyStringDefinition() {
+ CMISTypeDefinition type = loadTypeDefinition("/org/apache/
chemistry/abdera/ext/test/D_mycm_doc-type-definition-string-max-
length-entry.xml");
+ assertNotNull(type);
+ CMISPropertyDefinition property =
type.getPropertyDefinition("mycm:limited");
+ assertNotNull(property);
+ assertEquals("Limited info", property.getDisplayName());
+ assertTrue(property instanceof
CMISPropertyStringDefinition);
+ assertNotNull(((CMISPropertyStringDefinition)
property).getMaxLength());
+ assertEquals(new Integer(128),
((CMISPropertyStringDefinition) property).getMaxLength());
+ }
+
/**
* Tests property definition choices parsing with no nested
choices
*/
public void testGetChoices() {
- CMISTypeDefinition typeDefinition =
loadCustomTypeDefinition();
+ CMISTypeDefinition typeDefinition = loadTypeDefinition("/
org/apache/chemistry/abdera/ext/test/D_mycm_doc-type-definition-
entry.xml");
assertNotNull(typeDefinition);
CMISPropertyDefinition propertyDefinition =
typeDefinition.getPropertyDefinition("mycm:privacy");
assertNotNull(propertyDefinition);
@@ -138,7 +152,7 @@ public class TestAppModel extends TestCa
* Tests property definition choices parsing with with nested
choices
*/
public void testGetNestedChoices() {
- CMISTypeDefinition typeDefinition =
loadTypeDefinitionWithNestedChoices();
+ CMISTypeDefinition typeDefinition = loadTypeDefinition("/
org/apache/chemistry/abdera/ext/test/D_mycm_doc-type-definition-
nested-choices-entry.xml");
assertNotNull(typeDefinition);
CMISPropertyDefinition propertyDefinition =
typeDefinition.getPropertyDefinition("mycm:privacy");
assertNotNull(propertyDefinition);
@@ -184,22 +198,15 @@ public class TestAppModel extends TestCa
assertEquals(choices.size(), 13);
}
- private CMISTypeDefinition loadCustomTypeDefinition() {
- String typeDefinitionEntry = null;
- try {
- typeDefinitionEntry = load("/org/apache/chemistry/
abdera/ext/test/D_mycm_doc-type-definition-entry.xml");
- } catch (IOException e) {
- fail("Test atom entry not found");
- }
- Entry entry = model.parseEntry(new
StringReader(typeDefinitionEntry), null);
- CMISTypeDefinition type =
entry.getExtension(CMISConstants.TYPE_DEFINITION);
- return type;
- }
-
- private CMISTypeDefinition
loadTypeDefinitionWithNestedChoices() {
+
+ /*
+ * Utility private methods
+ */
+
+ private CMISTypeDefinition loadTypeDefinition(String
resourcePath) {
String typeDefinitionEntry = null;
try {
- typeDefinitionEntry = load("/org/apache/chemistry/
abdera/ext/test/D_mycm_doc-type-definition-nested-choices-
entry.xml");
+ typeDefinitionEntry = load(resourcePath);
} catch (IOException e) {
fail("Test atom entry not found");
}
@@ -208,6 +215,7 @@ public class TestAppModel extends TestCa
return type;
}
+
/**
* Load text from file specified by class path
*