[logback-dev] svn commit: r1873 - in logback/trunk/logback-access: . src/main/java/ch/qos/logback/access/db/dialect src/test/input src/test/input/integration src/test/input/integration/db src/test/java/ch/qos/logback/access/db

noreply.ceki at qos.ch noreply.ceki at qos.ch
Fri Oct 24 23:22:22 CEST 2008


Author: ceki
Date: Fri Oct 24 23:22:21 2008
New Revision: 1873

Added:
   logback/trunk/logback-access/src/main/java/ch/qos/logback/access/db/dialect/msSQLServer.sql
      - copied, changed from r1859, /logback/trunk/logback-access/src/main/java/ch/qos/logback/access/db/dialect/mssql.sql
   logback/trunk/logback-access/src/test/input/
   logback/trunk/logback-access/src/test/input/integration/
   logback/trunk/logback-access/src/test/input/integration/db/
   logback/trunk/logback-access/src/test/input/integration/db/mysql-with-driver.xml
   logback/trunk/logback-access/src/test/input/integration/db/oracle10g-with-driver.xml
   logback/trunk/logback-access/src/test/input/integration/db/oracle11g-with-driver.xml
   logback/trunk/logback-access/src/test/input/integration/db/postgresql-with-driver.xml
   logback/trunk/logback-access/src/test/input/integration/db/sqlserver-with-driver.xml
   logback/trunk/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderIntegrationTest.java
Removed:
   logback/trunk/logback-access/src/main/java/ch/qos/logback/access/db/dialect/mssql.sql
Modified:
   logback/trunk/logback-access/pom.xml

Log:
Related to LBCORE-15

- doing integration tests with various databases for logback-access

Modified: logback/trunk/logback-access/pom.xml
==============================================================================
--- logback/trunk/logback-access/pom.xml	(original)
+++ logback/trunk/logback-access/pom.xml	Fri Oct 24 23:22:21 2008
@@ -1,4 +1,6 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
 	<parent>
 		<groupId>ch.qos.logback</groupId>
@@ -21,7 +23,8 @@
 			a line return in the description.
 			The generated jar will contain a corrupt MANIFEST file.
 		-->
-		Logback: the generic, reliable, fast and flexible logging library for Java.
+		Logback: the generic, reliable, fast and flexible logging
+		library for Java.
 	</description>
 	<licenses>
 		<license>
@@ -48,28 +51,28 @@
 			<groupId>tomcat</groupId>
 			<artifactId>catalina</artifactId>
 			<scope>compile</scope>
-      <optional>true</optional>
+			<optional>true</optional>
 		</dependency>
 
 		<dependency>
 			<groupId>org.mortbay.jetty</groupId>
 			<artifactId>jetty</artifactId>
 			<scope>compile</scope>
-      <optional>true</optional>
+			<optional>true</optional>
 		</dependency>
 
 		<dependency>
 			<groupId>org.mortbay.jetty</groupId>
 			<artifactId>servlet-api-2.5</artifactId>
 			<scope>compile</scope>
-      <optional>true</optional>
+			<optional>true</optional>
 		</dependency>
 
 		<dependency>
 			<groupId>janino</groupId>
 			<artifactId>janino</artifactId>
 			<scope>compile</scope>
-      <optional>true</optional>
+			<optional>true</optional>
 		</dependency>
 
 		<dependency>
@@ -77,14 +80,14 @@
 			<artifactId>hsqldb</artifactId>
 			<scope>test</scope>
 		</dependency>
-		
+
 		<dependency>
 			<groupId>javax.mail</groupId>
 			<artifactId>mail</artifactId>
 			<scope>compile</scope>
-      <optional>true</optional>
+			<optional>true</optional>
 		</dependency>
-		
+
 	</dependencies>
 
 	<build>
@@ -103,9 +106,9 @@
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-surefire-plugin</artifactId>
 				<configuration>
-          <fork>once</fork>                 
-          <reportFormat>plain</reportFormat>
-          <disableXmlReport>true</disableXmlReport>
+					<fork>once</fork>
+					<reportFormat>plain</reportFormat>
+					<disableXmlReport>true</disableXmlReport>
 					<excludes>
 						<exclude>**/AllTest.java</exclude>
 						<exclude>**/PackageTest.java</exclude>
@@ -129,7 +132,47 @@
 				</executions>
 			</plugin>
 		</plugins>
-
 	</build>
+	
+	
+	<profiles>
+		<profile>
+			<!-- Integration tests require the host-orion profile -->
+			<id>host-orion</id>
+
+			<dependencies>
+				<dependency>
+					<groupId>mysql</groupId>
+					<artifactId>mysql-connector-java</artifactId>
+					<version>5.0.8</version>
+					<scope>test</scope>
+				</dependency>
+
+				<dependency>
+					<groupId>postgresql</groupId>
+					<artifactId>postgresql</artifactId>
+					<version>8.2-507.jdbc3</version>
+				</dependency>
+
+				<!-- locally installed artifact -->
+				<dependency>
+					<groupId>com.microsoft.sqlserver</groupId>
+					<artifactId>sqljdbc</artifactId>
+					<version>2.0</version>
+					<scope>test</scope>
+				</dependency>
+				<!-- locally installed artifact -->
+				<dependency>
+					<groupId>com.oracle</groupId>
+					<artifactId>ojdbc14</artifactId>
+					<version>10.2.0.1</version>
+					<scope>test</scope>
+				</dependency>
+			</dependencies>
+
+		</profile>
+
+	</profiles>
+
 
 </project>
\ No newline at end of file

Copied: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/db/dialect/msSQLServer.sql (from r1859, /logback/trunk/logback-access/src/main/java/ch/qos/logback/access/db/dialect/mssql.sql)
==============================================================================
--- /logback/trunk/logback-access/src/main/java/ch/qos/logback/access/db/dialect/mssql.sql	(original)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/db/dialect/msSQLServer.sql	Fri Oct 24 23:22:21 2008
@@ -4,7 +4,7 @@
 DROP TABLE access_event_header
 DROP TABLE access_event 
 
-CREATE TABLE logging_event 
+CREATE TABLE access_event 
   ( 
     timestmp          BIGINT NOT NULL,
    	requestURI        VARCHAR(254),

Added: logback/trunk/logback-access/src/test/input/integration/db/mysql-with-driver.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-access/src/test/input/integration/db/mysql-with-driver.xml	Fri Oct 24 23:22:21 2008
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<configuration>
+
+	<appender name="DB" class="ch.qos.logback.access.db.DBAppender">
+		<connectionSource
+			class="ch.qos.logback.core.db.DriverManagerConnectionSource">
+			<driverClass>com.mysql.jdbc.Driver</driverClass>
+			<url>jdbc:mysql://localhost:3306/logback</url>
+			<user>root</user>
+			<password></password>
+		</connectionSource>
+	</appender>
+
+
+	<appender-ref ref="DB" />
+</configuration>

Added: logback/trunk/logback-access/src/test/input/integration/db/oracle10g-with-driver.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-access/src/test/input/integration/db/oracle10g-with-driver.xml	Fri Oct 24 23:22:21 2008
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<configuration>
+
+	<appender name="DB" class="ch.qos.logback.access.db.DBAppender">
+		<connectionSource
+			class="ch.qos.logback.core.db.DriverManagerConnectionSource">
+			<driverClass>oracle.jdbc.OracleDriver</driverClass>
+			<url>jdbc:oracle:thin:@localhost:1522:xe</url>
+			<user>hr</user>
+			<password>hr</password>
+		</connectionSource>
+	</appender>
+
+
+	<appender-ref ref="DB" />
+</configuration>

Added: logback/trunk/logback-access/src/test/input/integration/db/oracle11g-with-driver.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-access/src/test/input/integration/db/oracle11g-with-driver.xml	Fri Oct 24 23:22:21 2008
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<configuration>
+
+	<appender name="DB" class="ch.qos.logback.access.db.DBAppender">
+		<connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource">
+			<driverClass>oracle.jdbc.OracleDriver</driverClass>
+			<url>jdbc:oracle:thin:@localhost:1521:orcl</url>
+			<user>SCOTT</user>
+			<password>SCOTT</password>
+		</connectionSource>
+	</appender>
+	
+	
+	<appender-ref ref="DB" />
+	
+</configuration>

Added: logback/trunk/logback-access/src/test/input/integration/db/postgresql-with-driver.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-access/src/test/input/integration/db/postgresql-with-driver.xml	Fri Oct 24 23:22:21 2008
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<configuration>
+
+	<appender name="DB" class="ch.qos.logback.access.db.DBAppender">
+		<connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource">
+			<driverClass>org.postgresql.Driver</driverClass>
+			<url>jdbc:postgresql://192.168.1.5:5432/test</url>
+			<user>logback</user>
+			<password>logback</password>
+		</connectionSource>
+	</appender>
+	
+	<appender-ref ref="DB" />
+	
+</configuration>

Added: logback/trunk/logback-access/src/test/input/integration/db/sqlserver-with-driver.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-access/src/test/input/integration/db/sqlserver-with-driver.xml	Fri Oct 24 23:22:21 2008
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<configuration>
+
+	<appender name="DB" class="ch.qos.logback.access.db.DBAppender">
+		<connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource">
+			<driverClass>com.microsoft.sqlserver.jdbc.SQLServerDriver</driverClass>
+			<url>jdbc:sqlserver://localhost:1987;databaseName=logback;</url>
+			<user>logback</user>
+			<password>logback</password>
+		</connectionSource>
+	</appender>
+	
+
+    <appender-ref ref="DB" />
+</configuration>

Added: logback/trunk/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderIntegrationTest.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderIntegrationTest.java	Fri Oct 24 23:22:21 2008
@@ -0,0 +1,136 @@
+package ch.qos.logback.access.db;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.InetAddress;
+import java.util.Random;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import ch.qos.logback.access.dummy.DummyRequest;
+import ch.qos.logback.access.dummy.DummyResponse;
+import ch.qos.logback.access.dummy.DummyServerAdapter;
+import ch.qos.logback.access.joran.JoranConfigurator;
+import ch.qos.logback.access.spi.AccessContext;
+import ch.qos.logback.access.spi.AccessEvent;
+import ch.qos.logback.core.Appender;
+import ch.qos.logback.core.joran.spi.JoranException;
+import ch.qos.logback.core.status.Status;
+import ch.qos.logback.core.util.StatusPrinter;
+
+public class DBAppenderIntegrationTest {
+
+  static String LOCAL_HOST_NAME;
+  static String[] CONFORMING_HOST_LIST = new String[] { "Orion" };
+
+  int diff = new Random(System.nanoTime()).nextInt(10000);
+  AccessContext context = new AccessContext();
+  
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {
+    InetAddress localhostIA = InetAddress.getLocalHost();
+    LOCAL_HOST_NAME = localhostIA.getHostName();
+  }
+
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception {
+  }
+
+  @Before
+  public void setUp() throws Exception {
+  }
+
+  @After
+  public void tearDown() throws Exception {
+
+  }
+
+  public void doTest(String configFile) throws JoranException {
+    JoranConfigurator configurator = new JoranConfigurator();
+    configurator.setContext(context);
+    configurator.doConfigure(configFile);
+
+    Appender<AccessEvent> appender = context.getAppender("DB");
+    
+    for (int i = 0; i < 10; i++) {
+      AccessEvent event = createAccessEvent();
+      appender.doAppend(event);
+    }
+    
+    StatusPrinter.print(context);
+    
+    // check that there were no errors
+    assertEquals(Status.INFO,  context.getStatusManager().getLevel());
+    
+  }
+  
+  static boolean isConformingHost() {
+    for (String conformingHost : CONFORMING_HOST_LIST) {
+      if (conformingHost.equalsIgnoreCase(LOCAL_HOST_NAME)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  @Test
+  public void sqlserver() throws Exception {
+    // perform test only on conforming hosts
+    if (!isConformingHost()) {
+      return;
+    }
+    doTest("src/test/input/integration/db/sqlserver-with-driver.xml");
+  }
+
+  @Test
+  public void oracle10g() throws Exception {
+    // perform test only on conforming hosts
+    if (!isConformingHost()) {
+      return;
+    }
+    doTest("src/test/input/integration/db/oracle10g-with-driver.xml");
+  }
+
+  @Test
+  @Ignore
+  public void oracle11g() throws Exception {
+    // perform test only on conforming hosts
+    if (!isConformingHost()) {
+      return;
+    }
+    doTest("src/test/input/integration/db/oracle11g-with-driver.xml");
+  }
+  
+  @Test
+  public void mysql() throws Exception {
+    // perform test only on conforming hosts
+    if (!isConformingHost()) {
+      return;
+    }
+    doTest("src/test/input/integration/db/mysql-with-driver.xml");
+  }
+  
+  @Test
+  public void postgres() throws Exception {
+    // perform test only on conforming hosts
+    if (!isConformingHost()) {
+      return;
+    }
+    doTest("src/test/input/integration/db/postgresql-with-driver.xml");
+  }
+  
+  private AccessEvent createAccessEvent() {
+    DummyRequest request = new DummyRequest();
+    DummyResponse response = new DummyResponse();
+    DummyServerAdapter adapter = new DummyServerAdapter(request, response);
+
+    AccessEvent ae = new AccessEvent(request, response, adapter);
+    return ae;
+  }
+  
+}


More information about the logback-dev mailing list