You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by ca...@apache.org on 2011/11/04 13:45:52 UTC

svn commit: r1197540 - in /incubator/jena/Jena2/jena/trunk: ./ src/main/java/jena/cmdline/ src/test/java/com/hp/hpl/jena/rdf/arp/ src/test/java/com/hp/hpl/jena/test/ src/test/resources/

Author: castagna
Date: Fri Nov  4 12:45:51 2011
New Revision: 1197540

URL: http://svn.apache.org/viewvc?rev=1197540&view=rev
Log:
JENA-36 and JENA-155

This is to make sure we do not have log messages (either at WARN or ERROR level) when we run the test suite in Eclipse or via mvn test command line.

There are two log4j properties file: one is used by the test suite and it's located in src/test/resources/log4j.properties. The other one is src/main/java/jena-log4j.properties and it is included in the .jar file (because we want command lines to have logging enabled). I usually have just one log4j.properties in src/test/resources and do not ship jars with log4j in it. If that is needed, a better location for jena-log4j.properties is src/main/resources. I am not going do to this now.

I agree on the principle of not having spurious errors or warning when we execute the test suite (and this is the reason why I am committing this).
However, I did not find this task trivial as it should have been. We could benefit from a common and shared approach towards logging, error messages, System.out|err, in the code and in the tests. It there is one, I am not aware of it and I am not able to infer it from the sources. At the moment IMHO there is a too high degree of diversity (which some could call caos). :-)

I am not proposing to do anything about this now, let's focus on the release. However a discussion on what would be the right thing to do and sharing a best practice is possible.

Modified:
    incubator/jena/Jena2/jena/trunk/.classpath
    incubator/jena/Jena2/jena/trunk/pom.xml
    incubator/jena/Jena2/jena/trunk/src/main/java/jena/cmdline/CmdLineUtils.java
    incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/rdf/arp/MoreTests.java
    incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/rdf/arp/StAX2ModelTest.java
    incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/test/TestPackage.java
    incubator/jena/Jena2/jena/trunk/src/test/resources/log4j.properties

Modified: incubator/jena/Jena2/jena/trunk/.classpath
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/jena/trunk/.classpath?rev=1197540&r1=1197539&r2=1197540&view=diff
==============================================================================
--- incubator/jena/Jena2/jena/trunk/.classpath (original)
+++ incubator/jena/Jena2/jena/trunk/.classpath Fri Nov  4 12:45:51 2011
@@ -4,17 +4,12 @@
   <classpathentry kind="src" path="src/test/java"/>
   <classpathentry kind="src" path="src-examples"/>
   <classpathentry kind="output" path="classes"/>
-
+  <classpathentry kind="src" path="src/test/resources" excluding="**/*.java"/>
 
   <classpathentry kind="var" path="M2_REPO/com/ibm/icu/icu4j/3.4.4/icu4j-3.4.4.jar" sourcepath="M2_REPO/com/ibm/icu/icu4j/3.4.4/icu4j-3.4.4-sources.jar"/>
-
-  <classpathentry kind="var" 
-		  path="M2_REPO/org/apache/jena/jena-iri/0.9.0-incubating-SNAPSHOT/jena-iri-0.9.0-incubating-SNAPSHOT.jar"
-		  sourcepath="M2_REPO/org/apache/jena/jena-iri/0.9.0-incubating-SNAPSHOT/jena-iri-0.9.0-incubating-SNAPSHOT-sources.jar"/>
-
+  <classpathentry kind="var" path="M2_REPO/org/apache/jena/jena-iri/0.9.0-incubating-SNAPSHOT/jena-iri-0.9.0-incubating-SNAPSHOT.jar" sourcepath="M2_REPO/org/apache/jena/jena-iri/0.9.0-incubating-SNAPSHOT/jena-iri-0.9.0-incubating-SNAPSHOT-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/junit/junit/4.9/junit-4.9.jar" sourcepath="M2_REPO/junit/junit/4.9/junit-4.9-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16.jar" sourcepath="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16-sources.jar"/>
-
   <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar" sourcepath="M2_REPO/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/slf4j/jcl-over-slf4j/1.6.1/jcl-over-slf4j-1.6.1.jar" sourcepath="M2_REPO/org/slf4j/jcl-over-slf4j/1.6.1/jcl-over-slf4j-1.6.1-sources.jar"/>

Modified: incubator/jena/Jena2/jena/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/jena/trunk/pom.xml?rev=1197540&r1=1197539&r2=1197540&view=diff
==============================================================================
--- incubator/jena/Jena2/jena/trunk/pom.xml (original)
+++ incubator/jena/Jena2/jena/trunk/pom.xml Fri Nov  4 12:45:51 2011
@@ -165,25 +165,25 @@
 
       <plugin>
         <artifactId>maven-assembly-plugin</artifactId>
-
         <executions>
           <execution>
             <id>create-assembly</id>
             <!-- Must be last in phase "package" (else use "verify") -->
             <phase>package</phase>
             <goals><goal>single</goal></goals>
-	    <configuration>
-	      <!--
-	      <finalName>${assembly.root.name}</finalName>
-	      <appendAssemblyId>false</appendAssemblyId>
-	      -->
-	      <descriptors>
-		<descriptor>assembly.xml</descriptor>
-	  </descriptors>
-	    </configuration>
-	  </execution>
+            <configuration>
+              <!--
+	          <finalName>${assembly.root.name}</finalName>
+	          <appendAssemblyId>false</appendAssemblyId>
+	          -->
+	          <descriptors>
+		        <descriptor>assembly.xml</descriptor>
+              </descriptors>
+	        </configuration>
+          </execution>
         </executions>
       </plugin>
+
     </plugins>
 
     <resources>
@@ -196,7 +196,7 @@
 
       <resource>
         <directory>vocabularies</directory>
-	<targetPath>vocabularies</targetPath>
+        <targetPath>vocabularies</targetPath>
         <filtering>false</filtering>
         <includes>
           <include>assembler.n3</include>
@@ -218,5 +218,4 @@
     <!-- <outputDirectory>${project.build.directory}/site</outputDirectory> -->
   </reporting>
 
-
 </project>

Modified: incubator/jena/Jena2/jena/trunk/src/main/java/jena/cmdline/CmdLineUtils.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/jena/trunk/src/main/java/jena/cmdline/CmdLineUtils.java?rev=1197540&r1=1197539&r2=1197540&view=diff
==============================================================================
--- incubator/jena/Jena2/jena/trunk/src/main/java/jena/cmdline/CmdLineUtils.java (original)
+++ incubator/jena/Jena2/jena/trunk/src/main/java/jena/cmdline/CmdLineUtils.java Fri Nov  4 12:45:51 2011
@@ -18,9 +18,14 @@ public class CmdLineUtils
 
     static public void setLog4jConfiguration() 
     {
+		setLog4jConfiguration("jena-log4j.properties") ;
+    }
+    
+    static public void setLog4jConfiguration(String filename) 
+    {
     	if ( System.getProperty("log4j.configuration") == null ) 
     	{
-        	System.setProperty("log4j.configuration", "jena-log4j.properties") ;    		
+        	System.setProperty("log4j.configuration", filename) ;    		
     	}
     }
 }

Modified: incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/rdf/arp/MoreTests.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/rdf/arp/MoreTests.java?rev=1197540&r1=1197539&r2=1197540&view=diff
==============================================================================
--- incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/rdf/arp/MoreTests.java (original)
+++ incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/rdf/arp/MoreTests.java Fri Nov  4 12:45:51 2011
@@ -153,8 +153,7 @@ public class MoreTests extends TestCase 
 		FileReader r = new FileReader(
 				"testing/wg/rdfms-syntax-incomplete/test001.rdf");
 		if (r.getEncoding().startsWith("UTF")) {
-			System.err
-					.println("WARNING: Encoding mismatch tests not executed on platform with default UTF encoding.");
+			logger.warn("Encoding mismatch tests not executed on platform with default UTF encoding.");
 			return;
 		}
 		rdr.setErrorHandler(this);

Modified: incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/rdf/arp/StAX2ModelTest.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/rdf/arp/StAX2ModelTest.java?rev=1197540&r1=1197539&r2=1197540&view=diff
==============================================================================
--- incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/rdf/arp/StAX2ModelTest.java (original)
+++ incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/rdf/arp/StAX2ModelTest.java Fri Nov  4 12:45:51 2011
@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
 
 import com.hp.hpl.jena.rdf.model.Model;
 import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.impl.RDFDefaultErrorHandler;
 import com.hp.hpl.jena.regression.testReaderInterface;
 import javax.xml.stream.XMLInputFactory;
 
@@ -1147,9 +1148,20 @@ public class StAX2ModelTest extends Test
         this.file = "testing/" + dir + file;
     }
 
+    private boolean errorHanderFlag;
+    @Override
+    public void setUp() {
+    	errorHanderFlag = RDFDefaultErrorHandler.silent; 
+    	RDFDefaultErrorHandler.silent = true; // JENA-36
+    }
+    
+    @Override
+    public void tearDown() {
+    	RDFDefaultErrorHandler.silent = errorHanderFlag;    	
+    }
+    
     @Override
     public void runTest() throws Exception {
-
         Model expected = ModelFactory.createDefaultModel();
         Model got = ModelFactory.createDefaultModel();
         

Modified: incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/test/TestPackage.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/test/TestPackage.java?rev=1197540&r1=1197539&r2=1197540&view=diff
==============================================================================
--- incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/test/TestPackage.java (original)
+++ incubator/jena/Jena2/jena/trunk/src/test/java/com/hp/hpl/jena/test/TestPackage.java Fri Nov  4 12:45:51 2011
@@ -22,7 +22,8 @@ import com.hp.hpl.jena.assembler.test.Te
 public class TestPackage extends TestCase{
 
     static {
-    	setLog4jConfiguration() ;
+    	// better to have a separate log4j.properties for testing, see JENA-36
+    	setLog4jConfiguration("log4j.properties") ;
     }
 	
     static public TestSuite suite() {

Modified: incubator/jena/Jena2/jena/trunk/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/jena/trunk/src/test/resources/log4j.properties?rev=1197540&r1=1197539&r2=1197540&view=diff
==============================================================================
--- incubator/jena/Jena2/jena/trunk/src/test/resources/log4j.properties (original)
+++ incubator/jena/Jena2/jena/trunk/src/test/resources/log4j.properties Fri Nov  4 12:45:51 2011
@@ -7,6 +7,10 @@ log4j.rootLogger=INFO, stderr
 
 # Base of all Jena classes
 log4j.logger.com.hp.hpl.jena=INFO
+log4j.logger.com.hp.hpl.jena.graph.impl.LiteralLabelImpl=ERROR
+log4j.logger.com.hp.hpl.jena.rdf.arp.MoreTests=FATAL
+log4j.logger.com.hp.hpl.jena.regression.testReaderInterface=FATAL
+log4j.logger.com.hp.hpl.jena.rdf.model.impl.RDFDefaultErrorHandler=FATAL
 
 # Example of switching on debug level logging for part of tree
 # log4j.logger.com.hp.hpl.jena.graph.test=debug