incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r523838 - in /incubator/graffito/trunk/jcr/jcr-mapping/src: dtd/ java/org/apache/portals/graffito/jcr/mapper/model/ java/org/apache/portals/graffito/jcr/persistence/ java/org/apache/portals/graffito/jcr/persistence/impl/ java/org/apache/por...
Date Thu, 29 Mar 2007 20:58:05 GMT
Author: clombart
Date: Thu Mar 29 13:58:03 2007
New Revision: 523838

URL: http://svn.apache.org/viewvc?view=rev&rev=523838
Log:
working on GRFT-84. add more unit test

Modified:
    incubator/graffito/trunk/jcr/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/SimpleFieldsHelper.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-jcrnodetypes.xml
    incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-testdigester.xml
    incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/nodetypes/custom_nodetypes.xml
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/jcrnodetype/PersistenceManagerJcrNodeTypeTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/jcrnodetype/PersistenceManagerJcrPropertyTest.java

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd?view=diff&rev=523838&r1=523837&r2=523838
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd Thu Mar 29 13:58:03
2007
@@ -63,6 +63,8 @@
     * path : specified if the field is the object path
     * uuid : specified if the field is the object uuid
     * converter : AtomicTypeConverter class name to used for this field descriptor. If not
defined, a default one is provided by default in function of the field type
+    * jcrDefaultValue : if the field is null, this default value will be used, optional
+    * jcrValueConstraints : a comma separated list of acceptable values, optional
     * jcrType: specifies the JCR property type (supported jcr property types: STRING, DATE,
LONG, DOUBLE, BOOLEAN), optional
     * jcrAutoCreated: specifies if this JCR property will be autocreated (true/false / default
is false), optional
     * jcrMandatory: specifies if this JCR property is mandatory (true/false / default is
false), optional
@@ -80,6 +82,8 @@
 	path (true | false) "false"
 	uuid (true | false) "false"
 	converter CDATA #IMPLIED
+	jcrDefaultValue CDATA #IMPLIED
+	jcrValueConstraints CDATA #IMPLIED 
     jcrType (String | Date | Long | Double | Boolean | Binary) #IMPLIED
     jcrAutoCreated (true | false) "false"
     jcrMandatory (true | false) "false"

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java?view=diff&rev=523838&r1=523837&r2=523838
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java
Thu Mar 29 13:58:03 2007
@@ -44,6 +44,8 @@
     private boolean path;
     private boolean uuid;
     private String converter;
+    private String jcrDefaultValue; 
+    private String[] jcrValueConstraints = new String[0];
    
 
     /**
@@ -279,8 +281,27 @@
     public void setJcrMultiple(boolean value) {
         this.jcrMultiple = value;
     }
+    
+    public String getJcrDefaultValue() {
+		return jcrDefaultValue;
+	}
 
-    /**
+	public void setJcrDefaultValue(String defaultValue) {
+		this.jcrDefaultValue = defaultValue;
+	}
+
+	public String[] getJcrValueConstraints() {
+		return jcrValueConstraints;
+	}
+
+	public void setJcrValueConstraints(String[] jcrValueConstraints) {
+        if (null != jcrValueConstraints && jcrValueConstraints.length == 1) {
+        	this.jcrValueConstraints = jcrValueConstraints[0].split(" *, *");
+        }
+
+	}
+
+	/**
      * Initialize the fieldTypeClass.
      *
      * @return the primitive class or the class accordign to fieldType

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java?view=diff&rev=523838&r1=523837&r2=523838
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java
Thu Mar 29 13:58:03 2007
@@ -340,5 +340,11 @@
      * @return The query manager reference
      */
     public QueryManager getQueryManager();
+    
+    /**
+     * Refrsh the underlying jcr session (see the jcr spec)
+     * @param keepChanges
+     */
+    public void refresh(boolean keepChanges);
         
 }

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java?view=diff&rev=523838&r1=523837&r2=523838
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java
Thu Mar 29 13:58:03 2007
@@ -106,6 +106,7 @@
                                   Session session) {
         this.mapper = mapper;
         this.session = session;
+        
         this.objectConverter = new ObjectConverterImpl(mapper, new DefaultAtomicTypeConverterProvider());
         this.queryManager = queryManager;
     }
@@ -1068,8 +1069,22 @@
     /**
      * @return The JCR Session
      */
-    public Session getSession() {
-        return this.session;
+    public Session getSession() {       
+    	return this.session;
     }
+
+	public void refresh(boolean keepChanges) {
+		try 
+		{
+		    session.refresh(keepChanges);
+		}
+        catch(RepositoryException e) {
+            throw new PersistenceException("Cannot refresh current session ", e);
+        }
+
+		
+	}
+    
+    
 
 }

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/SimpleFieldsHelper.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/SimpleFieldsHelper.java?view=diff&rev=523838&r1=523837&r2=523838
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/SimpleFieldsHelper.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/SimpleFieldsHelper.java
Thu Mar 29 13:58:03 2007
@@ -196,6 +196,15 @@
 		{ // DO NOT TRY TO WRITE PROTECTED  PROPERTIES
 			
 			Object fieldValue = ReflectionUtils.getNestedProperty(object, fieldName);
+			// if the value and if there is a default value for this field => set this default
value
+			String defaultValue = fieldDescriptor.getJcrDefaultValue();
+			if ((fieldValue == null) && (defaultValue != null))
+			{
+				//Not sure that we have the attribute with the default value in all use cases				
+				ReflectionUtils.setNestedProperty(object, fieldName, defaultValue);
+				fieldValue = ReflectionUtils.getNestedProperty(object, fieldName);
+				
+			}
 			AtomicTypeConverter converter = getAtomicTypeConverter(fieldDescriptor, object, fieldName);
 			Value value = converter.getValue(valueFactory, fieldValue);
 	

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-jcrnodetypes.xml
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-jcrnodetypes.xml?view=diff&rev=523838&r1=523837&r2=523838
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-jcrnodetypes.xml (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-jcrnodetypes.xml Thu
Mar 29 13:58:03 2007
@@ -34,9 +34,14 @@
     <class-descriptor className="org.apache.portals.graffito.jcr.testmodel.PropertyTest"
jcrNodeType="graffito:propertytest" >
 		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="requiredProp" jcrName="graffito:requiredProp" />
-		<field-descriptor fieldName="requiredWithConstraintsProp" jcrName="graffito:requiredWithConstraintsProp"
/>
-		<field-descriptor fieldName="autoCreatedProp" jcrName="graffito:autoCreatedProp" />
+		<field-descriptor fieldName="requiredWithConstraintsProp" jcrName="graffito:requiredWithConstraintsProp"
jcrValueConstraints="abc,def,ghi" />
+		<field-descriptor fieldName="autoCreatedProp" jcrName="graffito:autoCreatedProp" jcrDefaultValue="aaa"
/>
+		<field-descriptor fieldName="autoCreatedWithConstraintsProp" jcrName="graffito:autoCreatedWithConstraintsProp"
jcrDefaultValue="ccc" jcrValueConstraints="bbb,ccc,ddd"/>
+		<field-descriptor fieldName="mandatoryProp" jcrName="graffito:mandatoryProp" jcrMandatory="true"
/>				
+		<field-descriptor fieldName="mandatoryWithConstaintsProp" jcrName="graffito:mandatoryWithConstaintsProp"
jcrMandatory="true" jcrValueConstraints="xx,yy"/>						
+		
 	</class-descriptor>	
+	
 	<!-- class-descriptor className="org.apache.portals.graffito.jcr.testmodel.PropertyTest"
jcrNodeType="graffito:propertytest" >
 		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="requiredProp" jcrName="graffito:requiredProp" />

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-testdigester.xml
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-testdigester.xml?view=diff&rev=523838&r1=523837&r2=523838
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-testdigester.xml (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-testdigester.xml Thu
Mar 29 13:58:03 2007
@@ -98,4 +98,5 @@
 		<field-descriptor fieldName="uuid" uuid="true" />
         <field-descriptor fieldName="stringData" jcrName="stringData" />
 	</class-descriptor>
+	
 </graffito-jcr>

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/nodetypes/custom_nodetypes.xml
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/nodetypes/custom_nodetypes.xml?view=diff&rev=523838&r1=523837&r2=523838
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/nodetypes/custom_nodetypes.xml
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/nodetypes/custom_nodetypes.xml
Thu Mar 29 13:58:03 2007
@@ -183,11 +183,30 @@
 	        <valueConstraint>ghi</valueConstraint>
 	 	</valueConstraints>     
      </propertyDefinition>
-     <propertyDefinition name="graffito:autoCreatedProp" requiredType="String" autoCreated="true"
mandatory="false" onParentVersion="INITIALIZE" protected="false" multiple="false" >   
+     <propertyDefinition name="graffito:autoCreatedProp" requiredType="String" autoCreated="true"
mandatory="false" onParentVersion="COPY" protected="false" multiple="false" >   
             <defaultValues>
                 <defaultValue>autoCreatePropValue</defaultValue>
             </defaultValues>
      </propertyDefinition>
+     <propertyDefinition name="graffito:autoCreatedWithConstraintsProp" requiredType="String"
autoCreated="true" mandatory="false" onParentVersion="COPY" protected="false" multiple="false"
>   
+        <defaultValues>
+            <defaultValue>ccc</defaultValue>
+        </defaultValues>
+     	<valueConstraints>
+        	<valueConstraint>bbb</valueConstraint>
+	        <valueConstraint>ccc</valueConstraint>
+	        <valueConstraint>ddd</valueConstraint>
+	 	</valueConstraints>     
+            
+     </propertyDefinition>
+     <propertyDefinition name="graffito:mandatoryProp" requiredType="String" autoCreated="false"
mandatory="true" onParentVersion="COPY" protected="false" multiple="false" />     
+     <propertyDefinition name="graffito:mandatoryWithConstaintsProp" requiredType="String"
autoCreated="false" mandatory="true" onParentVersion="COPY" protected="false" multiple="false"
>     
+     	<valueConstraints>
+        	<valueConstraint>xx</valueConstraint>
+	        <valueConstraint>yy</valueConstraint>
+	 	</valueConstraints>      
+     </propertyDefinition>
+     
    </nodeType> 
 </nodeTypes>
 

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java?view=diff&rev=523838&r1=523837&r2=523838
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java
Thu Mar 29 13:58:03 2007
@@ -31,6 +31,7 @@
 import org.apache.portals.graffito.jcr.testmodel.A;
 import org.apache.portals.graffito.jcr.testmodel.B;
 import org.apache.portals.graffito.jcr.testmodel.C;
+import org.apache.portals.graffito.jcr.testmodel.PropertyTest;
 import org.apache.portals.graffito.jcr.testmodel.inheritance.Ancestor;
 import org.apache.portals.graffito.jcr.testmodel.inheritance.AnotherDescendant;
 import org.apache.portals.graffito.jcr.testmodel.inheritance.Descendant;
@@ -147,11 +148,16 @@
 	 */
 	public void testMapperOptionalProperties() {
 		try {
-			Mapper mapper = new DigesterMapperImpl("./src/test-config/jcrmapping.xml");
+
+			String[] files = { "./src/test-config/jcrmapping.xml",
+					           "./src/test-config/jcrmapping-jcrnodetypes.xml"};			
+
+			Mapper mapper = new DigesterMapperImpl(files);
+			
+			
 			assertNotNull("Mapper is null", mapper);
 
-			ClassDescriptor classDescriptor = mapper
-					.getClassDescriptorByClass(B.class);
+			ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(B.class);
 			assertNotNull("ClassDescriptor is null", classDescriptor);
 			assertTrue("Invalid classname", classDescriptor.getClassName()
 					.equals(B.class.getName()));
@@ -203,6 +209,19 @@
 			assertFalse(collectionDescriptor.isJcrProtected());
 			assertFalse(collectionDescriptor.isJcrSameNameSiblings());
 			assertEquals(collectionDescriptor.getJcrOnParentVersion(), "IGNORE");
+			
+			classDescriptor = mapper.getClassDescriptorByClass(PropertyTest.class);
+			assertNotNull(classDescriptor);
+			FieldDescriptor fieldDescriptor = classDescriptor.getFieldDescriptor("requiredWithConstraintsProp");
+			assertNotNull(fieldDescriptor.getJcrValueConstraints());
+			assertTrue("Invalid constaint", fieldDescriptor.getJcrValueConstraints()[0].equals("abc")
);
+			assertTrue("Invalid constaint", fieldDescriptor.getJcrValueConstraints()[1].equals("def")
);
+			assertTrue("Invalid constaint", fieldDescriptor.getJcrValueConstraints()[2].equals("ghi")
);
+			
+			fieldDescriptor = classDescriptor.getFieldDescriptor("autoCreatedProp");
+			assertNotNull(fieldDescriptor.getJcrDefaultValue());
+			assertTrue("Invalid default value", fieldDescriptor.getJcrDefaultValue().equals("aaa")
);
+			
 		} catch (JcrMappingException e) {
 			e.printStackTrace();
 			fail("Impossible to retrieve the converter " + e);

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/jcrnodetype/PersistenceManagerJcrNodeTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/jcrnodetype/PersistenceManagerJcrNodeTypeTest.java?view=diff&rev=523838&r1=523837&r2=523838
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/jcrnodetype/PersistenceManagerJcrNodeTypeTest.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/jcrnodetype/PersistenceManagerJcrNodeTypeTest.java
Thu Mar 29 13:58:03 2007
@@ -71,26 +71,6 @@
 			PersistenceManager persistenceManager = this.getPersistenceManager();
 
 			//---------------------------------------------------------------------------------------------------------
-			// Insert a  folder (class mapped to jcr:folder)
-			//---------------------------------------------------------------------------------------------------------
		
-//            Folder folder = new Folder();
-//            folder.setPath("/folder1");            
-//                        
-//            persistenceManager.insert(folder); 
-//           
-//			persistenceManager.save();
-			
-			
-			//---------------------------------------------------------------------------------------------------------
-			// Retrieve a document object
-			//---------------------------------------------------------------------------------------------------------
					
-//			folder = (Folder) persistenceManager.getObject( "/folder1");
-//			assertNotNull("folder is null", folder);			
-//			assertEquals("Document path is invalid", folder.getPath(), "/folder1");
-//			System.out.println("Folder calendar: " + folder.getCreationDate());	// The prop is autocreated

-			
-
-			//---------------------------------------------------------------------------------------------------------
 			// Insert a  folder (class mapped to jcr:folder) with one file (class mapped to jcr:file)
 			//---------------------------------------------------------------------------------------------------------
		
             Resource resource = new Resource();

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/jcrnodetype/PersistenceManagerJcrPropertyTest.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/jcrnodetype/PersistenceManagerJcrPropertyTest.java?view=diff&rev=523838&r1=523837&r2=523838
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/jcrnodetype/PersistenceManagerJcrPropertyTest.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/jcrnodetype/PersistenceManagerJcrPropertyTest.java
Thu Mar 29 13:58:03 2007
@@ -63,15 +63,30 @@
 		{
 			PersistenceManager persistenceManager = this.getPersistenceManager();
 			//---------------------------------------------------------------------------------------------------------
-			// Insert 
+			// Insert without the mandatory field
 			//---------------------------------------------------------------------------------------------------------
		
 			
             PropertyTest propertyTest = new PropertyTest();
             propertyTest.setPath("/test");
             propertyTest.setRequiredProp("requiredPropValue");
             propertyTest.setRequiredWithConstraintsProp("abc");
-            propertyTest.setAutoCreatedProp("autoCreatePropValue");
             
+            try 
+            {
+                 persistenceManager.insert(propertyTest);
+                 fail("Incorrect insert operation - the mandatory fields have no value");
+            }
+            catch(Exception e)
+            {
+               // Normal behaviour 	
+            	persistenceManager.refresh(false);
+            }
+            
+			//---------------------------------------------------------------------------------------------------------
+			// Insert with the mandatory fields
+			//---------------------------------------------------------------------------------------------------------
		
+            propertyTest.setMandatoryProp("mandatoryValue");
+            propertyTest.setMandatoryWithConstaintsProp("xx");
             persistenceManager.insert(propertyTest);
             persistenceManager.save();
             
@@ -81,29 +96,62 @@
             propertyTest = (PropertyTest) persistenceManager.getObject("/test");
             assertTrue("Invalid required property", propertyTest.getRequiredProp().equals("requiredPropValue"));
             assertTrue("Invalid required property with constraints", propertyTest.getRequiredWithConstraintsProp().equals("abc"));
           
-            assertTrue("Invalid autocreated property", propertyTest.getAutoCreatedProp().equals("autoCreatePropValue"));
           
+            assertTrue("Invalid autocreated property", propertyTest.getAutoCreatedProp().equals("aaa"));

+            assertTrue("Invalid autocreated property", propertyTest.getAutoCreatedWithConstraintsProp().equals("ccc"));
             
             //---------------------------------------------------------------------------------------------------------
 			// update the property requiredWithConstraintsProp with bad value
 			//---------------------------------------------------------------------------------------------------------
		
+            propertyTest = (PropertyTest) persistenceManager.getObject("/test");
             propertyTest.setRequiredWithConstraintsProp("invalid value");
             try 
             {
             	persistenceManager.update(propertyTest);
             	persistenceManager.save();
-            	fail("Invalid value was accepted");
+            	fail("Invalid value was accepted for requiredWithConstraintsProp");
             }
             catch(Exception e)
+            {                	
+               // Do nothing - normal behaviour, the value               	
+            }
+            
+            //---------------------------------------------------------------------------------------------------------
+			// update the property AutoCreatedWithConstraintsProp with bad value
+			//---------------------------------------------------------------------------------------------------------
		
+            propertyTest = (PropertyTest) persistenceManager.getObject("/test");
+            propertyTest.setAutoCreatedWithConstraintsProp("invalid value");
+            try 
             {
-                e.printStackTrace();	
-               // Do nothing - normal behaviour, the value  	
+            	persistenceManager.update(propertyTest);
+            	persistenceManager.save();
+            	fail("Invalid value was accepted for autoCreatedWithConstraintsProp ");
+            }
+            catch(Exception e)
+            {             	
+               // Do nothing - normal behaviour, the value is not valid
+               	
             }
             
+            //---------------------------------------------------------------------------------------------------------
+			// update the property mandatoryWithConstaintsProp with bad value
+			//---------------------------------------------------------------------------------------------------------
		
+            propertyTest = (PropertyTest) persistenceManager.getObject("/test");
+            propertyTest.setMandatoryWithConstaintsProp("yy");
+            try 
+            {
+            	persistenceManager.update(propertyTest);
+            	persistenceManager.save();
+            	fail("Invalid value was accepted for mandatoryWithConstaintsProp");
+            }
+            catch(Exception e)
+            {                	
+                e.printStackTrace();
+            }            
 			
 			
 		}
 		catch (Exception e)
-		{
+		{			
 			e.printStackTrace();
 			fail();
 		}



Mime
View raw message