[slf4j-dev] svn commit: r706 - in slf4j/trunk/slf4j-osgi-test-bundle: . src/main/java/org/slf4j/osgi/test src/main/java/org/slf4j/osgi/test/service src/main/resources/META-INF

jconlon at slf4j.org jconlon at slf4j.org
Sat Feb 3 01:22:50 CET 2007


Author: jconlon
Date: Sat Feb  3 01:22:49 2007
New Revision: 706

Added:
   slf4j/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/CommonsLoggingTester.java
   slf4j/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/ProbeImpl.java
   slf4j/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/service/
   slf4j/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/service/Probe.java
Modified:
   slf4j/trunk/slf4j-osgi-test-bundle/pom.xml
   slf4j/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/Activator.java
   slf4j/trunk/slf4j-osgi-test-bundle/src/main/resources/META-INF/MANIFEST.MF

Log:
Test bundle now registers an OSGi Probe Service. 
Probe service will offer third party bundles the ability to test accessability and functionality of imported sl4j packages.

Modified: slf4j/trunk/slf4j-osgi-test-bundle/pom.xml
==============================================================================
--- slf4j/trunk/slf4j-osgi-test-bundle/pom.xml	(original)
+++ slf4j/trunk/slf4j-osgi-test-bundle/pom.xml	Sat Feb  3 01:22:49 2007
@@ -35,6 +35,16 @@
 			<version>${project.version}</version>
 			<scope>provided</scope>
 		</dependency>
+		
+		<!-- To get org.apache.commons.logging package for
+		 commons logging testing.-->
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>jcl104-over-slf4j</artifactId>
+			<version>${project.version}</version>
+			<scope>provided</scope>
+		</dependency>
+		
 		<dependency>
       		<groupId>org.apache.felix</groupId>
       		<artifactId>org.osgi.core</artifactId>

Modified: slf4j/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/Activator.java
==============================================================================
--- slf4j/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/Activator.java	(original)
+++ slf4j/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/Activator.java	Sat Feb  3 01:22:49 2007
@@ -40,6 +40,9 @@
 import org.slf4j.LoggerFactory;
 import org.slf4j.Marker;
 import org.slf4j.MarkerFactory;
+import org.slf4j.osgi.test.service.Probe;
+
+import java.util.Hashtable;
 
 /**
  * <code>Activator</code> implements a simple bundle to test OSGi slf4j
@@ -68,6 +71,11 @@
 	public void start(BundleContext bundleContext) throws Exception {
 		log.info("Starting to listen for service events.");
 		bundleContext.addServiceListener(this);
+		
+		Probe probe = new ProbeImpl();
+		Hashtable props = new Hashtable();
+		props.put("description", "Service for testing slf4j components.");
+		bundleContext.registerService(Probe.class.getName(),probe, props);
 
 		test1();
 		test2();

Added: slf4j/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/CommonsLoggingTester.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/CommonsLoggingTester.java	Sat Feb  3 01:22:49 2007
@@ -0,0 +1,114 @@
+/* 
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * 
+ * All rights reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ * 
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * 
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+
+package org.slf4j.osgi.test;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * <code>CommonsLoggingTester</code> tests org.apache.commons.logging functionality.
+ * 
+ * @author John Conlon
+ */
+public class CommonsLoggingTester {
+
+	boolean testCommonslogging() throws Exception {
+		testIsEnabledAPI();
+		testPrintAPI();
+		return true;
+	}
+
+	public void testIsEnabledAPI() {
+		// assume that we are running over slf4j-simple
+		Log log = LogFactory.getLog(CommonsLoggingTester.class);
+		assertFalse("Trace was enabled", log.isTraceEnabled());
+		assertFalse("Debug was enabled", log.isDebugEnabled());
+		assertTrue("Info was not enabled", log.isInfoEnabled());
+		assertTrue("Warn was not enabled", log.isWarnEnabled());
+		assertTrue("Error was not enabled", log.isErrorEnabled());
+		assertTrue("Fatal was not enabled", log.isFatalEnabled());
+	}
+
+	private void assertFalse(String failureMessage, boolean value) {
+		if (value) {
+			throw new IllegalStateException(failureMessage);
+		}
+	}
+
+	private void assertTrue(String failureMessage, boolean value) {
+		if (!value) {
+			throw new IllegalStateException(failureMessage);
+		}
+	}
+
+	public void testPrintAPI() {
+		Log log = LogFactory.getLog(CommonsLoggingTester.class);
+		Exception e = new Exception("just testing");
+
+		log.trace(null);
+		log.trace("trace message");
+
+		log.debug(null);
+		log.debug("debug message");
+
+		log.info(null);
+		log.info("info  message");
+
+		log.warn(null);
+		log.warn("warn message");
+
+		log.error(null);
+		log.error("error message");
+
+		log.fatal(null);
+		log.fatal("fatal message");
+
+		log.trace(null, e);
+		log.trace("trace message", e);
+
+		log.debug(null, e);
+		log.debug("debug message", e);
+
+		log.info(null, e);
+		log.info("info  message", e);
+
+		log.warn(null, e);
+		log.warn("warn message", e);
+
+		log.error(null, e);
+		log.error("error message", e);
+
+		log.fatal(null, e);
+		log.fatal("fatal message", e);
+	}
+}

Added: slf4j/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/ProbeImpl.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/ProbeImpl.java	Sat Feb  3 01:22:49 2007
@@ -0,0 +1,55 @@
+/* 
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * 
+ * All rights reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ * 
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * 
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+
+package org.slf4j.osgi.test;
+
+import org.slf4j.osgi.test.service.Probe;
+
+/**
+ * <code>ProbeImpl</code> a simple implementation of the Probe interface for testing
+ * Slf4j components.
+ *
+ * @author John Conlon
+ */
+public class ProbeImpl implements Probe{
+
+	/**
+	 * 
+	 * @throws ClassNotFoundException If there is not a bundle exporting
+	 * the org.apache.commons.logging package  
+	 * 
+	 */
+	public boolean testCommonslogging() throws Exception{
+		return new CommonsLoggingTester().testCommonslogging();
+	}
+
+}

Added: slf4j/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/service/Probe.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-osgi-test-bundle/src/main/java/org/slf4j/osgi/test/service/Probe.java	Sat Feb  3 01:22:49 2007
@@ -0,0 +1,55 @@
+/* 
+ * Copyright (c) 2004-2005 SLF4J.ORG
+ * 
+ * All rights reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute, and/or sell copies of  the Software, and to permit persons
+ * to whom  the Software is furnished  to do so, provided  that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the  Software and  that both  the above  copyright notice(s)  and this
+ * permission notice appear in supporting documentation.
+ * 
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF  THIRD PARTY  RIGHTS. IN  NO EVENT  SHALL THE  COPYRIGHT  HOLDER OR
+ * HOLDERS  INCLUDED IN  THIS  NOTICE BE  LIABLE  FOR ANY  CLAIM, OR  ANY
+ * SPECIAL INDIRECT  OR CONSEQUENTIAL DAMAGES, OR  ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS  OF USE, DATA OR PROFITS, WHETHER  IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE  OR OTHER TORTIOUS  ACTION, ARISING OUT OF  OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * 
+ * Except as  contained in  this notice, the  name of a  copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ *
+ */
+
+package org.slf4j.osgi.test.service;
+
+/**
+ * <code>Probe</code> is a service for testing accessibility of
+ * Slf4j components from the test bundle.
+ * 
+ * @author John Conlon
+ * @version $Rev$, $Date$
+ */
+public interface Probe {
+	
+	/**
+	 * 
+	 * testCommonslogging 
+	 *
+	 * @return true if all the tests were executed.
+	 * @throws ClassNotFoundError if a org.apache.commons.logging package
+	 * could not be dynamically imported from the OSGi runtime.
+	 * @throws Exception if testing fails
+	 */
+	boolean testCommonslogging() throws Exception;
+
+}

Modified: slf4j/trunk/slf4j-osgi-test-bundle/src/main/resources/META-INF/MANIFEST.MF
==============================================================================
--- slf4j/trunk/slf4j-osgi-test-bundle/src/main/resources/META-INF/MANIFEST.MF	(original)
+++ slf4j/trunk/slf4j-osgi-test-bundle/src/main/resources/META-INF/MANIFEST.MF	Sat Feb  3 01:22:49 2007
@@ -4,4 +4,6 @@
 Bundle-Name: slf4j-osgi-test-bundle
 Bundle-Vendor: SLF4J.ORG
 Import-Package: org.osgi.framework,org.slf4j;version="[1.3,1.4)"
+DynamicImport-Package: org.apache.commons.logging;version="1.0.4"
+Export-Package: org.slf4j.osgi.test.service
 Bundle-Activator: org.slf4j.osgi.test.Activator



More information about the slf4j-dev mailing list