Migrated to Karaf 4.  This was required to support Jetty 9.2.x.
Fixed all OSGi unit tests.
This commit is contained in:
Christopher L. Shannon (cshannon) 2015-08-25 15:47:41 +00:00
parent f44c3d20ed
commit 0f492f3b4b
12 changed files with 140 additions and 77 deletions

View File

@ -31,6 +31,7 @@ import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.servlets.gzip.GzipHandler;
public class HttpTransportServer extends WebTransportServerSupport {
@ -118,12 +119,7 @@ public class HttpTransportServer extends WebTransportServerSupport {
return (Integer)connector.getClass().getMethod("getLocalPort").invoke(connector);
}
private void addGzipHandler(ServletContextHandler contextHandler) throws Exception {
Handler handler = null;
try {
handler = (Handler)Class.forName("org.eclipse.jetty.server.handler.GzipHandler", true, Handler.class.getClassLoader()).newInstance();
} catch (Throwable t) {
handler = (Handler)Class.forName("org.eclipse.jetty.servlets.gzip.GzipHandler", true, Handler.class.getClassLoader()).newInstance();
}
Handler handler = new GzipHandler();
contextHandler.setHandler(handler);
}

View File

@ -17,11 +17,14 @@
package org.apache.activemq.karaf.itest;
import javax.security.auth.Subject;
import org.apache.felix.service.command.CommandProcessor;
import org.apache.felix.service.command.CommandSession;
import org.apache.karaf.features.FeaturesService;
import org.apache.karaf.jaas.boot.principal.RolePrincipal;
import org.apache.karaf.jaas.boot.principal.UserPrincipal;
import org.apache.karaf.shell.api.console.Session;
import org.apache.karaf.shell.api.console.SessionFactory;
import org.junit.After;
import org.junit.Before;
import org.ops4j.pax.exam.Option;
@ -37,6 +40,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
@ -50,7 +54,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import static org.ops4j.pax.exam.CoreOptions.*;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.*;
@ -96,18 +99,20 @@ public abstract class AbstractFeatureTest {
}
@Inject
CommandProcessor commandProcessor;
SessionFactory sessionFactory;
ExecutorService executor = Executors.newCachedThreadPool();
protected String executeCommand(final String command, final Long timeout, final Boolean silent) {
String response;
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
final PrintStream printStream = new PrintStream(byteArrayOutputStream);
final CommandSession commandSession = commandProcessor.createSession(System.in, printStream, printStream);
final Session commandSession = sessionFactory.create(System.in, printStream, printStream);
commandSession.put("APPLICATION", System.getProperty("karaf.name", "root"));
commandSession.put("USER", USER);
FutureTask<String> commandFuture = new FutureTask<String>(
new Callable<String>() {
@Override
public String call() {
Subject subject = new Subject();
@ -154,13 +159,13 @@ public abstract class AbstractFeatureTest {
* @throws Exception
*/
public void installAndAssertFeature(final String feature) throws Throwable {
executeCommand("osgi:list -t 0");
executeCommand("features:install " + feature);
executeCommand("feature:list -i");
executeCommand("feature:install " + feature);
assertFeatureInstalled(feature);
}
public void assertFeatureInstalled(final String feature) throws Throwable {
executeCommand("osgi:list -t 0");
executeCommand("feature:list -i");
withinReason(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
@ -174,7 +179,7 @@ public abstract class AbstractFeatureTest {
boolean found = false;
for (Bundle bundle: bundleContext.getBundles()) {
LOG.debug("Checking: " + bundle.getSymbolicName());
if (bundle.getSymbolicName().equals(bundleName)) {
if (bundle.getSymbolicName().contains(bundleName)) {
found = true;
break;
}
@ -251,6 +256,11 @@ public abstract class AbstractFeatureTest {
editConfigurationFilePut("etc/config.properties", "karaf.startlevel.bundle", "50"),
//debugConfiguration("5005", true),
features(getActiveMQKarafFeatureUrl(), f.toArray(new String[f.size()]))};
if (f.contains("activemq-camel")) {
options = append(features(maven().groupId("org.apache.camel.karaf").artifactId("apache-camel")
.versionAsInProject()
.type("xml/features")), options);
}
return options;
}

View File

@ -16,9 +16,14 @@
*/
package org.apache.activemq.karaf.itest;
import static org.junit.Assert.assertTrue;
import java.util.concurrent.Callable;
import javax.jms.Connection;
import org.apache.qpid.jms.JmsConnectionFactory;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -27,31 +32,40 @@ import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import java.util.concurrent.Callable;
import static org.junit.Assert.assertTrue;
@RunWith(PaxExam.class)
public class ActiveMQAMQPBrokerFeatureTest extends ActiveMQBrokerFeatureTest {
private static final Integer AMQP_PORT = 61636;
@Configuration
public static Option[] configure() {
Option[] activeMQOptions = configure("activemq");
Option netty = CoreOptions.wrappedBundle(CoreOptions.mavenBundle("io.netty", "netty-all").versionAsInProject().getURL().toString() + "$Bundle-SymbolicName=netty-all");
Option protonJ = CoreOptions.wrappedBundle(CoreOptions.mavenBundle("org.apache.qpid", "proton-j").versionAsInProject().getURL().toString() + "$Bundle-SymbolicName=proton-j");
Option qpidClient = CoreOptions.wrappedBundle(CoreOptions.mavenBundle("org.apache.qpid", "qpid-jms-client").versionAsInProject().getURL().toString() + "$Bundle-SymbolicName=qpid-jms-client");
Option[] configure = configure("activemq");
Option[] options = append(protonJ, activeMQOptions);
options = append(netty, options);
options = append(qpidClient, options);
Option[] configuredOptions = configureBrokerStart(configure);
Option[] configuredOptions = configureBrokerStart(options);
return configuredOptions;
}
@Before
public void setUpBundle() {
installWrappedBundle(CoreOptions.wrappedBundle(CoreOptions.mavenBundle(
"io.netty", "netty-all").version(
getArtifactVersion("io.netty", "netty-all")).getURL().toString()
+ "$Bundle-SymbolicName=qpid-jms-client"));
installWrappedBundle(CoreOptions.wrappedBundle(CoreOptions.mavenBundle(
"org.apache.qpid", "proton-j").version(
getArtifactVersion("org.apache.qpid", "proton-j")).getURL()));
installWrappedBundle(CoreOptions.wrappedBundle(CoreOptions.mavenBundle(
"org.apache.qpid", "qpid-jms-client").version(
getArtifactVersion("org.apache.qpid", "qpid-jms-client")).getURL()));
}
@Override
protected Connection getConnection() throws Throwable {
setUpBundle();
withinReason(new Callable<Boolean>() {
@Override

View File

@ -16,13 +16,19 @@
*/
package org.apache.activemq.karaf.itest;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.concurrent.Callable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.options.WrappedUrlProvisionOption;
import javax.jms.Connection;
import javax.jms.Message;
@ -41,6 +47,32 @@ public class ActiveMQBrokerFeatureTest extends AbstractJmsFeatureTest {
return configureBrokerStart(configure("activemq"));
}
protected final File file = new File("../../../classes/META-INF/maven/dependencies.properties");
public final String getArtifactVersion(final String groupId, final String artifactId) {
final Properties dependencies = new Properties();
try (FileInputStream fis = new FileInputStream(file)){
dependencies.load(fis);
final String version = dependencies
.getProperty(groupId + "/" + artifactId + "/version");
if (version == null) {
throw new RuntimeException(
"Could not resolve version. Do you have a dependency for " + groupId + "/"
+ artifactId + " in your maven project?");
}
return version;
}
catch (IOException e) {
throw new RuntimeException("Could not resolve version for groupId:" + groupId
+ " artifactId:" + artifactId
+ " by reading the dependency information generated by maven.", e);
}
}
protected String installWrappedBundle(WrappedUrlProvisionOption option) {
return executeCommand("bundle:install 'wrap:" + option.getURL() + "'");
}
@Test(timeout=5 * 60 * 1000)
public void test() throws Throwable {

View File

@ -19,6 +19,8 @@ package org.apache.activemq.karaf.itest;
import java.io.File;
import java.util.Date;
import java.util.concurrent.Callable;
import org.apache.karaf.features.Feature;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -27,7 +29,6 @@ import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.junit.PaxExam;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
@ -41,17 +42,16 @@ public class ActiveMQBrokerNdCamelFeatureTest extends AbstractJmsFeatureTest {
public static Option[] configure() {
return append(
editConfigurationFilePut("etc/system.properties", "camel.version", MavenUtils.getArtifactVersion("org.apache.camel.karaf", "apache-camel")),
configure("activemq"));
configure("activemq", "activemq-camel"));
}
@Test(timeout = 2 * 60 * 1000)
public void test() throws Throwable {
System.err.println(executeCommand("osgi:list").trim());
System.err.println(executeCommand("feature:list").trim());
assertFeatureInstalled("activemq");
executeCommand("features:addurl " + getCamelFeatureUrl());
installAndAssertFeature("activemq-camel");
assertTrue("activemq-camel bundle installed", verifyBundleInstalled("org.apache.activemq.activemq-camel"));
withinReason(new Callable<Boolean>() {
@Override

View File

@ -85,7 +85,7 @@ public class ObrFeatureTest extends AbstractFeatureTest {
@Test(timeout=5 * 60 * 1000)
public void testCamel() throws Throwable {
executeCommand("features:addurl " + getCamelFeatureUrl());
executeCommand("feature:repo-add " + getCamelFeatureUrl());
installAndAssertFeature("activemq-camel");
}
}

View File

@ -43,12 +43,12 @@
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-api</artifactId>
<version>1.6.2</version>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-service</artifactId>
<version>1.6.2</version>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@ -59,16 +59,21 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.aries.blueprint</groupId>
<artifactId>org.apache.aries.blueprint.core</artifactId>
<version>1.4.4</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>1.0.0</version>
<version>5.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.bundlerepository</artifactId>
<version>1.2.1</version>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.karaf.shell</groupId>

View File

@ -206,7 +206,7 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>4.3.1</version>
<version>${org.osgi.core-version}</version>
<scope>provided</scope>
</dependency>

View File

@ -1,3 +1,19 @@
/**
* 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.activemq.bugs;
import static org.junit.Assert.assertEquals;

View File

@ -324,7 +324,7 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>4.3.1</version>
<version>${org.osgi.core-version}</version>
<scope>provided</scope>
</dependency>

View File

@ -262,7 +262,7 @@
<include>org.mortbay.jasper:apache-el</include>
<include>org.apache.taglibs:taglibs-standard-impl</include>
<include>org.apache.geronimo.specs:geronimo-annotation_1.0_spec</include>
<include>org.apache.geronimo.specs:geronimo-annotation_1.0_spec</include>
<include>org.ow2.asm:asm</include>
<include>org.eclipse.jetty.orbit:org.eclipse.jdt.core</include>

68
pom.xml
View File

@ -88,7 +88,7 @@
<junit-version>4.12</junit-version>
<hamcrest-version>1.3</hamcrest-version>
<jxta-version>2.0</jxta-version>
<karaf-version>2.4.1</karaf-version>
<karaf-version>4.0.1</karaf-version>
<leveldb-api-version>0.6</leveldb-api-version>
<leveldb-version>0.6</leveldb-version>
<leveldbjni-version>1.8</leveldbjni-version>
@ -130,12 +130,12 @@
<jaxb-basics-version>0.6.4</jaxb-basics-version>
<stompjms-version>1.19</stompjms-version>
<pax-exam-version>4.3.0</pax-exam-version>
<pax-exam-version>4.6.0</pax-exam-version>
<paxexam-karaf-container-version>1.0.0</paxexam-karaf-container-version>
<pax-runner-version>1.6.1</pax-runner-version>
<pax-url-version>2.3.0</pax-url-version>
<pax-url-version>2.4.1</pax-url-version>
<felix-configadmin-version>1.8.0</felix-configadmin-version>
<felix-framework-version>4.4.1</felix-framework-version>
<felix-framework-version>5.0.1</felix-framework-version>
<site-repo-url>scpexe://people.apache.org/www/activemq.apache.org/maven/</site-repo-url>
<source-version>1.7</source-version>
@ -537,11 +537,11 @@
<artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>5.0.3</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>5.0.3</version>
</dependency>
<!-- Servlet 3.1 and JSP -->
<dependency>
@ -944,26 +944,26 @@
<version>${jetty-version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all</artifactId>
<version>${jetty-version}</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>${jetty-version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all</artifactId>
<version>${jetty-version}</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>${jetty-version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
@ -1086,16 +1086,6 @@
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j-version}</version>
</dependency>
<!-- >dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl-version}</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency -->
<dependency>
<groupId>org.apache.geronimo.components</groupId>