You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by pa...@apache.org on 2019/01/15 20:02:06 UTC

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

Author: painter
Date: Tue Jan 15 20:02:05 2019
New Revision: 1851410

URL: http://svn.apache.org/viewvc?rev=1851410&view=rev
Log:
Javadoc cleanup, fix FindBugs and PMD report issues

Modified:
    turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java
    turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/StringField.java
    turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/XmlField.java
    turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/FileValidator.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
    turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/test/AnotherForm.java

Modified: turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java?rev=1851410&r1=1851409&r2=1851410&view=diff
==============================================================================
--- turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java (original)
+++ turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java Tue Jan 15 20:02:05 2019
@@ -35,6 +35,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 
 import javax.xml.XMLConstants;
@@ -744,7 +745,7 @@ public class IntakeServiceImpl extends A
             // Get the timestamp of the youngest file to be compared with
             // a serialized file. If it is younger than the serialized file,
             // then we have to parse the XML anyway.
-            timeStamp = (xmlFile.lastModified() > timeStamp) ? xmlFile
+            timeStamp = xmlFile.lastModified() > timeStamp ? xmlFile
                     .lastModified() : timeStamp;
         }
 
@@ -809,8 +810,14 @@ public class IntakeServiceImpl extends A
         }
 
         int counter = 0;
-        for (AppData appData : appDataElements.keySet())
-        {
+        AppData appData;
+        File dataFile;
+        for ( Entry<AppData, File> entry : appDataElements.entrySet() )
+        {
+        	// Set the entry pair
+        	appData = entry.getKey();
+        	dataFile = entry.getValue();
+        	
             int maxPooledGroups = 0;
             List<Group> glist = appData.getGroups();
 
@@ -828,7 +835,7 @@ public class IntakeServiceImpl extends A
                     getLogger().info(
                             "Ignored redefinition of Group " + groupName
                                     + " or Key " + g.getGID() + " from "
-                                    + appDataElements.get(appData));
+                                    + dataFile);
                 }
 
                 if (groupPrefix != null)
@@ -864,7 +871,7 @@ public class IntakeServiceImpl extends A
             KeyedPooledObjectFactory<String, Group> factory =
                 new Group.GroupFactory(appData);
 
-            GenericKeyedObjectPoolConfig poolConfig = new GenericKeyedObjectPoolConfig();
+            GenericKeyedObjectPoolConfig<Group> poolConfig = new GenericKeyedObjectPoolConfig<Group>();
             poolConfig.setMaxTotalPerKey(maxPooledGroups);
             poolConfig.setJmxEnabled(true);
             poolConfig.setJmxNamePrefix("fulcrum-intake-pool-" + counter++);
@@ -883,7 +890,7 @@ public class IntakeServiceImpl extends A
      * Note that the avalon.entry key="urn:avalon:home" 
      * and the type is {@link java.io.File}
      * 
-     * {@link org.apache.avalon.framework.context.Contextualizable#contextualize(Context)}
+     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
      * 
      * @param context the Context to use
      * @throws ContextException if the context is not found
@@ -899,6 +906,8 @@ public class IntakeServiceImpl extends A
      *
      * avalon.dependency type="org.apache.fulcrum.localization.LocalizationService"
      * 
+     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+     * 
      * @param manager the service manager
      * @throws ServiceException generic exception
      */

Modified: turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/StringField.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/StringField.java?rev=1851410&r1=1851409&r2=1851410&view=diff
==============================================================================
--- turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/StringField.java (original)
+++ turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/StringField.java Tue Jan 15 20:02:05 2019
@@ -98,7 +98,7 @@ public class StringField
             String[] sval = new String[ss.length];
             for (int i = 0; i < ss.length; i++)
             {
-                sval[i] = (StringUtils.isNotEmpty(ss[i])) ? ss[i] : (String) getEmptyValue();
+                sval[i] = StringUtils.isNotEmpty(ss[i]) ? ss[i] : (String) getEmptyValue();
             }
             setTestValue(sval);
         }

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=1851410&r1=1851409&r2=1851410&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 Tue Jan 15 20:02:05 2019
@@ -326,15 +326,13 @@ public class XmlField
             ruleMap.put(rule.getName(), rule);
         }
 
-        if (mapToObject == null)
+        // if a mapToProperty exists, set the object to this group's default
+        if (mapToObject == null && 
+        		mapToProperty != null &&
+        		StringUtils.isNotEmpty(mapToProperty) &&
+        		this.parent.getDefaultMapToObject() != null)
         {
-            // if a mapToProperty exists, set the object to this group's default
-            if (mapToProperty != null
-                    && !"".equals(mapToProperty)
-                    && this.parent.getDefaultMapToObject() != null)
-            {
-                mapToObject = this.parent.getDefaultMapToObject();
-            }
+        	mapToObject = this.parent.getDefaultMapToObject();
         }
     }
 

Modified: turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/FileValidator.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/FileValidator.java?rev=1851410&r1=1851409&r2=1851410&view=diff
==============================================================================
--- turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/FileValidator.java (original)
+++ turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/validator/FileValidator.java Tue Jan 15 20:02:05 2019
@@ -78,7 +78,12 @@ public class FileValidator
 
         try (InputStream fis = testValue.getInputStream())
         {
-            fis.read(fileData);
+            int byteSize = fis.read(fileData);
+            if ( fileData.length != byteSize )
+            {
+            	throw new ValidationException("Byte length mismatch found");
+            }
+            
         }
         catch (IOException e)
         {

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=1851410&r1=1851409&r2=1851410&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 Tue Jan 15 20:02:05 2019
@@ -47,13 +47,17 @@ public class IntakeServiceTest extends B
     private IntakeService intakeService = null;
 
     /**
-      * Defines the testcase for JUnit5.
-      *
-      */
+     * Defines the testcase for JUnit5.
+     * 
+     * @param testInfo defining the test
+     */
     public IntakeServiceTest(TestInfo testInfo) {
     	
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @BeforeEach
     public void setUp() throws Exception
     {
@@ -70,6 +74,9 @@ public class IntakeServiceTest extends B
 
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testBasicConfigLoads() throws Exception {
 

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=1851410&r1=1851409&r2=1851410&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 Tue Jan 15 20:02:05 2019
@@ -58,18 +58,20 @@ import static org.junit.jupiter.api.Asse
  */
 public class IntakeTest extends BaseUnit5Test
 {
-	 /**
+    /**
      * Defines the testcase for JUnit5.
-     *
+     * @param testInfo defining the test
      */
     public IntakeTest(TestInfo testInfo)
     {
     }
 
 
-    /*
+    /**
      * This looks strange to me. A test should not bother with explicit initialization.
      * That's the task of the container.
+     * 
+     * @throws Exception generic exception
      */
     @Disabled
     public void OFFtestFacadeNotConfigured() throws Exception
@@ -85,6 +87,9 @@ public class IntakeTest extends BaseUnit
         }
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testFacadeConfigured() throws Exception
     {
@@ -97,6 +102,9 @@ public class IntakeTest extends BaseUnit
 		assertNotNull(group);
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testInterfaceMapTo() throws Exception
     {
@@ -119,6 +127,9 @@ public class IntakeTest extends BaseUnit
         assertEquals("Joe", form.getUsername(), "User names should be equal");
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testParserInit() throws Exception
     {
@@ -140,6 +151,9 @@ public class IntakeTest extends BaseUnit
         assertEquals("Joe", userNameField.getValue(), "The field should have the value Joe");
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testEmptyBooleanField() throws Exception
     {
@@ -153,6 +167,9 @@ public class IntakeTest extends BaseUnit
         assertFalse( booleanField.isRequired(), "An Empty intake Field type boolean should not be required");
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testBooleanField() throws Exception
     {
@@ -166,6 +183,9 @@ public class IntakeTest extends BaseUnit
         assertFalse( booleanField.isRequired(), "An intake Field type boolean, which is not required, should not be required");
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testRequiredBooleanField() throws Exception
     {
@@ -179,6 +199,9 @@ public class IntakeTest extends BaseUnit
         assertTrue( booleanField.isRequired(), "An intake Field type boolean, which is required, should be required");
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testMultiValueField() throws Exception
     {
@@ -203,6 +226,9 @@ public class IntakeTest extends BaseUnit
         assertTrue( Arrays.equals(values, (int[])multiValueField.getValue()), "The field should have the value [1, 2]");
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testInvalidNumberMessage() throws Exception // TRB-74
     {

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=1851410&r1=1851409&r2=1851410&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 Tue Jan 15 20:02:05 2019
@@ -63,14 +63,17 @@ import static org.junit.jupiter.api.Asse
 @DisplayName("Intake Validator Test")
 public class IntakeValidatonTest extends BaseUnit5Test
 {
-	/**
+    /**
      * Defines the testcase for JUnit5.
-     *
+     * @param testInfo defining the test
      */
     public IntakeValidatonTest(TestInfo testInfo)
     {
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testStringValidation() throws Exception
     {
@@ -129,6 +132,9 @@ public class IntakeValidatonTest extends
         }
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testBooleanValidation() throws Exception
     {
@@ -166,6 +172,10 @@ public class IntakeValidatonTest extends
             fail("Validator should not throw ValidationException");
         }
     }
+    
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testBigDecimalValidation() throws Exception
     {
@@ -246,6 +256,10 @@ public class IntakeValidatonTest extends
         }
     }
 
+    
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testIntegerValidation() throws Exception
     {
@@ -316,6 +330,9 @@ public class IntakeValidatonTest extends
         }
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testIntegerRangeValidation() throws Exception
     {
@@ -372,6 +389,9 @@ public class IntakeValidatonTest extends
         }
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testFloatValidation() throws Exception
     {
@@ -452,6 +472,9 @@ public class IntakeValidatonTest extends
         }
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testDateStringValidation() throws Exception
     {
@@ -520,6 +543,9 @@ public class IntakeValidatonTest extends
         }
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testDateRangeValidation() throws Exception
     {
@@ -576,6 +602,9 @@ public class IntakeValidatonTest extends
         }
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testDoubleValidation() throws Exception
     {
@@ -656,6 +685,9 @@ public class IntakeValidatonTest extends
         }
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testShortValidation() throws Exception
     {
@@ -726,6 +758,9 @@ public class IntakeValidatonTest extends
         }
     }
 
+    /**
+     * @throws Exception generic exception
+     */
     @Test
     public void testLongValidation() throws Exception
     {

Modified: turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/test/AnotherForm.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/test/AnotherForm.java?rev=1851410&r1=1851409&r2=1851410&view=diff
==============================================================================
--- turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/test/AnotherForm.java (original)
+++ turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/test/AnotherForm.java Tue Jan 15 20:02:05 2019
@@ -39,7 +39,7 @@ public class AnotherForm
     }
 
     /**
-     * @param username
+     * @param username the user name
      */
     public void setUsername(String username)
     {