You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by mi...@apache.org on 2010/08/12 17:34:30 UTC
svn commit: r984835 -
/openjpa/trunk/openjpa-integration/slf4j/src/test/java/org/apache/openjpa/integration/slf4j/TestLogFactory.java
Author: mikedd
Date: Thu Aug 12 15:34:30 2010
New Revision: 984835
URL: http://svn.apache.org/viewvc?rev=984835&view=rev
Log:
Testcase update with slf4j
Modified:
openjpa/trunk/openjpa-integration/slf4j/src/test/java/org/apache/openjpa/integration/slf4j/TestLogFactory.java
Modified: openjpa/trunk/openjpa-integration/slf4j/src/test/java/org/apache/openjpa/integration/slf4j/TestLogFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/slf4j/src/test/java/org/apache/openjpa/integration/slf4j/TestLogFactory.java?rev=984835&r1=984834&r2=984835&view=diff
==============================================================================
--- openjpa/trunk/openjpa-integration/slf4j/src/test/java/org/apache/openjpa/integration/slf4j/TestLogFactory.java (original)
+++ openjpa/trunk/openjpa-integration/slf4j/src/test/java/org/apache/openjpa/integration/slf4j/TestLogFactory.java Thu Aug 12 15:34:30 2010
@@ -21,24 +21,37 @@ package org.apache.openjpa.integration.s
import javax.persistence.EntityManager;
import org.apache.openjpa.lib.log.Log;
-import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+import org.apache.openjpa.lib.log.SLF4JLogFactory;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
/**
* Simple test case to verify SLF4JLogFactory is being loaded
*/
public class TestLogFactory extends SingleEMFTestCase {
-
+ String systemPropLog = null;
+
+ public void setUp() throws Exception {
+ // Maven users may disable logging via a global system prop - which breaks this testcase.
+ systemPropLog = System.getProperty("openjpa.Log");
+ System.getProperties().remove("openjpa.Log");
+ super.setUp();
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ if(systemPropLog != null) {
+ System.setProperty("openjpa.Log", systemPropLog);
+ }
+ }
+
public void testSLF4J() {
- OpenJPAEntityManagerFactorySPI emf = createNamedEMF("openjpa-integration-slf4j");
try {
EntityManager em = emf.createEntityManager();
-
// do some logging
- Log log = getLog();
+ Log log = getLog();
String logFactory = log.getClass().getName();
log.info("Log class=" + logFactory);
- assertTrue("SLF4JLogFactory", logFactory.indexOf("SLF4JLogFactory") != -1);
+ assertEquals(SLF4JLogFactory.LogAdapter.class.getName(), logFactory);
// next one should not be logged if using slf4j-simple binding - only INFO, WARN and ERROR
log.trace("TRACE level logging");
@@ -47,6 +60,11 @@ public class TestLogFactory extends Sing
closeEMF(emf);
}
}
-
+
+ public String getPersistenceUnitName() {
+ // override puName instead of creating our own EMF.
+ // getLog uses the SingleEMFTestCase's emf.
+ return "openjpa-integration-slf4j";
+ }
}