directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcon...@apache.org
Subject svn commit: r475991 - in /directory/sandbox/jconlon/osgi-mina: ./ mina-osgi-example-integration-test/ mina-osgi-example-integration-test/src/ mina-osgi-example-integration-test/src/main/ mina-osgi-example-integration-test/src/main/java/ mina-osgi-examp...
Date Thu, 16 Nov 2006 23:53:21 GMT
Author: jconlon
Date: Thu Nov 16 15:53:18 2006
New Revision: 475991

URL: http://svn.apache.org/viewvc?view=rev&rev=475991
Log:
adding osgi sample application and integration tests for mina

Added:
    directory/sandbox/jconlon/osgi-mina/README
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/   (with props)
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/   (with props)
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/pom.xml
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/main/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/main/java/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/main/resources/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/java/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/java/org/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/java/org/apache/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/java/org/apache/mina/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/java/org/apache/mina/osgi/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/java/org/apache/mina/osgi/example/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/java/org/apache/mina/osgi/example/chat/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/java/org/apache/mina/osgi/example/chat/test/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/java/org/apache/mina/osgi/example/chat/test/MinaOSGIExampleChatBundleTest.java
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/log4j.properties
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/org/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/org/apache/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/org/apache/mina/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/org/apache/mina/osgi/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/org/apache/mina/osgi/example/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/org/apache/mina/osgi/example/chat/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/org/apache/mina/osgi/example/chat/test/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/org/apache/mina/osgi/example/chat/test/MANIFEST.MF
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/pom.xml
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/ChatCommand.java
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/ChatProtocolHandler.java
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/BogusSSLContextFactory.java
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/BogusTrustManagerFactory.java
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/ChatClientSupport.java
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/SwingChatClientHandler.java
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/META-INF/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/META-INF/spring/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/META-INF/spring/serverContext-osgi.xml
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/META-INF/spring/serverContext.xml
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/org/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/org/apache/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/org/apache/mina/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/org/apache/mina/osgi/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/org/apache/mina/osgi/example/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/org/apache/mina/osgi/example/chat/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/org/apache/mina/osgi/example/chat/ssl/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/org/apache/mina/osgi/example/chat/ssl/bogus.cert   (with props)
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/java/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/java/org/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/java/org/apache/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/java/org/apache/mina/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/java/org/apache/mina/osgi/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/java/org/apache/mina/osgi/example/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/java/org/apache/mina/osgi/example/chat/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/java/org/apache/mina/osgi/example/chat/BeanIntegrationTest.java
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/java/org/apache/mina/osgi/example/chat/ChatCommandTest.java
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/resources/
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/resources/log4j.properties
    directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/resources/readme.txt
    directory/sandbox/jconlon/osgi-mina/pom.xml
Modified:
    directory/sandbox/jconlon/osgi-mina/   (props changed)

Propchange: directory/sandbox/jconlon/osgi-mina/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Nov 16 15:53:18 2006
@@ -0,0 +1 @@
+target

Added: directory/sandbox/jconlon/osgi-mina/README
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/README?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/README (added)
+++ directory/sandbox/jconlon/osgi-mina/README Thu Nov 16 15:53:18 2006
@@ -0,0 +1,16 @@
+Due to a bug* in maven the pom.xml in this directory fails to properly install
+the correct artifacts in the m2 repository. To build and install the subprojects
+please execute a mvn clean from this directory and build each subproject manually
+by changing directories to each of the subdirectories and executing a mvn install.
+
+The subprojects must be built in the following order:
+integration-osgi
+mina-osgi-example
+mina-osgi-example-integration-test.
+
+
+* This is truly a major bug with maven. Here it is folks
+http://jira.codehaus.org/browse/MNG-1682
+will everyone please go to the above Jira and
+vote to impeach this bug.. 
+

Propchange: directory/sandbox/jconlon/osgi-mina/mina-osgi-example/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Nov 16 15:53:18 2006
@@ -0,0 +1,5 @@
+target
+.settings
+.wtpmodules
+.classpath
+.project

Propchange: directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Nov 16 15:53:18 2006
@@ -0,0 +1,5 @@
+target
+.settings
+.wtpmodules
+.classpath
+.project

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/pom.xml?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/pom.xml (added)
+++ directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/pom.xml Thu Nov 16 15:53:18 2006
@@ -0,0 +1,210 @@
+<?xml version="1.0"?>
+<project>
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.apache.mina.osgi</groupId>
+		<artifactId>build</artifactId>
+		<version>1.1.0-SNAPSHOT</version>
+	</parent>
+
+	<description>
+        OSGi integration tests for the mina-osgi-example chat service and client. 
+        </description>
+	<artifactId>mina-osgi-example-integration-test</artifactId>
+	<name>${pom.artifactId} suite</name>
+
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>3.8.1</version>
+			<scope>test</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>javax.servlet</artifactId>
+			<version>0.8.0-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.osgi.compendium</artifactId>
+			<version>0.8.0-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.mina.osgi</groupId>
+			<artifactId>mina-osgi-example</artifactId>
+			<version>1.1.0-SNAPSHOT</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.directory.osgi.services</groupId>
+			<artifactId>logging-service</artifactId>
+			<version>1.0.6-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.directory.osgi.commons</groupId>
+			<artifactId>commons-collections-osgi</artifactId>
+			<version>3.2</version>
+			<scope>test</scope>
+		</dependency>
+  
+
+		<dependency>
+			<groupId>org.apache.directory.osgi.commons</groupId>
+			<artifactId>jzlib-osgi</artifactId>
+			<version>1.0.7</version>
+			<scope>test</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.mina.osgi</groupId>
+			<artifactId>mina-integration-osgi</artifactId>
+			<version>1.1.0-SNAPSHOT</version>
+
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.osgi</groupId>
+			<artifactId>org.springframework.osgi.test</artifactId>
+			<version>1.0-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.osgi</groupId>
+			<artifactId>spring-core</artifactId>
+			<version>2.1-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.osgi</groupId>
+			<artifactId>spring-context</artifactId>
+			<version>2.1-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.osgi</groupId>
+			<artifactId>spring-beans</artifactId>
+			<version>2.1-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.osgi</groupId>
+			<artifactId>commons-logging.osgi</artifactId>
+			<version>1.1-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+   
+
+	</dependencies>
+
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.5</source>
+					<target>1.5</target>
+				</configuration>
+			</plugin>
+      <!-- run tests during the integration-test phase, not the normal test phase -->
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-surefire-plugin</artifactId>
+				<configuration>
+					<skip>true</skip>
+				</configuration>
+				<executions>
+					<execution>
+						<id>default</id>
+						<phase>test</phase>
+						<goals></goals>
+					</execution>
+					<execution>
+						<id>integration-test</id>
+						<phase>integration-test</phase>
+						<goals>
+							<goal>test</goal>
+						</goals>
+						<configuration>
+							<skip>false</skip>
+							<forkMode>pertest</forkMode>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+	<profiles>
+		<profile>
+			<id>equinox</id>
+			<activation>
+				<activeByDefault>true</activeByDefault>
+			</activation>
+			<dependencies>
+				<dependency>
+					<groupId>org.eclipse.equinox</groupId>
+					<artifactId>org.eclipse.osgi</artifactId>
+					<version>3.2.0</version>
+					<type>jar</type>
+					<scope>provided</scope>
+				</dependency>
+			</dependencies>
+			<properties>
+				<osgi.test.platform>equinox</osgi.test.platform>
+			</properties>
+		</profile>
+		<profile>
+			<id>knopflerfish</id>
+			<dependencies>
+				<dependency>
+					<groupId>org.knopflerfish</groupId>
+					<artifactId>framework</artifactId>
+					<version>2.0.1</version>
+					<type>jar</type>
+					<scope>provided</scope>
+				</dependency>
+			</dependencies>
+			<properties>
+				<osgi.test.platform>knopflerfish</osgi.test.platform>
+			</properties>
+		</profile>
+		<profile>
+			<id>felix</id>
+			<dependencies>
+				<dependency>
+					<groupId>org.apache.felix</groupId>
+					<artifactId>org.apache.felix.framework</artifactId>
+					<version>0.8.0-SNAPSHOT</version>
+					<type>jar</type>
+					<scope>provided</scope>
+				</dependency>
+				<dependency>
+					<groupId>org.apache.felix</groupId>
+					<artifactId>org.apache.felix.main</artifactId>
+					<version>0.8.0-SNAPSHOT</version>
+					<type>jar</type>
+					<scope>provided</scope>
+				</dependency>
+				<dependency>
+					<groupId>org.apache.felix</groupId>
+					<artifactId>org.osgi.core</artifactId>
+					<version>0.8.0-SNAPSHOT</version>
+					<type>jar</type>
+					<scope>runtime</scope>
+				</dependency>
+			</dependencies>
+			<properties>
+				<osgi.test.platform>felix</osgi.test.platform>
+		<!-- <org.osgi.vendor.framework>org.apache.felix.framework</org.osgi.vendor.framework>  -->
+			</properties>
+		</profile>
+	</profiles>
+</project>
\ No newline at end of file

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/java/org/apache/mina/osgi/example/chat/test/MinaOSGIExampleChatBundleTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/java/org/apache/mina/osgi/example/chat/test/MinaOSGIExampleChatBundleTest.java?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/java/org/apache/mina/osgi/example/chat/test/MinaOSGIExampleChatBundleTest.java (added)
+++ directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/java/org/apache/mina/osgi/example/chat/test/MinaOSGIExampleChatBundleTest.java Thu Nov 16 15:53:18 2006
@@ -0,0 +1,252 @@
+/*
+ * Copyright 2006 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.mina.osgi.example.chat.test;
+
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.osgi.example.chat.client.ChatClientSupport;
+import org.apache.mina.osgi.example.chat.client.SwingChatClientHandler;
+import org.apache.mina.osgi.example.chat.client.SwingChatClientHandler.Callback;
+import org.apache.mina.transport.socket.nio.SocketConnector;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+import org.springframework.osgi.test.ConfigurableBundleCreatorTests;
+
+
+
+/**
+ * Starts up an OSGi environment (equinox, knopflerfish, or felix according to
+ * the profile selected) and installs the simple service bundle and the bundles
+ * it depends on. The test classes in this project will be turned into a virtual
+ * bundle which is also installed and the tests are then run inside the OSGi
+ * runtime.
+ * 
+ * The tests have access to a BundleContext, which we use to test that the
+ * simpleService bean was indeed published as an OSGi service.
+ * 
+ * @author Adrian Colyer
+ */
+public class MinaOSGIExampleChatBundleTest extends
+        ConfigurableBundleCreatorTests {
+    
+    private static final String NAME = "fishhead";
+    private static final String TEST_MESSAGE = "Captain Beefheart";
+    private static final int port = 1234;
+    LogService logService;
+    static {
+        System.setProperty("log4j.configuration","file:src/test/resources/log4j.properties");
+    }
+
+    
+    /**
+     * The manifest to use for the "virtual bundle" created out of the test
+     * classes and resources in this project
+     * 
+     * This is actually the boilerplate manifest with one additional
+     * import-package added. We should provide a simpler customization point for
+     * such use cases that doesn't require duplication of the entire manifest...
+     */
+    protected String getManifestLocation() {
+        return "classpath:org/apache/mina/osgi/example/chat/test/MANIFEST.MF";
+    }
+
+    /**
+     * The location of the packaged OSGi bundles to be installed for this test.
+     * Values are Spring resource paths. The bundles we want to use are part of
+     * the same multi-project maven build as this project is. Hence we use the
+     * localMavenArtifact helper method to find the bundles produced by the
+     * package phase of the maven build (these tests will run after the
+     * packaging phase, in the integration-test phase).
+     * 
+     * JUnit, commons-logging, spring-core and the spring OSGi test bundle are
+     * automatically included so do not need to be specified here.
+     */
+    protected String[] getBundleLocations() {
+        return new String[] {
+            localMavenArtifact("org.springframework.osgi", "aopalliance.osgi","1.0-SNAPSHOT"),
+            localMavenArtifact("org.springframework.osgi", "spring-context", "2.1-SNAPSHOT"),
+            localMavenArtifact("org.springframework.osgi", "spring-beans","2.1-SNAPSHOT"),
+            localMavenArtifact("org.springframework.osgi", "spring-osgi-core","1.0-SNAPSHOT"),
+            localMavenArtifact("org.springframework.osgi", "spring-aop","2.1-SNAPSHOT"),
+            localMavenArtifact("org.apache.directory.osgi.commons","jzlib-osgi", "1.0.7"),
+            localMavenArtifact("org.apache.felix", "javax.servlet", "0.8.0-SNAPSHOT"),
+            localMavenArtifact("org.apache.felix","org.osgi.compendium", "0.8.0-SNAPSHOT"),
+            localMavenArtifact("org.apache.directory.osgi.services","logging-service", "1.0.6-SNAPSHOT"),
+            localMavenArtifact("org.apache.mina", "mina-integration-osgi","1.1.0-SNAPSHOT"),
+            localMavenArtifact("org.apache.directory.osgi.commons","commons-collections-osgi", "3.2"),
+            localMavenArtifact("org.apache.mina", "mina-osgi-example", "1.1.0-SNAPSHOT")
+        };
+    }
+
+    /**
+     * The superclass provides us access to the root bundle context via the
+     * 'getBundleContext' operation
+     */
+    public void testOSGiStartedOk() {
+        BundleContext bundleContext = getBundleContext();
+        assertNotNull(bundleContext);
+        
+        assertEquals(20,bundleContext.getBundles().length);
+    }
+
+    /**
+     * The LogService should have been exported as an OSGi service, which we
+     * can verify using the OSGi service APIs.
+     * 
+     * The mina-osgi-example bundle should have started a server and exported a 
+     * package for building a client.
+     * 
+     * In a Spring bundle, using osgi:reference is a much easier way to get a
+     * reference to a published service.
+     * 
+     */
+    public void testConnection() {
+        BundleContext context = getBundleContext();
+        ServiceReference ref = context.getServiceReference(LogService.class
+                .getName());
+        assertNotNull("Service Reference is null", ref);
+        
+        try {
+            logService = (LogService) context.getService(ref);
+            assertNotNull("Cannot find the service", logService);
+            
+            Bundle[] bundles = context.getBundles();
+            logService.log(LogService.LOG_DEBUG, "Loaded bundles:");
+            for (Bundle bundle : bundles) {
+                logService.log(LogService.LOG_DEBUG, bundle.getSymbolicName());
+            }
+        } finally {
+            context.ungetService(ref);
+        }
+    
+      logService.log(LogService.LOG_DEBUG,"Found LogService. Starting connection test");
+      final SocketAddress address = new InetSocketAddress( port );
+      assertNotNull( address );
+      final ExecutorService executor = Executors.newSingleThreadExecutor();
+      Callable<String> task = 
+          new Callable<String>() {
+              public String call(){
+                  MyCallback callback = new MyCallback();
+                  IoHandler handler = new SwingChatClientHandler(callback);
+                  ChatClientSupport client = new ChatClientSupport(NAME, handler);
+                  SocketConnector connector = new SocketConnector();
+                  client.connect( connector, address, true);
+                  client.login();
+                  client.broadcast(TEST_MESSAGE);
+                  String results = null;
+                  try
+                  {
+                      results = callback.getLastMessage();
+                  } catch (InterruptedException e)
+                  {
+                      Thread.currentThread().interrupt();
+                    
+                      fail("Getting results from callback interupted");
+                  }finally{
+                  client.quit();
+                  }
+                  return results;
+              }
+      };
+      Future<String> future = executor.submit(task);
+      try
+      {
+          String result = future.get(5, TimeUnit.SECONDS);
+          assertEquals("returned: <"+result+'>',NAME+": "+TEST_MESSAGE, result);
+      } catch (InterruptedException e)
+      {
+          Thread.currentThread().interrupt();
+          future.cancel(true);
+          fail("Testing Task interupted");
+      } catch (ExecutionException e){
+          RuntimeException ex = launderThrowable(e.getCause());
+          log.error("Execution execption", ex);
+          fail(ex.toString());
+      } catch (TimeoutException e){
+          fail(e.toString());
+      } 
+  }
+  
+  public static RuntimeException launderThrowable(Throwable t) {
+      if (t instanceof RuntimeException)
+          return (RuntimeException) t;
+      else if (t instanceof Error)
+              throw (Error) t;
+      else 
+          throw new IllegalStateException("Not unchecked", t);
+  }
+  
+  
+  class MyCallback implements Callback{
+
+      final CountDownLatch gotMessage = new CountDownLatch(2);
+      private String lastMessage = "nothing";
+      String getLastMessage() throws InterruptedException{
+          gotMessage.await();
+          return lastMessage;
+      }
+      public void connected()
+      {
+          logService.log(LogService.LOG_DEBUG,"Callback connected");
+      }
+
+      public void loggedIn()
+      {
+          logService.log(LogService.LOG_DEBUG,"Callback loggedIn");
+          
+      }
+
+      public void loggedOut()
+      {
+          logService.log(LogService.LOG_DEBUG,"Callback loggedOut");
+          
+      }
+
+      public void disconnected()
+      {
+          logService.log(LogService.LOG_DEBUG,"Callback disconnected");
+          
+      }
+
+      public void messageReceived( String message )
+      {
+         logService.log(LogService.LOG_DEBUG,"Callback message received: "+message);
+          lastMessage =message;
+          gotMessage.countDown();
+          
+      }
+
+      public void error( String message )
+      {
+          logService.log(LogService.LOG_ERROR,message);
+          
+      }
+      
+  }
+ 
+}

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/log4j.properties?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/log4j.properties (added)
+++ directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/log4j.properties Thu Nov 16 15:53:18 2006
@@ -0,0 +1,9 @@
+# Log4j properties file.
+log4j.rootCategory=WARN,console
+
+log4j.category.org.apache.directory.osgi.services.logging.LogServiceImpl=DEBUG
+
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.target=System.out
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%-5p  %l - %m%n
\ No newline at end of file

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/org/apache/mina/osgi/example/chat/test/MANIFEST.MF
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/org/apache/mina/osgi/example/chat/test/MANIFEST.MF?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/org/apache/mina/osgi/example/chat/test/MANIFEST.MF (added)
+++ directory/sandbox/jconlon/osgi-mina/mina-osgi-example-integration-test/src/test/resources/org/apache/mina/osgi/example/chat/test/MANIFEST.MF Thu Nov 16 15:53:18 2006
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-Name: simple-service-integration-tests
+Bundle-SymbolicName: org.springframework.osgi.samples.simpleservice.test
+Bundle-Vendor: Spring Framework
+Bundle-Activator: org.springframework.osgi.test.JUnitTestActivator
+Import-Package: junit.framework,
+ org.osgi.framework;specification-version="1.3.0",
+ org.springframework.core.io;specification-version="2.1.0",
+ org.springframework.osgi.test,
+ org.springframework.osgi.test.runner,
+ org.osgi.service.log,
+ org.apache.mina.osgi.example.chat.client,
+ org.apache.mina.common,
+ org.apache.mina.transport.socket.nio
+ 
+      

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example/pom.xml?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/mina-osgi-example/pom.xml (added)
+++ directory/sandbox/jconlon/osgi-mina/mina-osgi-example/pom.xml Thu Nov 16 15:53:18 2006
@@ -0,0 +1,178 @@
+<?xml version="1.0"?>
+<project>
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.apache.mina.osgi</groupId>
+		<artifactId>build</artifactId>
+		<version>1.1.0-SNAPSHOT</version>
+	</parent>
+	
+	<description>
+	 Bundles an example mina chat service by exposing its spring configuration for Spring-osgi to dynamically discover it at runtime. Spring-osgi will then register it as an OSGi service. Bundle also exports the chat client packages. 
+    </description>
+	<artifactId>mina-osgi-example</artifactId>
+	<name>${pom.artifactId} bundle</name>
+	<packaging>osgi-bundle</packaging>
+	
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.mina.osgi</groupId>
+			<artifactId>mina-integration-osgi</artifactId>
+			<version>1.1.0-SNAPSHOT</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.directory.osgi.commons</groupId>
+			<artifactId>jzlib-osgi</artifactId>
+			<version>1.0.7</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>3.8.1</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.osgi</groupId>
+			<artifactId>spring-mock</artifactId>
+			<version>2.1-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.osgi</groupId>
+			<artifactId>spring-core</artifactId>
+			<version>2.1-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.osgi</groupId>
+			<artifactId>spring-context</artifactId>
+			<version>2.1-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.osgi</groupId>
+			<artifactId>spring-beans</artifactId>
+			<version>2.1-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.osgi</groupId>
+			<artifactId>commons-logging.osgi</artifactId>
+			<version>1.1-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>nlog4j</artifactId>
+			<version>1.2.21</version>
+			<scope>provided</scope>
+			<exclusions>
+				<exclusion>
+					<groupId>xerces</groupId>
+					<artifactId>xerces</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>com.sun.jdmk</groupId>
+					<artifactId>jmxtools</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>javax.jms</groupId>
+					<artifactId>jms</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>javax.mail</groupId>
+					<artifactId>mail</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>javax.activation</groupId>
+					<artifactId>activation</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>com.sun.jmx</groupId>
+					<artifactId>jmxri</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>checkstyle</groupId>
+					<artifactId>checkstyle</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+	</dependencies>
+
+  <!-- for packaging as an OSGi bundle, we use the maven-osgi-plugin -->
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.5</source>
+					<target>1.5</target>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.felix.plugins</groupId>
+				<artifactId>maven-osgi-plugin</artifactId>
+				<extensions>true</extensions>
+				<version>0.8.0-SNAPSHOT</version>
+				<configuration>
+					<osgiManifest>
+						<bundleName>${pom.name}</bundleName>
+						<bundleSymbolicName>${pom.groupId}.${pom.artifactId}</bundleSymbolicName>
+						<exportPackage>org.apache.mina.osgi.example.chat.client</exportPackage>
+						<importPackage>
+				javax.net.ssl,
+				org.apache.mina.common,
+				org.apache.mina.filter,
+				org.apache.mina.filter.codec,
+				org.apache.mina.filter.codec.textline,
+				org.apache.mina.transport.socket.nio,
+				org.apache.mina.util,
+				org.apache.commons.collections.map,
+				org.apache.mina.integration.spring.ssl,
+				org.apache.mina.integration.spring,
+				org.springframework.beans.factory.config
+				</importPackage>
+					</osgiManifest>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+	
+	<repositories>
+		<repository>
+			<snapshots>
+				<enabled>true</enabled>
+			</snapshots>
+			<id>apache-snapshots</id>
+			<name>Apache Snapshots</name>
+			<url>http://cvs.apache.org/maven-snapshot-repository</url>
+		</repository>
+		<repository>
+			<snapshots>
+				<enabled>true</enabled>
+			</snapshots>
+			<id>spring-ext</id>
+			<name>Spring External Dependencies Repository</name>
+			<url>
+        https://svn.sourceforge.net/svnroot/springframework/repos/repo-ext/
+      </url>
+		</repository>
+	</repositories>
+
+  <!-- needed so that maven can find the maven-osgi-plugin -->
+	<pluginRepositories>
+		<pluginRepository>
+			<snapshots>
+				<enabled>true</enabled>
+			</snapshots>
+			<id>apache.snapshots</id>
+			<name>Apache Snapshots</name>
+			<url>http://cvs.apache.org/maven-snapshot-repository/</url>
+		</pluginRepository>
+	</pluginRepositories>
+
+</project>
\ No newline at end of file

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/ChatCommand.java
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/ChatCommand.java?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/ChatCommand.java (added)
+++ directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/ChatCommand.java Thu Nov 16 15:53:18 2006
@@ -0,0 +1,67 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.mina.osgi.example.chat;
+
+/**
+ * Encapsulates a chat command. Use {@link #valueOf(String)} to create an
+ * instance given a command string.
+ * 
+ * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class ChatCommand
+{
+    public static final int LOGIN = 0;
+
+    public static final int QUIT = 1;
+
+    public static final int BROADCAST = 2;
+
+    private final int num;
+
+    private ChatCommand( int num )
+    {
+        this.num = num;
+    }
+
+    public int toInt()
+    {
+        return num;
+    }
+
+    public static ChatCommand valueOf( String s )
+    {
+        s = s.toUpperCase();
+        if ( "LOGIN".equals( s ) )
+        {
+            return new ChatCommand( LOGIN );
+        }
+        if ( "QUIT".equals( s ) )
+        {
+            return new ChatCommand( QUIT );
+        }
+        if ( "BROADCAST".equals( s ) )
+        {
+            return new ChatCommand( BROADCAST );
+        }
+
+        throw new IllegalArgumentException( "Unrecognized command: " + s );
+    }
+}

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/ChatProtocolHandler.java
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/ChatProtocolHandler.java?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/ChatProtocolHandler.java (added)
+++ directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/ChatProtocolHandler.java Thu Nov 16 15:53:18 2006
@@ -0,0 +1,171 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.mina.osgi.example.chat;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoHandlerAdapter;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.util.SessionLog;
+
+/**
+ * {@link IoHandler} implementation of a simple chat server protocol.
+ * 
+ * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class ChatProtocolHandler extends IoHandlerAdapter
+{
+    private Set<IoSession> sessions = Collections.synchronizedSet( new HashSet<IoSession>() );
+    private Set<String> users = Collections.synchronizedSet( new HashSet<String>() );
+
+    public void exceptionCaught( IoSession session, Throwable cause )
+    {
+        SessionLog.error( session, "", cause );
+        // Close connection when unexpected exception is caught.
+        session.close();
+    }
+
+    public void messageReceived( IoSession session, Object message )
+    {
+        String theMessage = (String) message;
+        String[] result = theMessage.split( " ", 2 );
+        String theCommand = result[0];
+
+        try
+        {
+
+            ChatCommand command = ChatCommand.valueOf( theCommand );
+            String user = (String) session.getAttribute( "user" );
+
+            switch (command.toInt()) {
+
+            case ChatCommand.QUIT:
+                session.write( "QUIT OK" );
+                session.close();
+                break;
+            case ChatCommand.LOGIN:
+
+                if ( user != null )
+                {
+                    session.write( "LOGIN ERROR user " + user + " already logged in." );
+                    return;
+                }
+
+                if ( result.length == 2 )
+                {
+                    user = result[1];
+                }
+                else
+                {
+                    session.write( "LOGIN ERROR invalid login command." );
+                    return;
+                }
+
+                // check if the username is already used
+                if ( users.contains( user ) )
+                {
+                    session.write( "LOGIN ERROR the name " + user + " is already used." );
+                    return;
+                }
+
+                sessions.add( session );
+                session.setAttribute( "user", user );
+
+                // Allow all users
+                users.add( user );
+                session.write( "LOGIN OK" );
+                broadcast( "The user " + user + " has joined the chat session." );
+                break;
+
+            case ChatCommand.BROADCAST:
+                if ( result.length == 2 )
+                {
+                    broadcast( user + ": " + result[1] );
+                }
+                break;
+            default:
+                SessionLog.info( session, "Unhandled command: " + command );
+                break;
+            }
+
+        } catch (IllegalArgumentException e)
+        {
+            SessionLog.debug( session, e.getMessage() );
+        }
+    }
+
+    public void broadcast( String message )
+    {
+        synchronized (sessions)
+        {
+
+            Iterator iter = sessions.iterator();
+
+            while (iter.hasNext())
+            {
+                IoSession s = (IoSession) iter.next();
+                if ( s.isConnected() )
+                {
+                    s.write( "BROADCAST OK " + message );
+                }
+            }
+        }
+    }
+
+    public void sessionClosed( IoSession session ) throws Exception
+    {
+        String user = (String) session.getAttribute( "user" );
+        users.remove( user );
+        sessions.remove( session );
+        broadcast( "The user " + user + " has left the chat session." );
+    }
+
+    public boolean isChatUser( String name )
+    {
+        return users.contains( name );
+    }
+
+    public int getNumberOfUsers()
+    {
+        return users.size();
+    }
+
+    public void kick( String name )
+    {
+        synchronized (sessions)
+        {
+            Iterator iter = sessions.iterator();
+            while (iter.hasNext())
+            {
+                IoSession s = (IoSession) iter.next();
+                if ( name.equals( s.getAttribute( "user" ) ) )
+                {
+                    s.close();
+                    break;
+                }
+            }
+        }
+    }
+}

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/BogusSSLContextFactory.java
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/BogusSSLContextFactory.java?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/BogusSSLContextFactory.java (added)
+++ directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/BogusSSLContextFactory.java Thu Nov 16 15:53:18 2006
@@ -0,0 +1,175 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.mina.osgi.example.chat.client;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.GeneralSecurityException;
+import java.security.KeyStore;
+import java.security.Security;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+
+/**
+ * Factory to create a bougus SSLContext.
+ *
+ * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @version $Rev: 448075 $, $Date: 2006-09-20 00:26:53 -0500 (Wed, 20 Sep 2006) $
+ */
+public class BogusSSLContextFactory
+{
+
+    /**
+     * Protocol to use.
+     */
+    private static final String PROTOCOL = "TLS";
+    
+    private static final String KEY_MANAGER_FACTORY_ALGORITHM;
+
+    static {
+        String algorithm = Security.getProperty( "ssl.KeyManagerFactory.algorithm" );
+        if( algorithm == null )
+        {
+            algorithm = "SunX509";
+        }
+        
+        KEY_MANAGER_FACTORY_ALGORITHM = algorithm;
+    }
+
+    /**
+     * Bougus Server certificate keystore file name.
+     */
+    private static final String BOGUS_KEYSTORE = "bogus.cert";
+
+    // NOTE: The keystore was generated using keytool:
+    //   keytool -genkey -alias bogus -keysize 512 -validity 3650
+    //           -keyalg RSA -dname "CN=bogus.com, OU=XXX CA,
+    //               O=Bogus Inc, L=Stockholm, S=Stockholm, C=SE"
+    //           -keypass boguspw -storepass boguspw -keystore bogus.cert
+
+    /**
+     * Bougus keystore password.
+     */
+    private static final char[] BOGUS_PW = { 'b', 'o', 'g', 'u', 's', 'p',
+                                            'w' };
+
+    private static SSLContext serverInstance = null;
+
+    private static SSLContext clientInstance = null;
+
+    /**
+     * Get SSLContext singleton.
+     *
+     * @return SSLContext
+     * @throws java.security.GeneralSecurityException
+     *
+     */
+    public static SSLContext getInstance( boolean server )
+            throws GeneralSecurityException
+    {
+        SSLContext retInstance = null;
+        if( server )
+        {
+            if( serverInstance == null )
+            {
+                synchronized( BogusSSLContextFactory.class )
+                {
+                    if( serverInstance == null )
+                    {
+                        try
+                        {
+                            serverInstance = createBougusServerSSLContext();
+                        }
+                        catch( Exception ioe )
+                        {
+                            throw new GeneralSecurityException(
+                                    "Can't create Server SSLContext:" + ioe );
+                        }
+                    }
+                }
+            }
+            retInstance = serverInstance;
+        }
+        else
+        {
+            if( clientInstance == null )
+            {
+                synchronized( BogusSSLContextFactory.class )
+                {
+                    if( clientInstance == null )
+                    {
+                        clientInstance = createBougusClientSSLContext();
+                    }
+                }
+            }
+            retInstance = clientInstance;
+        }
+        return retInstance;
+    }
+
+    private static SSLContext createBougusServerSSLContext()
+            throws GeneralSecurityException, IOException
+    {
+        // Create keystore
+        KeyStore ks = KeyStore.getInstance( "JKS" );
+        InputStream in = null;
+        try
+        {
+            in = BogusSSLContextFactory.class
+                    .getResourceAsStream( BOGUS_KEYSTORE );
+            ks.load( in, BOGUS_PW );
+        }
+        finally
+        {
+            if( in != null )
+            {
+                try
+                {
+                    in.close();
+                }
+                catch( IOException ignored )
+                {
+                }
+            }
+        }
+
+        // Set up key manager factory to use our key store
+        KeyManagerFactory kmf = KeyManagerFactory.getInstance(
+                KEY_MANAGER_FACTORY_ALGORITHM );
+        kmf.init( ks, BOGUS_PW );
+
+        // Initialize the SSLContext to work with our key managers.
+        SSLContext sslContext = SSLContext.getInstance( PROTOCOL );
+        sslContext.init( kmf.getKeyManagers(),
+                BogusTrustManagerFactory.X509_MANAGERS, null );
+
+        return sslContext;
+    }
+
+    private static SSLContext createBougusClientSSLContext()
+            throws GeneralSecurityException
+    {
+        SSLContext context = SSLContext.getInstance( PROTOCOL );
+        context.init( null, BogusTrustManagerFactory.X509_MANAGERS, null );
+        return context;
+    }
+
+}

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/BogusTrustManagerFactory.java
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/BogusTrustManagerFactory.java?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/BogusTrustManagerFactory.java (added)
+++ directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/BogusTrustManagerFactory.java Thu Nov 16 15:53:18 2006
@@ -0,0 +1,82 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.mina.osgi.example.chat.client;
+
+import java.security.InvalidAlgorithmParameterException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.ManagerFactoryParameters;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactorySpi;
+import javax.net.ssl.X509TrustManager;
+
+/**
+ * Bogus trust manager factory. Creates BogusX509TrustManager
+ *
+ * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @version $Rev: 448075 $, $Date: 2006-09-20 00:26:53 -0500 (Wed, 20 Sep 2006) $
+ */
+class BogusTrustManagerFactory extends TrustManagerFactorySpi
+{
+
+    static final X509TrustManager X509 = new X509TrustManager()
+    {
+        public void checkClientTrusted( X509Certificate[] x509Certificates,
+                                       String s ) throws CertificateException
+        {
+        }
+
+        public void checkServerTrusted( X509Certificate[] x509Certificates,
+                                       String s ) throws CertificateException
+        {
+        }
+
+        public X509Certificate[] getAcceptedIssuers()
+        {
+            return new X509Certificate[ 0 ];
+        }
+    };
+
+    static final TrustManager[] X509_MANAGERS = new TrustManager[] { X509 };
+
+    public BogusTrustManagerFactory()
+    {
+    }
+
+    protected TrustManager[] engineGetTrustManagers()
+    {
+        return X509_MANAGERS;
+    }
+
+    protected void engineInit( KeyStore keystore ) throws KeyStoreException
+    {
+        // noop
+    }
+
+    protected void engineInit(
+                              ManagerFactoryParameters managerFactoryParameters )
+            throws InvalidAlgorithmParameterException
+    {
+        // noop
+    }
+}

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/ChatClientSupport.java
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/ChatClientSupport.java?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/ChatClientSupport.java (added)
+++ directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/ChatClientSupport.java Thu Nov 16 15:53:18 2006
@@ -0,0 +1,131 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.mina.osgi.example.chat.client;
+
+import java.net.SocketAddress;
+
+import javax.net.ssl.SSLContext;
+
+import org.apache.mina.common.ConnectFuture;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.common.RuntimeIOException;
+//import org.apache.mina.example.echoserver.ssl.BogusSSLContextFactory;
+import org.apache.mina.filter.SSLFilter;
+import org.apache.mina.transport.socket.nio.SocketConnector;
+import org.apache.mina.transport.socket.nio.SocketConnectorConfig;
+
+/**
+ * A simple chat client for a given user.
+ *
+ * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class ChatClientSupport
+{
+    private final IoHandler handler;
+    private final String name;
+    private IoSession session;
+
+    public ChatClientSupport( String name, IoHandler handler )
+    {
+        if( name == null )
+        {
+            throw new IllegalArgumentException( "Name can not be null" );
+        }
+        this.name = name;
+        this.handler = handler;
+    }
+
+    public boolean connect( SocketConnector connector, SocketAddress address, boolean useSsl )
+    {
+        if( session != null && session.isConnected() )
+        {
+            throw new IllegalStateException( "Already connected. Disconnect first." );
+        }
+
+        try
+        {
+
+            SocketConnectorConfig config = new SocketConnectorConfig();
+            if( useSsl )
+            {
+                SSLContext sslContext = BogusSSLContextFactory.getInstance( false );
+                SSLFilter sslFilter = new SSLFilter( sslContext );
+                sslFilter.setUseClientMode( true );
+                config.getFilterChain().addLast( "sslFilter", sslFilter );
+            }
+
+            ConnectFuture future1 = connector.connect( address, handler, config );
+            future1.join();
+            if( ! future1.isConnected() )
+            {
+                return false;
+            }
+            session = future1.getSession();
+
+            return true;
+        }
+        catch ( Exception e)
+        {
+            return false;
+        }
+    }
+
+    public void login()
+    {
+        if( name == null )
+        {
+            throw new IllegalArgumentException( "Name can not be null" );
+        }
+        
+        if( session == null )
+        {
+            throw new IllegalArgumentException( "session can not be null" );
+        }
+        session.write( "LOGIN " + name );
+    }
+
+    public void broadcast( String message )
+    {
+        session.write( "BROADCAST " + message );
+    }
+
+    public void quit()
+    {
+        if( session != null )
+        {
+            if( session.isConnected() )
+            {
+                session.write( "QUIT" );
+                // Wait until the chat ends.
+                try
+                {
+                    session.getCloseFuture().join();
+                } catch( InterruptedException e )
+                {
+                    throw new RuntimeIOException( e );
+                }
+            }
+            session.close();
+        }
+    }
+
+}

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/SwingChatClientHandler.java
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/SwingChatClientHandler.java?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/SwingChatClientHandler.java (added)
+++ directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/java/org/apache/mina/osgi/example/chat/client/SwingChatClientHandler.java Thu Nov 16 15:53:18 2006
@@ -0,0 +1,121 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.mina.osgi.example.chat.client;
+
+import org.apache.mina.common.IoFilter;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoHandlerAdapter;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.osgi.example.chat.ChatCommand;
+import org.apache.mina.filter.LoggingFilter;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
+
+/**
+ * {@link IoHandler} implementation of the client side of the simple chat
+ * protocol.
+ * 
+ * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class SwingChatClientHandler extends IoHandlerAdapter
+{
+
+    public interface Callback
+    {
+        void connected();
+
+        void loggedIn();
+
+        void loggedOut();
+
+        void disconnected();
+
+        void messageReceived( String message );
+
+        void error( String message );
+    }
+
+    private static IoFilter LOGGING_FILTER = new LoggingFilter();
+    private static IoFilter CODEC_FILTER = new ProtocolCodecFilter( new TextLineCodecFactory() );
+
+    private final Callback callback;
+
+    public SwingChatClientHandler( Callback callback )
+    {
+        this.callback = callback;
+    }
+
+    public void sessionCreated( IoSession session ) throws Exception
+    {
+        session.getFilterChain().addLast( "codec", CODEC_FILTER );
+        session.getFilterChain().addLast( "logger", LOGGING_FILTER );
+    }
+
+    public void sessionOpened( IoSession session ) throws Exception
+    {
+        callback.connected();
+    }
+
+    public void messageReceived( IoSession session, Object message ) throws Exception
+    {
+        String theMessage = (String) message;
+        String[] result = theMessage.split( " ", 3 );
+        String status = result[1];
+        String theCommand = result[0];
+        ChatCommand command = ChatCommand.valueOf( theCommand );
+
+        if ( "OK".equals( status ) )
+        {
+
+            switch (command.toInt()) {
+
+            case ChatCommand.BROADCAST:
+
+                if ( result.length == 3 )
+                {
+                    callback.messageReceived( result[2] );
+                }
+                break;
+            case ChatCommand.LOGIN:
+                callback.loggedIn();
+                break;
+
+            case ChatCommand.QUIT:
+                callback.loggedOut();
+                break;
+            }
+
+        }
+        else
+        {
+            if ( result.length == 3 )
+            {
+                callback.error( result[2] );
+            }
+        }
+    }
+
+    public void sessionClosed( IoSession session ) throws Exception
+    {
+        callback.disconnected();
+    }
+
+}

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/META-INF/spring/serverContext-osgi.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/META-INF/spring/serverContext-osgi.xml?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/META-INF/spring/serverContext-osgi.xml (added)
+++ directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/META-INF/spring/serverContext-osgi.xml Thu Nov 16 15:53:18 2006
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:osgi="http://www.springframework.org/schema/osgi"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                      http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+
+  <!-- definitions using elements of the osgi namespace can be included
+       in this file. There is no requirement to keep these definitions
+       in a separate file if you do not want to. The rationale for 
+       keeping these definitions separate is to facilitate integration
+       testing of the bundle outside of an OSGi container -->
+
+</beans>
\ No newline at end of file

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/META-INF/spring/serverContext.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/META-INF/spring/serverContext.xml?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/META-INF/spring/serverContext.xml (added)
+++ directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/META-INF/spring/serverContext.xml Thu Nov 16 15:53:18 2006
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+  <!-- regular spring configuration file defining simple service
+       bean. We've kept the osgi definitions in a separate 
+       configuration file so that this file can easily be used
+       for testing outside of an OSGi environment -->
+       
+  <!-- This makes it possible to specify java.net.SocketAddress values 
+    (e.g. :1234 below) as Strings.
+    They will be converted into java.net.InetSocketAddress objects by Spring.  -->
+  <bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
+    <property name="customEditors">
+      <map>
+        <entry key="java.net.SocketAddress">
+          <bean class="org.apache.mina.integration.spring.InetSocketAddressEditor" />
+        </entry>
+      </map>
+    </property>
+  </bean>
+
+  <!-- The IoHandler implementation -->
+  <bean id="chatHandler" class="org.apache.mina.osgi.example.chat.ChatProtocolHandler" />
+
+  <!-- The SSL configuration -->
+  <bean id="keyStore" class="org.apache.mina.integration.spring.ssl.KeyStoreFactoryBean">
+    <property name="resource" value="classpath:org/apache/mina/osgi/example/chat/ssl/bogus.cert"/>
+    <property name="password" value="boguspw"/>
+  </bean>
+  
+  <bean id="bogusTrustManagerFactory" class="org.apache.mina.integration.spring.ssl.BogusTrustManagerFactory"/>
+  
+  <!-- SSLContext to be used when acting as a server (client <-> proxy) -->
+  <bean id="sslContext"  class="org.apache.mina.integration.spring.ssl.SSLContextFactoryBean">
+    <property name="protocol" value="TLS"/>
+    <property name="keyManagerFactoryAlgorithm" value="SunX509"/>
+    <property name="keyManagerFactoryKeyStore"><ref local="keyStore"/></property>
+    <property name="keyManagerFactoryKeyStorePassword" value="boguspw"/>
+    <property name="trustManagerFactory"><ref local="bogusTrustManagerFactory"/></property>
+  </bean>
+  
+  <!-- The filter chain. Adds an SSLFilter, a TextLineCodec and a LoggingFilter -->
+  <bean id="filterChainBuilder" class="org.apache.mina.integration.spring.DefaultIoFilterChainBuilderFactoryBean">
+    <property name="filters">
+      <list>
+        <bean class="org.apache.mina.filter.SSLFilter">
+          <constructor-arg ref="sslContext"/>
+        </bean>      
+        <bean class="org.apache.mina.filter.codec.ProtocolCodecFilter">
+          <constructor-arg>
+            <bean class="org.apache.mina.filter.codec.textline.TextLineCodecFactory" />
+          </constructor-arg>
+        </bean>
+        <bean class="org.apache.mina.filter.LoggingFilter" />
+      </list>
+    </property>
+  </bean>
+
+  <!-- The IoAcceptor which binds to port 1234 -->
+  <bean id="ioAcceptor" class="org.apache.mina.integration.spring.IoAcceptorFactoryBean">
+    <property name="target">
+      <bean class="org.apache.mina.transport.socket.nio.SocketAcceptor" />
+    </property>
+    <property name="bindings">
+      <list>
+        <bean id="binding" class="org.apache.mina.integration.spring.Binding">
+          <property name="address" value=":1234" />
+          <property name="handler" ref="chatHandler" />
+          <property name="serviceConfig">
+            <bean class="org.apache.mina.transport.socket.nio.SocketAcceptorConfig">
+              <property name="filterChainBuilder" ref="filterChainBuilder" />
+              <property name="reuseAddress" value="true" />
+            </bean>
+          </property>
+        </bean>
+      </list>
+    </property>
+  </bean>
+
+  
+</beans>

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/org/apache/mina/osgi/example/chat/ssl/bogus.cert
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/org/apache/mina/osgi/example/chat/ssl/bogus.cert?view=auto&rev=475991
==============================================================================
Binary file - no diff available.

Propchange: directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/main/resources/org/apache/mina/osgi/example/chat/ssl/bogus.cert
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/java/org/apache/mina/osgi/example/chat/BeanIntegrationTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/java/org/apache/mina/osgi/example/chat/BeanIntegrationTest.java?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/java/org/apache/mina/osgi/example/chat/BeanIntegrationTest.java (added)
+++ directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/java/org/apache/mina/osgi/example/chat/BeanIntegrationTest.java Thu Nov 16 15:53:18 2006
@@ -0,0 +1,208 @@
+package org.apache.mina.osgi.example.chat;
+
+import java.net.SocketAddress;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.mina.common.IoAcceptor;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoService;
+import org.apache.mina.common.IoServiceConfig;
+import org.apache.mina.common.IoServiceListener;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.osgi.example.chat.client.ChatClientSupport;
+import org.apache.mina.osgi.example.chat.client.SwingChatClientHandler;
+import org.apache.mina.osgi.example.chat.client.SwingChatClientHandler.Callback;
+import org.apache.mina.transport.socket.nio.SocketConnector;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
+
+/**
+ * Integration test the bundle locally (outside of OSGi). Use AbstractOsgiTests
+ * and a separate integration test project for testing inside of OSGi.
+ */
+public class BeanIntegrationTest extends AbstractDependencyInjectionSpringContextTests
+{
+  
+    private static final String NAME = "fishhead";
+
+    private static final String TEST_MESSAGE = "Captain Beefheart";
+
+    /** the log for this class */
+    private static final Logger log = LoggerFactory.getLogger( BeanIntegrationTest.class );
+    
+    private IoAcceptor ioAcceptor;
+
+    protected String[] getConfigLocations()
+    {
+        return new String[] { "META-INF/spring/serverContext.xml" };
+    }
+
+    public void setIoAcceptor( IoAcceptor ioAcceptor )
+    {
+        this.ioAcceptor = ioAcceptor;
+    }
+
+    public void testIoAcceptorInstance()
+    {
+        assertNotNull( this.ioAcceptor );
+    }
+
+    public void testAddress()
+    {
+        assertNotNull( this.ioAcceptor );
+        Set<SocketAddress> addresses = ioAcceptor.getManagedServiceAddresses();
+        assertFalse( addresses.isEmpty() );
+        assertEquals( addresses.size(), 1 );
+        SocketAddress address = addresses.iterator().next();
+        assertNotNull( address );
+        assertEquals( "0.0.0.0/0.0.0.0:1234", address.toString() );
+    }
+    
+    public void testConnection(){
+        Set<SocketAddress> addresses = ioAcceptor.getManagedServiceAddresses();
+        final SocketAddress address = addresses.iterator().next();
+        assertNotNull( address );
+        
+        
+        MyListener listner = new MyListener();
+        ioAcceptor.addListener(listner);
+        assertEquals(listner.sessionsCreated,0);
+        assertEquals(listner.sessionsDestroyed,0);
+        final ExecutorService executor = Executors.newSingleThreadExecutor();
+        Callable<String> task = 
+            new Callable<String>() {
+                public String call(){
+                    MyCallback callback = new MyCallback();
+                    IoHandler handler = new SwingChatClientHandler(callback);
+                    ChatClientSupport client = new ChatClientSupport(NAME, handler);
+                    SocketConnector connector = new SocketConnector();
+                    client.connect( connector, address, true);
+                    client.login();
+                    client.broadcast(TEST_MESSAGE);
+                    String results = null;
+                    try
+                    {
+                        results = callback.getLastMessage();
+                    } catch (InterruptedException e)
+                    {
+                        Thread.currentThread().interrupt();
+                      
+                        fail("Getting results from callback interupted");
+                    }finally{
+                    client.quit();
+                    }
+                    return results;
+                }
+        };
+        Future<String> future = executor.submit(task);
+        try
+        {
+            String result = future.get(5, TimeUnit.SECONDS);
+            assertEquals("returned: <"+result+'>',NAME+": "+TEST_MESSAGE, result);
+        } catch (InterruptedException e)
+        {
+            Thread.currentThread().interrupt();
+            future.cancel(true);
+            fail("Testing Task interupted");
+        } catch (ExecutionException e){
+            RuntimeException ex = launderThrowable(e.getCause());
+            log.error("Execution execption", ex);
+            fail(ex.toString());
+        } catch (TimeoutException e){
+            fail(e.toString());
+        } 
+        assertEquals(listner.sessionsCreated,1);
+        assertEquals(listner.sessionsDestroyed,1);
+    }
+    
+    public static RuntimeException launderThrowable(Throwable t) {
+        if (t instanceof RuntimeException)
+            return (RuntimeException) t;
+        else if (t instanceof Error)
+                throw (Error) t;
+        else 
+            throw new IllegalStateException("Not unchecked", t);
+    }
+    
+    
+    class MyCallback implements Callback{
+
+        final CountDownLatch gotMessage = new CountDownLatch(2);
+        private String lastMessage = "nothing";
+        String getLastMessage() throws InterruptedException{
+            gotMessage.await();
+            return lastMessage;
+        }
+        public void connected()
+        {
+            log.info("connected");
+        }
+
+        public void loggedIn()
+        {
+            log.info("loggedIn");
+            
+        }
+
+        public void loggedOut()
+        {
+            log.info("loggedOut");
+            
+        }
+
+        public void disconnected()
+        {
+            log.info("disconnected");
+            
+        }
+
+        public void messageReceived( String message )
+        {
+            log.info("message: {}",message);
+            lastMessage =message;
+            gotMessage.countDown();
+            
+        }
+
+        public void error( String message )
+        {
+            log.error("error: {}",message);
+            
+        }
+        
+    }
+    class MyListener implements IoServiceListener{
+        volatile int sessionsCreated = 0;
+        volatile int sessionsDestroyed = 0;
+        public void serviceActivated( IoService service, SocketAddress serviceAddress, IoHandler handler, IoServiceConfig config )
+        {
+            // ignore
+        }
+
+        public void serviceDeactivated( IoService service, SocketAddress serviceAddress, IoHandler handler, IoServiceConfig config )
+        {
+            // ignore
+        }
+
+        public void sessionCreated( IoSession session )
+        {
+            sessionsCreated++;
+        }
+
+        public void sessionDestroyed( IoSession session )
+        {
+            sessionsDestroyed++;
+        }
+        
+    }
+
+}

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/java/org/apache/mina/osgi/example/chat/ChatCommandTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/java/org/apache/mina/osgi/example/chat/ChatCommandTest.java?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/java/org/apache/mina/osgi/example/chat/ChatCommandTest.java (added)
+++ directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/java/org/apache/mina/osgi/example/chat/ChatCommandTest.java Thu Nov 16 15:53:18 2006
@@ -0,0 +1,53 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.mina.osgi.example.chat;
+
+import junit.framework.TestCase;
+
+/**
+ * example of a standalone test.
+ * 
+ * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class ChatCommandTest extends TestCase
+{
+    public void testLOGINType()
+    {
+        ChatCommand type = ChatCommand.valueOf( "LOGIN" );
+        assertNotNull( type );
+        assertEquals( type.toInt(), ChatCommand.LOGIN );
+    }
+
+    public void testBROADCASTType()
+    {
+        ChatCommand type = ChatCommand.valueOf( "BROADCAST" );
+        assertNotNull( type );
+        assertEquals( type.toInt(), ChatCommand.BROADCAST );
+    }
+
+    public void testQUITType()
+    {
+        ChatCommand type = ChatCommand.valueOf( "QUIT" );
+        assertNotNull( type );
+        assertEquals( type.toInt(), ChatCommand.QUIT );
+    }
+
+}

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/resources/log4j.properties?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/resources/log4j.properties (added)
+++ directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/resources/log4j.properties Thu Nov 16 15:53:18 2006
@@ -0,0 +1,7 @@
+# Please don't modify the log level until we reach to acceptable test coverage.
+# It's very useful when I test examples manually.
+log4j.rootCategory=INFO, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n

Added: directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/resources/readme.txt
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/resources/readme.txt?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/resources/readme.txt (added)
+++ directory/sandbox/jconlon/osgi-mina/mina-osgi-example/src/test/resources/readme.txt Thu Nov 16 15:53:18 2006
@@ -0,0 +1,4 @@
+This file is only here because maven archetypes cannot create empty directories.Without this directory present, eclipse will indicate a classpath error 
+because src/test/resources is on the project's classpath.
+
+You can safely delete this file.

Added: directory/sandbox/jconlon/osgi-mina/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-mina/pom.xml?view=auto&rev=475991
==============================================================================
--- directory/sandbox/jconlon/osgi-mina/pom.xml (added)
+++ directory/sandbox/jconlon/osgi-mina/pom.xml Thu Nov 16 15:53:18 2006
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.mina</groupId>
+    <artifactId>build</artifactId>
+    <version>1.1.0-SNAPSHOT</version>
+  </parent>
+  
+  <description>
+    These subprojects provide a mina osgi support and an example of 
+    a mina osgi based application. 
+  </description>
+  <groupId>org.apache.mina.osgi</groupId>
+  <artifactId>build</artifactId>
+  <name>Apache Mina OSGi Build</name>
+  <packaging>pom</packaging>
+  
+  <modules>
+    <module>integration-osgi</module>
+    <module>mina-osgi-example</module>
+    <module>mina-osgi-example-integration-test</module>
+  </modules>
+  
+</project>



Mime
View raw message