[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v0.9.18-110-ge6af6bd

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Tue Mar 23 14:15:56 CET 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".

The branch, master has been updated
       via  e6af6bd2f69de46eed5febf9bb0de8613469a713 (commit)
      from  8ad8f15265b86671678d40c6109245327ef1f9f7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=e6af6bd2f69de46eed5febf9bb0de8613469a713
http://github.com/ceki/logback/commit/e6af6bd2f69de46eed5febf9bb0de8613469a713

commit e6af6bd2f69de46eed5febf9bb0de8613469a713
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Tue Mar 23 14:15:04 2010 +0100

    - Adding support for H2 database

diff --git a/logback-classic/pom.xml b/logback-classic/pom.xml
index 41559e0..9db2104 100644
--- a/logback-classic/pom.xml
+++ b/logback-classic/pom.xml
@@ -82,6 +82,12 @@
     </dependency>
 
     <dependency>
+      <groupId>com.h2database</groupId>
+      <artifactId>h2</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
       <groupId>postgresql</groupId>
       <artifactId>postgresql</artifactId>
       <scope>test</scope>      
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderH2Test.java
similarity index 89%
copy from logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTest.java
copy to logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderH2Test.java
index ef86c44..3ba8e00 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderH2Test.java
@@ -31,21 +31,23 @@ import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.classic.spi.ILoggingEvent;
 import ch.qos.logback.classic.spi.LoggingEvent;
 import ch.qos.logback.core.db.DriverManagerConnectionSource;
+import ch.qos.logback.core.util.StatusPrinter;
 
-public class DBAppenderTest  {
+public class DBAppenderH2Test  {
 
   LoggerContext lc;
   Logger logger;
   DBAppender appender;
   DriverManagerConnectionSource connectionSource;
 
-  DBAppenderTestFixture dbAppenderTestFixture;
+  DBAppenderH2TestFixture dbAppenderH2TestFixture;
   
   @Before
   public void setUp() throws SQLException {
-    dbAppenderTestFixture = new DBAppenderTestFixture();
-    dbAppenderTestFixture.setUp();
+    dbAppenderH2TestFixture = new DBAppenderH2TestFixture();
 
+    dbAppenderH2TestFixture.setUp();
+    
     lc = new LoggerContext();
     lc.setName("default");
     logger = lc.getLogger("root");
@@ -54,10 +56,12 @@ public class DBAppenderTest  {
     appender.setContext(lc);
     connectionSource = new DriverManagerConnectionSource();
     connectionSource.setContext(lc);
-    connectionSource.setDriverClass(DBAppenderTestFixture.HSQLDB_DRIVER_CLASS);
-    connectionSource.setUrl(dbAppenderTestFixture.url);
-    connectionSource.setUser(dbAppenderTestFixture.user);
-    connectionSource.setPassword(dbAppenderTestFixture.password);
+    connectionSource.setDriverClass(DBAppenderH2TestFixture.H2_DRIVER_CLASS);
+    connectionSource.setUrl(dbAppenderH2TestFixture.url);
+    connectionSource.setUser(dbAppenderH2TestFixture.user);
+    connectionSource.setPassword(dbAppenderH2TestFixture.password);
+    
+
     connectionSource.start();
     appender.setConnectionSource(connectionSource);
     appender.start();
@@ -69,7 +73,7 @@ public class DBAppenderTest  {
     lc = null;
     appender = null;
     connectionSource = null;
-    dbAppenderTestFixture.tearDown();
+    dbAppenderH2TestFixture.tearDown();
   }
 
   @Test
@@ -77,7 +81,8 @@ public class DBAppenderTest  {
     ILoggingEvent event = createLoggingEvent();
 
     appender.append(event);
-    //StatusPrinter.print(lc.getStatusManager());
+    
+    StatusPrinter.print(lc);
     
     Statement stmt = connectionSource.getConnection().createStatement();
     ResultSet rs = null;
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTestFixture.java b/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderH2TestFixture.java
similarity index 64%
copy from logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTestFixture.java
copy to logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderH2TestFixture.java
index 46cfd2b..8727b25 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTestFixture.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderH2TestFixture.java
@@ -15,98 +15,70 @@ package ch.qos.logback.classic.db;
 
 import static org.junit.Assert.assertNotNull;
 
-import java.io.PrintWriter;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Properties;
 
-import org.hsqldb.Server;
-import org.hsqldb.ServerConstants;
-import org.hsqldb.jdbcDriver;
+import org.h2.Driver;
 
-public class DBAppenderTestFixture  {
+import ch.qos.logback.core.testUtil.RandomUtil;
 
-  public static final String HSQLDB_DRIVER_CLASS = "org.hsqldb.jdbcDriver";
+public class DBAppenderH2TestFixture  {
+
+  public enum H2Mode {
+    MEM, FILE, NET;
+  }
+  
+  public static final String H2_DRIVER_CLASS = "org.h2.Driver";
   // String serverProps;
   String url = null;
   String user = "sa";
   String password = "";
-  Server server;
 
   // boolean isNetwork = true;
-  HsqlMode mode = HsqlMode.MEM;
+  H2Mode mode = H2Mode.MEM;
 
-  public DBAppenderTestFixture() {
+  int diff = RandomUtil.getPositiveInt();
+  
+  public DBAppenderH2TestFixture() {
   }
 
+  Connection connection;
+  
   public void setUp() throws SQLException {
 
     switch (mode) {
     case NET:
-      url = "jdbc:hsqldb:hsql://localhost:4808/test";
+      url = "jdbc:h2:tcp://localhost:4808/test";
       break;
     case MEM:
-      url = "jdbc:hsqldb:mem:test;sql.enforce_strict_size=true";
-      server = new Server();
-      server.setDatabaseName(0, "test");
-      server.setDatabasePath(0, url);
-      server.setLogWriter(new PrintWriter(System.out));
-      server.setErrWriter(new PrintWriter(System.out));
-      server.setTrace(false);
-      server.setSilent(false);
-      server.start();
-
+      url = "jdbc:h2:mem:test"+diff;
       break;
     case FILE:
       url = "jdbc:hsqldb:file:test;sql.enforce_strict_size=true";
       break;
 
     }
-
-    // try {
-    // Class.forName(DRIVER_CLASS);
-    // } catch (Exception e) {
-    // e.printStackTrace();
-    // System.out.println(this + ".setUp() error: " + e.getMessage());
-    // }
-    // Thread.yield();
-    System.out.println(server.getState());
-
-    int waitCount = 0;
-    while (server.getState() != ServerConstants.SERVER_STATE_ONLINE
-        && waitCount < 5) {
-      try {
-        waitCount++;
-        Thread.sleep(1);
-      } catch (InterruptedException e) {
-      }
-    }
+    connection = newConnection();
     createTables();
   }
 
   public void tearDown() throws SQLException {
     dropTables();
-
-    if (mode == HsqlMode.MEM) {
-      server.stop();
-      server = null;
-    }
+    connection.close();
   }
 
   Connection newConnection() throws SQLException {
-    jdbcDriver driver = new jdbcDriver();
+    org.h2.Driver driver = Driver.load();
     Properties props = new Properties();
     props.setProperty("user", user);
     props.setProperty("password", password);
     return driver.connect(url, props);
-
-    // return DriverManager.getConnection(url, user, password);
   }
 
   private void createTables() throws SQLException {
-    Connection conn = newConnection();
-    assertNotNull(conn);
+    assertNotNull(connection);
     StringBuffer buf = new StringBuffer();
     buf.append("CREATE TABLE logging_event (");
     buf.append("timestmp BIGINT NOT NULL,");
@@ -120,7 +92,7 @@ public class DBAppenderTestFixture  {
     buf.append("caller_method VARCHAR(256), ");
     buf.append("caller_line CHAR(4), ");
     buf.append("event_id INT NOT NULL IDENTITY);");
-    query(conn, buf.toString());
+    executeQuery(connection, buf.toString());
 
     buf = new StringBuffer();
     buf.append("CREATE TABLE logging_event_property (");
@@ -129,7 +101,7 @@ public class DBAppenderTestFixture  {
     buf.append("mapped_value LONGVARCHAR,");
     buf.append("PRIMARY KEY(event_id, mapped_key),");
     buf.append("FOREIGN KEY (event_id) REFERENCES logging_event(event_id));");
-    query(conn, buf.toString());
+    executeQuery(connection, buf.toString());
 
     buf = new StringBuffer();
     buf.append("CREATE TABLE logging_event_exception (");
@@ -138,26 +110,24 @@ public class DBAppenderTestFixture  {
     buf.append("trace_line VARCHAR(256) NOT NULL,");
     buf.append("PRIMARY KEY(event_id, i),");
     buf.append("FOREIGN KEY (event_id) REFERENCES logging_event(event_id));");
-    query(conn, buf.toString());
+    executeQuery(connection, buf.toString());
   }
 
   private  void dropTables() throws SQLException {
-    Connection conn = newConnection();
     StringBuffer buf = new StringBuffer();
     buf.append("DROP TABLE logging_event_exception IF EXISTS;");
-    query(conn, buf.toString());
+    executeQuery(connection, buf.toString());
 
     buf = new StringBuffer();
     buf.append("DROP TABLE logging_event_property IF EXISTS;");
-    query(conn, buf.toString());
+    executeQuery(connection, buf.toString());
 
     buf = new StringBuffer();
     buf.append("DROP TABLE logging_event IF EXISTS;");
-    query(conn, buf.toString());
+    executeQuery(connection, buf.toString());
   }
 
-  private  void query(Connection conn, String expression) throws SQLException {
-
+  private  void executeQuery(Connection conn, String expression) throws SQLException {
     Statement st = null;
     st = conn.createStatement();
     int i = st.executeUpdate(expression);
@@ -167,7 +137,5 @@ public class DBAppenderTestFixture  {
     st.close();
   }
 
-  public enum HsqlMode {
-    MEM, FILE, NET;
-  }
+
 }
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderHSQLTest.java
similarity index 90%
rename from logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTest.java
rename to logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderHSQLTest.java
index ef86c44..51117cd 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderHSQLTest.java
@@ -32,19 +32,19 @@ import ch.qos.logback.classic.spi.ILoggingEvent;
 import ch.qos.logback.classic.spi.LoggingEvent;
 import ch.qos.logback.core.db.DriverManagerConnectionSource;
 
-public class DBAppenderTest  {
+public class DBAppenderHSQLTest  {
 
   LoggerContext lc;
   Logger logger;
   DBAppender appender;
   DriverManagerConnectionSource connectionSource;
 
-  DBAppenderTestFixture dbAppenderTestFixture;
+  DBAppenderHSQLTestFixture dbAppenderHSQLTestFixture;
   
   @Before
   public void setUp() throws SQLException {
-    dbAppenderTestFixture = new DBAppenderTestFixture();
-    dbAppenderTestFixture.setUp();
+    dbAppenderHSQLTestFixture = new DBAppenderHSQLTestFixture();
+    dbAppenderHSQLTestFixture.setUp();
 
     lc = new LoggerContext();
     lc.setName("default");
@@ -54,10 +54,10 @@ public class DBAppenderTest  {
     appender.setContext(lc);
     connectionSource = new DriverManagerConnectionSource();
     connectionSource.setContext(lc);
-    connectionSource.setDriverClass(DBAppenderTestFixture.HSQLDB_DRIVER_CLASS);
-    connectionSource.setUrl(dbAppenderTestFixture.url);
-    connectionSource.setUser(dbAppenderTestFixture.user);
-    connectionSource.setPassword(dbAppenderTestFixture.password);
+    connectionSource.setDriverClass(DBAppenderHSQLTestFixture.HSQLDB_DRIVER_CLASS);
+    connectionSource.setUrl(dbAppenderHSQLTestFixture.url);
+    connectionSource.setUser(dbAppenderHSQLTestFixture.user);
+    connectionSource.setPassword(dbAppenderHSQLTestFixture.password);
     connectionSource.start();
     appender.setConnectionSource(connectionSource);
     appender.start();
@@ -69,7 +69,7 @@ public class DBAppenderTest  {
     lc = null;
     appender = null;
     connectionSource = null;
-    dbAppenderTestFixture.tearDown();
+    dbAppenderHSQLTestFixture.tearDown();
   }
 
   @Test
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTestFixture.java b/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderHSQLTestFixture.java
similarity index 98%
rename from logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTestFixture.java
rename to logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderHSQLTestFixture.java
index 46cfd2b..1f6e00f 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTestFixture.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderHSQLTestFixture.java
@@ -25,7 +25,7 @@ import org.hsqldb.Server;
 import org.hsqldb.ServerConstants;
 import org.hsqldb.jdbcDriver;
 
-public class DBAppenderTestFixture  {
+public class DBAppenderHSQLTestFixture  {
 
   public static final String HSQLDB_DRIVER_CLASS = "org.hsqldb.jdbcDriver";
   // String serverProps;
@@ -37,7 +37,7 @@ public class DBAppenderTestFixture  {
   // boolean isNetwork = true;
   HsqlMode mode = HsqlMode.MEM;
 
-  public DBAppenderTestFixture() {
+  public DBAppenderHSQLTestFixture() {
   }
 
   public void setUp() throws SQLException {
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/db/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/db/PackageTest.java
index 6fdc4d3..869fe27 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/db/PackageTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/db/PackageTest.java
@@ -18,6 +18,6 @@ import org.junit.runners.Suite;
 import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(Suite.class)
- at SuiteClasses( {DBAppenderTest.class})
+ at SuiteClasses( {DBAppenderHSQLTest.class})
 public class PackageTest {
 }
\ No newline at end of file
diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/ConnectionSourceBase.java b/logback-core/src/main/java/ch/qos/logback/core/db/ConnectionSourceBase.java
index 55d8e8c..29a5dee 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/db/ConnectionSourceBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/db/ConnectionSourceBase.java
@@ -55,9 +55,9 @@ public abstract class ConnectionSourceBase extends ContextAwareBase implements C
       supportsGetGeneratedKeys = util.supportsGetGeneratedKeys(meta);
       supportsBatchUpdates = util.supportsBatchUpdates(meta);
       dialectCode = DBUtil.discoverSQLDialect(meta);
-      System.out.println("Driver name="+meta.getDriverName());
-      System.out.println("Driver version="+meta.getDriverVersion());
-      System.out.println("supportsGetGeneratedKeys="+supportsGetGeneratedKeys);
+      addInfo("Driver name="+meta.getDriverName());
+      addInfo("Driver version="+meta.getDriverVersion());
+      addInfo("supportsGetGeneratedKeys="+supportsGetGeneratedKeys);
       
     } catch (SQLException se) {
       addWarn("Could not discover the dialect to use.", se);
diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/DBAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/db/DBAppenderBase.java
index be8bc33..ed08712 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/db/DBAppenderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/db/DBAppenderBase.java
@@ -50,7 +50,6 @@ public abstract class DBAppenderBase<E> extends AppenderBase<E> {
           "DBAppender cannot function without a connection source");
     }
 
-    System.out.println(connectionSource.supportsGetGeneratedKeys());
     sqlDialect = DBUtil
         .getDialectFromCode(connectionSource.getSQLDialectCode());
     if (getGeneratedKeysMethod() != null) {
diff --git a/pom.xml b/pom.xml
index 942e470..f56f9ec 100755
--- a/pom.xml
+++ b/pom.xml
@@ -94,9 +94,14 @@
         <version>1.8.0.7</version>
       </dependency>
       <dependency>
-	<groupId>postgresql</groupId>
-	<artifactId>postgresql</artifactId>
-	<version>8.4-701.jdbc4</version>
+        <groupId>com.h2database</groupId>
+        <artifactId>h2</artifactId>
+        <version>1.2.132</version>
+      </dependency>
+      <dependency>
+        <groupId>postgresql</groupId>
+        <artifactId>postgresql</artifactId>
+        <version>8.4-701.jdbc4</version>
       </dependency> 
       <dependency>
         <groupId>org.apache.tomcat</groupId>

-----------------------------------------------------------------------

Summary of changes:
 logback-classic/pom.xml                            |    6 ++
 .../{DBAppenderTest.java => DBAppenderH2Test.java} |   25 +++--
 ...stFixture.java => DBAppenderH2TestFixture.java} |   90 ++++++-------------
 ...DBAppenderTest.java => DBAppenderHSQLTest.java} |   18 ++--
 ...Fixture.java => DBAppenderHSQLTestFixture.java} |    4 +-
 .../ch/qos/logback/classic/db/PackageTest.java     |    2 +-
 .../qos/logback/core/db/ConnectionSourceBase.java  |    6 +-
 .../ch/qos/logback/core/db/DBAppenderBase.java     |    1 -
 pom.xml                                            |   11 ++-
 9 files changed, 73 insertions(+), 90 deletions(-)
 copy logback-classic/src/test/java/ch/qos/logback/classic/db/{DBAppenderTest.java => DBAppenderH2Test.java} (89%)
 copy logback-classic/src/test/java/ch/qos/logback/classic/db/{DBAppenderTestFixture.java => DBAppenderH2TestFixture.java} (64%)
 rename logback-classic/src/test/java/ch/qos/logback/classic/db/{DBAppenderTest.java => DBAppenderHSQLTest.java} (90%)
 rename logback-classic/src/test/java/ch/qos/logback/classic/db/{DBAppenderTestFixture.java => DBAppenderHSQLTestFixture.java} (98%)


hooks/post-receive
-- 
Logback: the generic, reliable, fast and flexible logging framework.


More information about the logback-dev mailing list