You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by bi...@apache.org on 2010/03/24 13:40:20 UTC

svn commit: r927038 - in /lucene/mahout/trunk: collections-codegen-plugin/src/main/java/org/apache/mahout/collection_codegen/CodeGenerator.java collections/src/test/java/org/apache/mahout/math/map/OpenHashMapTest.java

Author: bimargulies
Date: Wed Mar 24 12:40:20 2010
New Revision: 927038

URL: http://svn.apache.org/viewvc?rev=927038&view=rev
Log:
Experiment with quieting some PMD and checkstyle noise. 

Modified:
    lucene/mahout/trunk/collections-codegen-plugin/src/main/java/org/apache/mahout/collection_codegen/CodeGenerator.java
    lucene/mahout/trunk/collections/src/test/java/org/apache/mahout/math/map/OpenHashMapTest.java

Modified: lucene/mahout/trunk/collections-codegen-plugin/src/main/java/org/apache/mahout/collection_codegen/CodeGenerator.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/collections-codegen-plugin/src/main/java/org/apache/mahout/collection_codegen/CodeGenerator.java?rev=927038&r1=927037&r2=927038&view=diff
==============================================================================
--- lucene/mahout/trunk/collections-codegen-plugin/src/main/java/org/apache/mahout/collection_codegen/CodeGenerator.java (original)
+++ lucene/mahout/trunk/collections-codegen-plugin/src/main/java/org/apache/mahout/collection_codegen/CodeGenerator.java Wed Mar 24 12:40:20 2010
@@ -19,6 +19,15 @@
 
 package org.apache.mahout.collection_codegen;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
@@ -29,16 +38,6 @@ import org.apache.velocity.VelocityConte
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.context.Context;
 import org.codehaus.plexus.util.SelectorUtils;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 /**
  * @description Generate java code with Velocity.
  * @goal generate
@@ -129,6 +128,7 @@ public class CodeGenerator extends Abstr
   private MavenProject project;
   private VelocityEngine testVelocityEngine;
   private final FileSetManager fileSetManager;
+  private VelocityEngine mainVelocityEngine;
   
   public CodeGenerator() {
     typeToObjectTypeMap = new HashMap<String,String>();
@@ -155,22 +155,7 @@ public class CodeGenerator extends Abstr
       testOutputDirectory.mkdirs();
     }
 
-    VelocityEngine mainVelocityEngine = new VelocityEngine();
-    mainVelocityEngine.setProperty("file.resource.loader.path", sourceTemplateRoot);
-    if (testTemplateRoot != null) {
-      testVelocityEngine = new VelocityEngine();
-      testVelocityEngine.setProperty("file.resource.loader.path", testTemplateRoot);
-    }
-
-    
-    try {
-      mainVelocityEngine.init();
-      if (testVelocityEngine != null) {
-        testVelocityEngine.init();
-      }
-    } catch (Exception e) {
-      throw new MojoExecutionException("Unable to initialize velocity", e);
-    }
+    initializeVelocity();
     
     if (sourceTemplateRoot != null) {
       runGeneration(
@@ -194,6 +179,25 @@ public class CodeGenerator extends Abstr
     }
     
   }
+
+  private void initializeVelocity() throws MojoExecutionException {
+    mainVelocityEngine = new VelocityEngine();
+    mainVelocityEngine.setProperty("file.resource.loader.path", sourceTemplateRoot);
+    if (testTemplateRoot != null) {
+      testVelocityEngine = new VelocityEngine();
+      testVelocityEngine.setProperty("file.resource.loader.path", testTemplateRoot);
+    }
+
+    
+    try {
+      mainVelocityEngine.init();
+      if (testVelocityEngine != null) {
+        testVelocityEngine.init();
+      }
+    } catch (Exception e) {
+      throw new MojoExecutionException("Unable to initialize velocity", e);
+    }
+  }
   
   private void runGeneration(String thisSourceRoot, 
       VelocityEngine engine,

Modified: lucene/mahout/trunk/collections/src/test/java/org/apache/mahout/math/map/OpenHashMapTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/collections/src/test/java/org/apache/mahout/math/map/OpenHashMapTest.java?rev=927038&r1=927037&r2=927038&view=diff
==============================================================================
--- lucene/mahout/trunk/collections/src/test/java/org/apache/mahout/math/map/OpenHashMapTest.java (original)
+++ lucene/mahout/trunk/collections/src/test/java/org/apache/mahout/math/map/OpenHashMapTest.java Wed Mar 24 12:40:20 2010
@@ -101,6 +101,7 @@ public class OpenHashMapTest extends Ass
   }
   
   @Test
+  @SuppressWarnings("PMD")
   public void testContainValue() {
     OpenHashMap<String, String> map = new OpenHashMap<String, String>();
     map.put("Eleven", "11");