Permalink
Browse files

Adjust -Dtarget.container=jboss720 test suite for arquillian-osgi-1.0…

….3.Final
  • Loading branch information...
tdiesler committed Oct 25, 2012
1 parent a14cdd6 commit 4ef4a298d4225e09d0a5396ebee0b35b7d832ebe
View
@@ -276,6 +276,29 @@
</plugins>
</build>
</profile>
+
+ <profile>
+ <id>jboss720-testing</id>
+ <activation>
+ <property>
+ <name>target.container</name>
+ <value>jboss720</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>${surefire.system.args} ${surefire.security.args}</argLine>
+ <excludes>
+ <exclude>**/*StandaloneTestCase.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
<!-- Repositories -->
@@ -58,7 +58,7 @@
/**
* Tests CDI deployments with OSGi metadata
- *
+ *
* @author Thomas.Diesler@jboss.com
* @since 09-Jul-2012
*/
@@ -91,6 +91,7 @@ public InputStream openStream() {
OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
builder.addBundleSymbolicName(jar.getName());
builder.addBundleManifestVersion(2);
+ builder.addImportPackages(PackageAdmin.class, ManagementClient.class);
return builder.openStream();
}
});
@@ -49,7 +49,7 @@
/**
* Test OSGi bundles contained in EARs
- *
+ *
* @author thomas.diesler@jboss.com
* @since 07-Jun-2011
*/
@@ -77,6 +77,7 @@ public InputStream openStream() {
OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
builder.addBundleSymbolicName(jar.getName());
builder.addBundleManifestVersion(2);
+ builder.addImportPackages(ManagementClient.class);
return builder.openStream();
}
});
@@ -36,7 +36,6 @@
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.container.ManagementClient;
-import org.jboss.logging.Logger;
import org.jboss.osgi.metadata.OSGiManifestBuilder;
import org.jboss.osgi.resolver.XBundle;
import org.jboss.shrinkwrap.api.Archive;
@@ -55,7 +54,7 @@
/**
* Test the {@link HttpService} on JBossWeb
- *
+ *
* @author thomas.diesler@jboss.com
* @since 19-Jul-2011
*/
@@ -83,6 +82,7 @@ public InputStream openStream() {
builder.addBundleManifestVersion(2);
builder.addImportPackages(HttpService.class);
builder.addImportPackages(Servlet.class, HttpServlet.class);
+ builder.addImportPackages(XBundle.class, ManagementClient.class);
return builder.openStream();
}
});
@@ -201,15 +201,14 @@ private String performCall(String path) throws Exception {
@SuppressWarnings("serial")
static final class HttpServiceServlet extends HttpServlet {
- static Logger log = Logger.getLogger(HttpServiceServlet.class);
-
private final XBundle bundle;
// This hides the default ctor and verifies that this instance is used
HttpServiceServlet(Bundle bundle) {
this.bundle = (XBundle) bundle;
}
+ @Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
PrintWriter out = res.getWriter();
String type = req.getParameter("test");
@@ -57,10 +57,10 @@
/**
* A test that deployes a bundle that contains some metadata and an interceptor bundle that processes the metadata and
* registeres an http endpoint from it.
- *
+ *
* The idea is that the bundle does not process its own metadata. Instead this work is delegated to some specialized metadata
* processor (i.e. the interceptor)
- *
+ *
* @author thomas.diesler@jboss.com
* @since 23-Oct-2009
*/
@@ -84,11 +84,12 @@ public static JavaArchive createdeployment() {
final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "example-interceptor");
archive.addClasses(HttpRequest.class);
archive.setManifest(new Asset() {
+ @Override
public InputStream openStream() {
OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
builder.addBundleSymbolicName(archive.getName());
builder.addBundleManifestVersion(2);
- builder.addImportPackages(HttpService.class);
+ builder.addImportPackages(HttpService.class, ManagementClient.class);
return builder.openStream();
}
});
@@ -55,7 +55,7 @@
/**
* Test simple OSGi REST deployment
- *
+ *
* @author thomas.diesler@jboss.com
* @since 30-Aug-2012
*/
@@ -87,6 +87,7 @@ public InputStream openStream() {
OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
builder.addBundleSymbolicName(jar.getName());
builder.addBundleManifestVersion(2);
+ builder.addImportPackages(ManagementClient.class);
return builder.openStream();
}
});
@@ -49,7 +49,7 @@
/**
* Test web service client functionality
- *
+ *
* @author thomas.diesler@jboss.com
* @since 28-Aug-2011
*/
@@ -80,6 +80,7 @@ public InputStream openStream() {
builder.addBundleSymbolicName(archive.getName());
builder.addBundleManifestVersion(2);
builder.addImportPackages(WebService.class, SOAPBinding.class, QName.class, Service.class);
+ builder.addImportPackages(ManagementClient.class);
return builder.openStream();
}
});
@@ -57,7 +57,7 @@
/**
* Test web service endpoint functionality
- *
+ *
* @author thomas.diesler@jboss.com
* @since 28-Aug-2011
*/
@@ -93,6 +93,7 @@ public InputStream openStream() {
builder.addBundleSymbolicName(archive.getName());
builder.addBundleManifestVersion(2);
builder.addImportPackages(WebService.class, SOAPBinding.class, QName.class, Service.class);
+ builder.addImportPackages(PackageAdmin.class, ManagementClient.class);
return builder.openStream();
}
});
@@ -0,0 +1,195 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.example.jndi;
+
+import java.io.InputStream;
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.Reference;
+import javax.naming.spi.InitialContextFactory;
+
+import org.jboss.arquillian.container.test.api.Deployer;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.osgi.metadata.OSGiManifestBuilder;
+import org.jboss.osgi.repository.XRequirementBuilder;
+import org.jboss.osgi.resolver.MavenCoordinates;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.Asset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.test.osgi.AriesSupport;
+import org.jboss.test.osgi.BlueprintSupport;
+import org.jboss.test.osgi.ConfigurationAdminSupport;
+import org.jboss.test.osgi.NamingSupport;
+import org.jboss.test.osgi.RepositorySupport;
+import org.jboss.test.osgi.example.jndi.bundle.JNDITestActivator;
+import org.jboss.test.osgi.example.jndi.bundle.JNDITestActivator.SimpleInitalContextFactory;
+import org.jboss.test.osgi.example.jndi.bundle.JNDITestActivator.StringReference;
+import org.jboss.test.osgi.example.jndi.bundle.JNDITestService;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.resource.Resource;
+import org.osgi.service.jndi.JNDIContextManager;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.service.repository.Repository;
+
+/**
+ * This test exercises the OSGi-JNDI integration
+ *
+ * @author David Bosschaert
+ * @author Thomas.Diesler@jboss.com
+ */
+@RunWith(Arquillian.class)
+public class NamingStandaloneTestCase {
+
+ private static final String JNDI_PROVIDER = "jndi-provider";
+
+ @ArquillianResource
+ BundleContext context;
+
+ @ArquillianResource
+ Deployer deployer;
+
+ @Deployment(name = JNDI_PROVIDER)
+ public static JavaArchive jndiProvider() {
+ final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, JNDI_PROVIDER);
+ archive.addClasses(RepositorySupport.class, NamingSupport.class, AriesSupport.class, BlueprintSupport.class, ConfigurationAdminSupport.class);
+ archive.addClasses(JNDITestService.class, JNDITestActivator.class);
+ archive.addAsManifestResource(RepositorySupport.BUNDLE_VERSIONS_FILE);
+ archive.setManifest(new Asset() {
+ @Override
+ public InputStream openStream() {
+ OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
+ builder.addBundleSymbolicName(archive.getName());
+ builder.addBundleManifestVersion(2);
+ builder.addBundleActivator(JNDITestActivator.class);
+ builder.addImportPackages(XRequirementBuilder.class, MavenCoordinates.class, Repository.class, Resource.class);
+ builder.addImportPackages(PackageAdmin.class, Context.class, InitialContextFactory.class);
+ builder.addDynamicImportPackages(JNDIContextManager.class.getPackage().getName());
+ builder.addExportPackages(JNDITestService.class);
+ return builder.openStream();
+ }
+ });
+ return archive;
+ }
+
+ @Test
+ @InSequence(0)
+ public void addNamingSupport(@ArquillianResource Bundle bundle) throws Exception {
+ NamingSupport.provideJNDIIntegration(context, bundle);
+ bundle.start();
+ }
+
+ @Test
+ @InSequence(1)
+ public void testContextManagerOwnerContext(@ArquillianResource Bundle bundle) throws Exception {
+
+ // Get the InitialContext via {@link JNDIContextManager}
+ JNDIContextManager contextManager = NamingSupport.getContextManager(bundle);
+ Context initialContext = contextManager.newInitialContext();
+
+ // Get the context of the owner bundle
+ BundleContext context = (BundleContext) initialContext.lookup("osgi:framework/bundleContext");
+ Assert.assertEquals(bundle.getBundleContext(), context);
+ }
+
+ @Test
+ @InSequence(1)
+ public void testContextManagerReferenceBinding(@ArquillianResource Bundle bundle) throws Exception {
+
+ // Get the InitialContext via {@link JNDIContextManager}
+ JNDIContextManager contextManager = NamingSupport.getContextManager(bundle);
+ Hashtable<String, String> env = new Hashtable<String, String>();
+ env.put(Context.INITIAL_CONTEXT_FACTORY, SimpleInitalContextFactory.class.getName());
+ Context initialContext = contextManager.newInitialContext(env);
+
+ // Bind a some value reference under some key
+ Reference ref = new StringReference("bar");
+ initialContext.bind("test/foo", ref);
+ try {
+ // Lookup the value
+ Assert.assertEquals("bar", initialContext.lookup("test/foo"));
+ } finally {
+ initialContext.unbind("test/foo");
+ }
+ }
+
+ @Test
+ @Ignore
+ @InSequence(1)
+ public void testTraditionalAPIOwnerContext(@ArquillianResource Bundle bundle) throws Exception {
+
+ // Get the InitialContext via API
+ Context initialContext = new InitialContext();
+
+ // Get the context of the owner bundle
+ BundleContext context = (BundleContext) initialContext.lookup("osgi:framework/bundleContext");
+ Assert.assertEquals(bundle.getBundleContext(), context);
+ }
+
+ @Test
+ @InSequence(1)
+ public void testTraditionalAPIValueBinding(@ArquillianResource Bundle bundle) throws Exception {
+
+ // Get the InitialContext via API
+ Hashtable<String, String> env = new Hashtable<String, String>();
+ env.put(Context.INITIAL_CONTEXT_FACTORY, SimpleInitalContextFactory.class.getName());
+ Context initialContext = new InitialContext(env);
+
+ // Bind a some value under some key
+ initialContext.bind("test/foo", "bar");
+ try {
+ // Lookup the value
+ Assert.assertEquals("bar", initialContext.lookup("test/foo"));
+ } finally {
+ initialContext.unbind("test/foo");
+ }
+ }
+
+ @Test
+ @InSequence(1)
+ public void testTraditionalAPIReferenceBinding(@ArquillianResource Bundle bundle) throws Exception {
+
+ // Get the InitialContext via API
+ Hashtable<String, String> env = new Hashtable<String, String>();
+ env.put(Context.INITIAL_CONTEXT_FACTORY, SimpleInitalContextFactory.class.getName());
+ Context initialContext = new InitialContext(env);
+
+ // Bind a some value reference under some key
+ Reference ref = new StringReference("bar");
+ initialContext.bind("test/foo", ref);
+ try {
+ // Lookup the value
+ Assert.assertEquals("bar", initialContext.lookup("test/foo"));
+ } finally {
+ initialContext.unbind("test/foo");
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 4ef4a29

Please sign in to comment.