You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by gk...@apache.org on 2016/10/21 14:09:10 UTC

svn commit: r1766027 - in /turbine/fulcrum/trunk/intake: ./ src/java/org/apache/fulcrum/intake/model/ src/test/org/apache/fulcrum/intake/

Author: gk
Date: Fri Oct 21 14:09:09 2016
New Revision: 1766027

URL: http://svn.apache.org/viewvc?rev=1766027&view=rev
Log:
TRB-99 fixed -tested ok: jdk 1.7 and 1.8

Modified:
    turbine/fulcrum/trunk/intake/pom.xml
    turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Field.java
    turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldAdapter.java
    turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Group.java
    turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/XmlField.java
    turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeServiceTest.java
    turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeTest.java
    turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeValidatonTest.java

Modified: turbine/fulcrum/trunk/intake/pom.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/pom.xml?rev=1766027&r1=1766026&r2=1766027&view=diff
==============================================================================
--- turbine/fulcrum/trunk/intake/pom.xml (original)
+++ turbine/fulcrum/trunk/intake/pom.xml Fri Oct 21 14:09:09 2016
@@ -112,13 +112,14 @@
     <dependency>
       <groupId>org.apache.fulcrum</groupId>
       <artifactId>fulcrum-testcontainer</artifactId>
-      <version>1.0.6</version>
+      <version>1.0.7</version>
       <scope>test</scope>
     </dependency>
+    <!-- be aware to adapt group-id to org.apache.fulcrum again after version 1.0.7 -->
     <dependency>
-      <groupId>org.apache.fulcrum</groupId>
+      <groupId>org.apache.turbine</groupId>
       <artifactId>fulcrum-yaafi</artifactId>
-      <version>1.0.6</version>
+      <version>1.0.7</version>
       <scope>test</scope>
     </dependency>
   </dependencies>

Modified: turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Field.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Field.java?rev=1766027&r1=1766026&r2=1766027&view=diff
==============================================================================
--- turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Field.java (original)
+++ turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Field.java Fri Oct 21 14:09:09 2016
@@ -1039,7 +1039,7 @@ public abstract class Field<T> implement
     /**
      * Gets the maximum size of the field.  This is useful when
      * building the HTML input tag.  The maxSize is set with the maxLength
-     * rule.  If this rul was not set, an enmpty string is returned.
+     * rule.  If this rule was not set, an empty string is returned.
      */
     public String getMaxSize()
     {

Modified: turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldAdapter.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldAdapter.java?rev=1766027&r1=1766026&r2=1766027&view=diff
==============================================================================
--- turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldAdapter.java (original)
+++ turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldAdapter.java Fri Oct 21 14:09:09 2016
@@ -20,7 +20,10 @@ package org.apache.fulcrum.intake.model;
  */
 
 import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.xml.bind.annotation.adapters.XmlAdapter;
@@ -210,6 +213,18 @@ public class FieldAdapter extends XmlAda
         FieldCtor fieldCtor = null;
         Field<?> field = null;
         String type = xmlField.getType();
+        
+        List<Rule> rules = xmlField.getRules();
+        if (rules != null ) 
+        {
+        
+        	xmlField.getRuleMap().clear();
+        	Map<String,Rule> ruleMap = xmlField.getRuleMap();
+        	for (Rule rule : rules)
+	        {
+	            ruleMap.put(rule.getName(), rule);
+	        }
+        }
 
         fieldCtor = fieldCtors.get(type);
         if (fieldCtor == null)
@@ -231,9 +246,37 @@ public class FieldAdapter extends XmlAda
     @Override
     public Field<?> unmarshal(XmlField xmlField) throws Exception
     {
-        return getInstance(xmlField, xmlField.getGroup());
+    	Field<?> field = getInstance(xmlField, xmlField.getGroup());
+    	
+    	processDataInGroupContext(xmlField, field);        
+    	
+    	return field;
     }
 
+	private void processDataInGroupContext(XmlField xmlField, Field<?> field) {
+		Group group = xmlField.getGroup();
+    	Map<String, Field<?>> fields = group.fields;
+    	
+    	int defaultSize = 5;
+        if (fields == null) 
+        {
+        	fields = new HashMap<String, Field<?>>((int) (1.25 * defaultSize + 1));
+        }
+    	
+    	List<Field<?>> fieldsArray = null; // fieldsArray
+    	if (group.fieldsArray == null) 
+    	{
+        	fieldsArray = new ArrayList<Field<?>>();
+        } else 
+        {
+        	fieldsArray= new ArrayList<Field<?>>(Arrays.asList(group.fieldsArray));// resizable not size -fixed
+        }
+        fieldsArray.add(field);
+        fields.put(field.getName(), field);
+        group.fields = fields;
+        group.fieldsArray = fieldsArray.toArray(new Field<?>[]{});
+	}
+
     /**
      * @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object)
      */

Modified: turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Group.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Group.java?rev=1766027&r1=1766026&r2=1766027&view=diff
==============================================================================
--- turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Group.java (original)
+++ turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Group.java Fri Oct 21 14:09:09 2016
@@ -346,14 +346,14 @@ public class Group implements Serializab
     {
         if (fieldsArray == null)
         {
-            return new ArrayList<Field<?>>();
+            return null;// new ArrayList<Field<?>>();
         }
 
         return Arrays.asList(fieldsArray);
     }
 
     /**
-     * Set a collection of fields for this group
+     * Jaxb sets the collection of fields for this group
      *
      * @param fields the fields to set
      */
@@ -361,16 +361,6 @@ public class Group implements Serializab
     @XmlJavaTypeAdapter(FieldAdapter.class)
     protected void setFields(List<Field<?>> inputFields)
     {
-        int size = inputFields.size();
-        fields = new HashMap<String, Field<?>>((int) (1.25 * size + 1));
-        fieldsArray = new Field[size];
-
-        for (int i = size - 1; i >= 0; i--)
-        {
-            Field<?> field = inputFields.get(i);
-            fieldsArray[i] = field;
-            fields.put(field.getName(), field);
-        }
     }
 
     /**

Modified: turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/XmlField.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/XmlField.java?rev=1766027&r1=1766026&r2=1766027&view=diff
==============================================================================
--- turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/XmlField.java (original)
+++ turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/XmlField.java Fri Oct 21 14:09:09 2016
@@ -93,7 +93,14 @@ public class XmlField
     @XmlAttribute
     private String emptyValue;
 
+    /**
+     * Jaxb set the collection of rules for this field
+     *
+     * @param rules the rules to set
+     */
+    @XmlElement(name="rule")
     private List<Rule> rules;
+    
     private Map<String, Rule> ruleMap;
 
     private Group parent;
@@ -262,22 +269,6 @@ public class XmlField
     }
 
     /**
-     * Set the collection of rules for this field
-     *
-     * @param rules the rules to set
-     */
-    @XmlElement(name="rule")
-    public void setRules(List<Rule> rules)
-    {
-        this.rules = rules;
-        this.ruleMap.clear();
-        for (Rule rule : rules)
-        {
-            ruleMap.put(rule.getName(), rule);
-        }
-    }
-
-    /**
      * The collection of rules for this field keyed by
      * parameter name.
      *

Modified: turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeServiceTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeServiceTest.java?rev=1766027&r1=1766026&r2=1766027&view=diff
==============================================================================
--- turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeServiceTest.java (original)
+++ turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeServiceTest.java Fri Oct 21 14:09:09 2016
@@ -19,10 +19,17 @@ package org.apache.fulcrum.intake;
  * under the License.
  */
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.io.File;
 
 import org.apache.fulcrum.intake.model.Group;
-import org.apache.fulcrum.testcontainer.BaseUnitTest;
+import org.apache.fulcrum.testcontainer.BaseUnit4Test;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * @author Eric Pugh
@@ -30,30 +37,28 @@ import org.apache.fulcrum.testcontainer.
  * To change the template for this generated type comment go to
  * Window>Preferences>Java>Code Generation>Code and Comments
  */
-public class IntakeServiceTest extends BaseUnitTest
+public class IntakeServiceTest extends BaseUnit4Test
 {
     private static final File BASEDIR = new File( System.getProperty( "basedir" ));
 
     private IntakeService intakeService = null;
 
     /**
-      * Defines the testcase name for JUnit.
+      * Defines the testcase for JUnit4.
       *
-      * @param name the testcase's name.
       */
-    public IntakeServiceTest(String name) {
-        super(name);
+    public IntakeServiceTest() {
     }
 
+    @Before
     public void setUp() throws Exception
     {
-        super.setUp();
         File appData = new File( BASEDIR, "target/appData.ser");
         if(appData.exists()){
             appData.delete();
         }
         try {
-            intakeService = (IntakeService) this.resolve( IntakeService.class.getName() );
+            intakeService = (IntakeService) this.lookup( IntakeService.class.getName() );
         } catch (Throwable e) {
             fail(e.getMessage());
         }
@@ -61,6 +66,7 @@ public class IntakeServiceTest extends B
 
     }
 
+    @Test
     public void testBasicConfigLoads() throws Exception {
 
         Group group = intakeService.getGroup("LoginGroup");

Modified: turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeTest.java?rev=1766027&r1=1766026&r2=1766027&view=diff
==============================================================================
--- turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeTest.java (original)
+++ turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeTest.java Fri Oct 21 14:09:09 2016
@@ -19,6 +19,8 @@ package org.apache.fulcrum.intake;
  * under the License.
  */
 
+import static org.junit.Assert.*;
+
 import java.util.Arrays;
 import java.util.Locale;
 
@@ -36,7 +38,9 @@ import org.apache.fulcrum.intake.validat
 import org.apache.fulcrum.parser.DefaultParameterParser;
 import org.apache.fulcrum.parser.ParserService;
 import org.apache.fulcrum.parser.ValueParser;
-import org.apache.fulcrum.testcontainer.BaseUnitTest;
+import org.apache.fulcrum.testcontainer.BaseUnit4Test;
+import org.junit.Ignore;
+import org.junit.Test;
 /**
  * Test the facade class for the service
  *
@@ -44,16 +48,14 @@ import org.apache.fulcrum.testcontainer.
  * @author <a href="mailto:jh@byteaction.de">J&uuml;rgen Hoffmann</a>
  * @version $Id$
  */
-public class IntakeTest extends BaseUnitTest
+public class IntakeTest extends BaseUnit4Test
 {
-    /**
-     * Defines the testcase name for JUnit.
+	 /**
+     * Defines the testcase for JUnit4.
      *
-     * @param name the testcase's name.
      */
-    public IntakeTest(String name)
+    public IntakeTest()
     {
-        super(name);
     }
 
 
@@ -61,6 +63,7 @@ public class IntakeTest extends BaseUnit
      * This looks strange to me. A test should not bother with explicit initialization.
      * That's the task of the container.
      */
+    @Ignore
     public void OFFtestFacadeNotConfigured() throws Exception
     {
 		assertFalse(IntakeServiceFacade.isInitialized());
@@ -74,10 +77,11 @@ public class IntakeTest extends BaseUnit
         }
     }
 
+    @Test
     public void testFacadeConfigured() throws Exception
     {
         // this.lookup causes the workflow service to be configured.
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("LoginGroup");
         assertNotNull(group);
         assertTrue(IntakeServiceFacade.isInitialized());
@@ -85,15 +89,16 @@ public class IntakeTest extends BaseUnit
 		assertNotNull(group);
     }
 
+    @Test
     public void testInterfaceMapTo() throws Exception
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("LoginIfcGroup");
         assertNotNull(group);
 
         Field<?> userNameField = group.get("Username");
 
-        ParserService ps = (ParserService) this.resolve( ParserService.ROLE );
+        ParserService ps = (ParserService) this.lookup( ParserService.ROLE );
         ValueParser pp = ps.getParser(DefaultParameterParser.class);
 
         pp.setString(userNameField.getKey(), "Joe");
@@ -106,15 +111,16 @@ public class IntakeTest extends BaseUnit
         assertEquals("User names should be equal", "Joe", form.getUsername());
     }
 
+    @Test
     public void testParserInit() throws Exception
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("LoginGroup");
         assertNotNull(group);
 
         Field<?> userNameField = group.get("Username");
 
-        ParserService ps = (ParserService) this.resolve( ParserService.ROLE );
+        ParserService ps = (ParserService) this.lookup( ParserService.ROLE );
         ValueParser pp = ps.getParser(DefaultParameterParser.class);
 
         pp.setString("loginGroupKey_0loginUsernameKey", "Joe");
@@ -126,9 +132,10 @@ public class IntakeTest extends BaseUnit
         assertEquals("The field should have the value Joe", "Joe", userNameField.getValue());
     }
 
+    @Test
     public void testEmptyBooleanField() throws Exception
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("BooleanTest");
         assertNotNull(group);
         assertTrue(IntakeServiceFacade.isInitialized());
@@ -138,9 +145,10 @@ public class IntakeTest extends BaseUnit
         assertFalse("An Empty intake Field type boolean should not be required", booleanField.isRequired());
     }
 
+    @Test
     public void testBooleanField() throws Exception
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("BooleanTest");
         assertNotNull(group);
         assertTrue(IntakeServiceFacade.isInitialized());
@@ -150,9 +158,10 @@ public class IntakeTest extends BaseUnit
         assertFalse("An intake Field type boolean, which is not required, should not be required", booleanField.isRequired());
     }
 
+    @Test
     public void testRequiredBooleanField() throws Exception
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("BooleanTest");
         assertNotNull(group);
         assertTrue(IntakeServiceFacade.isInitialized());
@@ -162,16 +171,17 @@ public class IntakeTest extends BaseUnit
         assertTrue("An intake Field type boolean, which is required, should be required", booleanField.isRequired());
     }
 
+    @Test
     public void testMultiValueField() throws Exception
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("NumberTest");
         assertNotNull(group);
         Field<?> multiValueField = group.get("MultiIntegerTestField");
         assertTrue("The Default Validator of an intake Field type int should be IntegerValidator", (multiValueField.getValidator() instanceof IntegerValidator));
         assertTrue("An intake Field type int, which is multiValued, should be multiValued", multiValueField.isMultiValued());
 
-        ParserService ps = (ParserService) this.resolve( ParserService.ROLE );
+        ParserService ps = (ParserService) this.lookup( ParserService.ROLE );
         ValueParser pp = ps.getParser(DefaultParameterParser.class);
 
         int[] values = new int[] { 1, 2 };
@@ -185,9 +195,10 @@ public class IntakeTest extends BaseUnit
         assertTrue("The field should have the value [1, 2]", Arrays.equals(values, (int[])multiValueField.getValue()));
     }
 
+    @Test
     public void testInvalidNumberMessage() throws Exception // TRB-74
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("NumberTest");
         assertNotNull(group);
 

Modified: turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeValidatonTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeValidatonTest.java?rev=1766027&r1=1766026&r2=1766027&view=diff
==============================================================================
--- turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeValidatonTest.java (original)
+++ turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeValidatonTest.java Fri Oct 21 14:09:09 2016
@@ -19,6 +19,10 @@ package org.apache.fulcrum.intake;
  * under the License.
  */
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
 import java.util.Locale;
 
 import org.apache.fulcrum.intake.model.Field;
@@ -36,27 +40,32 @@ import org.apache.fulcrum.intake.validat
 import org.apache.fulcrum.parser.DefaultParameterParser;
 import org.apache.fulcrum.parser.ParserService;
 import org.apache.fulcrum.parser.ValueParser;
-import org.apache.fulcrum.testcontainer.BaseUnitTest;
+import org.apache.fulcrum.testcontainer.BaseUnit4Test;
+import org.junit.Test;
 /**
  * Test the validators
  *
  * @author <a href="tv@apache.org">Thomas Vandahl</a>
  */
-public class IntakeValidatonTest extends BaseUnitTest
+/**
+ * Test the validators
+ *
+ * @author <a href="tv@apache.org">Thomas Vandahl</a>
+ */
+public class IntakeValidatonTest extends BaseUnit4Test
 {
-    /**
-     * Defines the testcase name for JUnit.
+	/**
+     * Defines the testcase for JUnit4.
      *
-     * @param name the testcase's name.
      */
-    public IntakeValidatonTest(String name)
+    public IntakeValidatonTest()
     {
-        super(name);
     }
 
+    @Test
     public void testStringValidation() throws Exception
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("ValidationTest");
         assertNotNull(group);
 
@@ -111,9 +120,10 @@ public class IntakeValidatonTest extends
         }
     }
 
+    @Test
     public void testBooleanValidation() throws Exception
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("ValidationTest");
         assertNotNull(group);
 
@@ -147,10 +157,10 @@ public class IntakeValidatonTest extends
             fail("Validator should not throw ValidationException");
         }
     }
-
+    @Test
     public void testBigDecimalValidation() throws Exception
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("ValidationTest");
         assertNotNull(group);
 
@@ -216,9 +226,10 @@ public class IntakeValidatonTest extends
         }
     }
 
+    @Test
     public void testIntegerValidation() throws Exception
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("ValidationTest");
         assertNotNull(group);
 
@@ -274,13 +285,14 @@ public class IntakeValidatonTest extends
         }
     }
 
+    @Test
     public void testIntegerRangeValidation() throws Exception
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("ValidationTest");
         assertNotNull(group);
 
-        ParserService ps = (ParserService) this.resolve( ParserService.ROLE );
+        ParserService ps = (ParserService) this.lookup( ParserService.ROLE );
         ValueParser pp = ps.getParser(DefaultParameterParser.class);
 
         pp.add("vt_0itf", "15");
@@ -329,9 +341,10 @@ public class IntakeValidatonTest extends
         }
     }
 
+    @Test
     public void testFloatValidation() throws Exception
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("ValidationTest");
         assertNotNull(group);
 
@@ -397,9 +410,10 @@ public class IntakeValidatonTest extends
         }
     }
 
+    @Test
     public void testDateStringValidation() throws Exception
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("ValidationTest");
         assertNotNull(group);
 
@@ -464,13 +478,14 @@ public class IntakeValidatonTest extends
         }
     }
 
+    @Test
     public void testDateRangeValidation() throws Exception
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("ValidationTest");
         assertNotNull(group);
 
-        ParserService ps = (ParserService) this.resolve( ParserService.ROLE );
+        ParserService ps = (ParserService) this.lookup( ParserService.ROLE );
         ValueParser pp = ps.getParser(DefaultParameterParser.class);
 
         pp.add("vt_0dstf", "12/23/2001");
@@ -519,9 +534,10 @@ public class IntakeValidatonTest extends
         }
     }
 
+    @Test
     public void testDoubleValidation() throws Exception
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("ValidationTest");
         assertNotNull(group);
 
@@ -587,9 +603,10 @@ public class IntakeValidatonTest extends
         }
     }
 
+    @Test
     public void testShortValidation() throws Exception
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("ValidationTest");
         assertNotNull(group);
 
@@ -645,9 +662,10 @@ public class IntakeValidatonTest extends
         }
     }
 
+    @Test
     public void testLongValidation() throws Exception
     {
-        IntakeService is = (IntakeService) this.resolve( IntakeService.ROLE );
+        IntakeService is = (IntakeService) this.lookup( IntakeService.ROLE );
         Group group = is.getGroup("ValidationTest");
         assertNotNull(group);
 



Re: svn commit: r1766027 - in /turbine/fulcrum/trunk/intake: ./ src/java/org/apache/fulcrum/intake/model/ src/test/org/apache/fulcrum/intake/

Posted by Thomas Vandahl <tv...@apache.org>.
On 21.10.16 16:09, gk@apache.org wrote:
> Author: gk
> Date: Fri Oct 21 14:09:09 2016
> New Revision: 1766027
> 
> URL: http://svn.apache.org/viewvc?rev=1766027&view=rev
> Log:
> TRB-99 fixed -tested ok: jdk 1.7 and 1.8

Whoo, that's quite a lot of changes. Could you please explain a bit what
you did and why? Some things look strange to me.

Bye, Thomas.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@turbine.apache.org
For additional commands, e-mail: dev-help@turbine.apache.org


Re: Re: svn commit: r1766027 - in /turbine/fulcrum/trunk/intake: ./ src/java/org/apache/fulcrum/intake/model/ src/test/org/apache/fulcrum/intake/

Posted by Georg Kallidis <ge...@cedis.fu-berlin.de>.
Hi Thomas,

@my approach
I started with updating the deps, and upgrade to JUnit4. 

JAXB before calling afterUnMarshal did not visit the code in Group.setFields. I researched a little bit (Stackoverflow..) and thought the best hook would be the Adapter, which already exists. 
As it hooks the instantiation of a single field, I had to change a little bit the update of the arrays/map. The same was true for the rules, but they are available in the adapter ready as a list, so I could just copy and past the code. 

@your approach
Please feel free to discuss or change it in the code, if it could be done in afterUnMarshal may be the better!
 
-Georg


-----Thomas Vandahl <tv...@apache.org> schrieb: -----
An: dev@turbine.apache.org
Von: Thomas Vandahl <tv...@apache.org>
Datum: 23.10.2016 19:23
Betreff: Re: svn commit: r1766027 - in /turbine/fulcrum/trunk/intake: ./ src/java/org/apache/fulcrum/intake/model/ src/test/org/apache/fulcrum/intake/

Hi Georg,

On 21.10.16 16:09, gk@apache.org wrote:
> Author: gk
> Date: Fri Oct 21 14:09:09 2016
> New Revision: 1766027
> 
> URL: http://svn.apache.org/viewvc?rev=1766027&view=rev
> Log:
> TRB-99 fixed -tested ok: jdk 1.7 and 1.8
[...]
> Modified: turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldAdapter.java
> URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldAdapter.java?rev=1766027&r1=1766026&r2=1766027&view=diff
> ==============================================================================
> --- turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldAdapter.java (original)
> +++ turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldAdapter.java Fri Oct 21 14:09:09 2016
> @@ -20,7 +20,10 @@ package org.apache.fulcrum.intake.model;
>   */
>  
>  import java.lang.reflect.Constructor;
> +import java.util.ArrayList;
> +import java.util.Arrays;
>  import java.util.HashMap;
> +import java.util.List;
>  import java.util.Map;
>  
>  import javax.xml.bind.annotation.adapters.XmlAdapter;
> @@ -210,6 +213,18 @@ public class FieldAdapter extends XmlAda
>          FieldCtor fieldCtor = null;
>          Field<?> field = null;
>          String type = xmlField.getType();
> +        
> +        List<Rule> rules = xmlField.getRules();
> +        if (rules != null ) 
> +        {
> +        
> +        	xmlField.getRuleMap().clear();
> +        	Map<String,Rule> ruleMap = xmlField.getRuleMap();
> +        	for (Rule rule : rules)
> +	       {
> +	           ruleMap.put(rule.getName(), rule);
> +	       }
> +        }

I suggest to keep the adapter free of these operations. I'd rather stick
to afterUnmarshal() to complete the data objects. The following is not
necessary then and the scope is kept locally.

>  
>          fieldCtor = fieldCtors.get(type);
>          if (fieldCtor == null)
> @@ -231,9 +246,37 @@ public class FieldAdapter extends XmlAda
>      @Override
>      public Field<?> unmarshal(XmlField xmlField) throws Exception
>      {
> -        return getInstance(xmlField, xmlField.getGroup());
> +    	Field<?> field = getInstance(xmlField, xmlField.getGroup());
> +    	
> +    	processDataInGroupContext(xmlField, field);        
> +    	
> +    	return field;
[...]

+1 for switching to JUnit 4.

Would you like to see my approach?

Bye, Thomas.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@turbine.apache.org
For additional commands, e-mail: dev-help@turbine.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@turbine.apache.org
For additional commands, e-mail: dev-help@turbine.apache.org

Re: svn commit: r1766027 - in /turbine/fulcrum/trunk/intake: ./ src/java/org/apache/fulcrum/intake/model/ src/test/org/apache/fulcrum/intake/

Posted by Thomas Vandahl <tv...@apache.org>.
Hi Georg,

On 21.10.16 16:09, gk@apache.org wrote:
> Author: gk
> Date: Fri Oct 21 14:09:09 2016
> New Revision: 1766027
> 
> URL: http://svn.apache.org/viewvc?rev=1766027&view=rev
> Log:
> TRB-99 fixed -tested ok: jdk 1.7 and 1.8
[...]
> Modified: turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldAdapter.java
> URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldAdapter.java?rev=1766027&r1=1766026&r2=1766027&view=diff
> ==============================================================================
> --- turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldAdapter.java (original)
> +++ turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/FieldAdapter.java Fri Oct 21 14:09:09 2016
> @@ -20,7 +20,10 @@ package org.apache.fulcrum.intake.model;
>   */
>  
>  import java.lang.reflect.Constructor;
> +import java.util.ArrayList;
> +import java.util.Arrays;
>  import java.util.HashMap;
> +import java.util.List;
>  import java.util.Map;
>  
>  import javax.xml.bind.annotation.adapters.XmlAdapter;
> @@ -210,6 +213,18 @@ public class FieldAdapter extends XmlAda
>          FieldCtor fieldCtor = null;
>          Field<?> field = null;
>          String type = xmlField.getType();
> +        
> +        List<Rule> rules = xmlField.getRules();
> +        if (rules != null ) 
> +        {
> +        
> +        	xmlField.getRuleMap().clear();
> +        	Map<String,Rule> ruleMap = xmlField.getRuleMap();
> +        	for (Rule rule : rules)
> +	        {
> +	            ruleMap.put(rule.getName(), rule);
> +	        }
> +        }

I suggest to keep the adapter free of these operations. I'd rather stick
to afterUnmarshal() to complete the data objects. The following is not
necessary then and the scope is kept locally.

>  
>          fieldCtor = fieldCtors.get(type);
>          if (fieldCtor == null)
> @@ -231,9 +246,37 @@ public class FieldAdapter extends XmlAda
>      @Override
>      public Field<?> unmarshal(XmlField xmlField) throws Exception
>      {
> -        return getInstance(xmlField, xmlField.getGroup());
> +    	Field<?> field = getInstance(xmlField, xmlField.getGroup());
> +    	
> +    	processDataInGroupContext(xmlField, field);        
> +    	
> +    	return field;
[...]

+1 for switching to JUnit 4.

Would you like to see my approach?

Bye, Thomas.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@turbine.apache.org
For additional commands, e-mail: dev-help@turbine.apache.org