Repository: cxf-dosgi Updated Branches: refs/heads/master 90f706e37 -> b77a90308
[DOSGI-241] Simplify examples Project: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/commit/b77a9030 Tree: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/tree/b77a9030 Diff: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/diff/b77a9030 Branch: refs/heads/master Commit: b77a9030803aeb683f47b5dc99da0c28e09abdcc Parents: 90f706e Author: Christian Schneider <[email protected]> Authored: Thu Jun 30 16:49:31 2016 +0200 Committer: Christian Schneider <[email protected]> Committed: Thu Jun 30 16:49:31 2016 +0200 ---------------------------------------------------------------------- .../multi/GreeterServiceProxyFactory.java | 18 ++++++++---- .../dosgi/systests2/multi/TestCustomIntent.java | 31 ++++++++------------ .../systests2/multi/TestExportService.java | 2 -- 3 files changed, 24 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b77a9030/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/GreeterServiceProxyFactory.java ---------------------------------------------------------------------- diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/GreeterServiceProxyFactory.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/GreeterServiceProxyFactory.java index 87ccb0f..074a6f1 100644 --- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/GreeterServiceProxyFactory.java +++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/GreeterServiceProxyFactory.java @@ -23,16 +23,22 @@ import org.apache.cxf.dosgi.samples.greeter.GreeterService; import org.apache.cxf.frontend.ClientProxyFactoryBean; public final class GreeterServiceProxyFactory { - + private GreeterServiceProxyFactory() { } protected static GreeterService createGreeterServiceProxy(String serviceUri) { - ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); - factory.setServiceClass(GreeterService.class); - factory.setAddress(serviceUri); - factory.getServiceFactory().setDataBinding(new AegisDatabinding()); - return (GreeterService)factory.create(); + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader()); + try { + ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); + factory.setServiceClass(GreeterService.class); + factory.setAddress(serviceUri); + factory.getServiceFactory().setDataBinding(new AegisDatabinding()); + return (GreeterService)factory.create(); + } finally { + Thread.currentThread().setContextClassLoader(cl); + } } } http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b77a9030/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java ---------------------------------------------------------------------- diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java index 0a94a65..769f118 100644 --- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java +++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java @@ -18,6 +18,13 @@ */ package org.apache.cxf.dosgi.systests2.multi; +import static org.apache.cxf.dosgi.systests2.multi.GreeterServiceProxyFactory.createGreeterServiceProxy; +import static org.ops4j.pax.exam.CoreOptions.frameworkStartLevel; +import static org.ops4j.pax.exam.CoreOptions.mavenBundle; +import static org.ops4j.pax.exam.CoreOptions.provision; +import static org.ops4j.pax.exam.CoreOptions.streamBundle; +import static org.ops4j.pax.exam.CoreOptions.systemProperty; + import java.io.InputStream; import java.util.Map; @@ -30,7 +37,6 @@ import org.apache.cxf.dosgi.systests2.multi.customintent.CustomFeature; import org.apache.cxf.dosgi.systests2.multi.customintent.CustomIntentActivator; import org.apache.cxf.dosgi.systests2.multi.customintent.service.EmptyGreeterService; import org.apache.cxf.dosgi.systests2.multi.customintent.service.GreeterServiceWithCustomIntentActivator; -import org.apache.cxf.frontend.ClientProxyFactoryBean; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -41,13 +47,6 @@ import org.ops4j.pax.tinybundles.core.TinyBundles; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; -import static org.apache.cxf.dosgi.systests2.multi.GreeterServiceProxyFactory.createGreeterServiceProxy; -import static org.ops4j.pax.exam.CoreOptions.frameworkStartLevel; -import static org.ops4j.pax.exam.CoreOptions.mavenBundle; -import static org.ops4j.pax.exam.CoreOptions.provision; -import static org.ops4j.pax.exam.CoreOptions.streamBundle; -import static org.ops4j.pax.exam.CoreOptions.systemProperty; - @RunWith(PaxExam.class) public class TestCustomIntent extends AbstractDosgiTest { @@ -95,16 +94,10 @@ public class TestCustomIntent extends AbstractDosgiTest { getBundleByName(bundleContext, "CustomIntent").start(); waitPort(9090); - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader()); - try { - GreeterService greeterService = createGreeterServiceProxy("http://localhost:9090/greeter"); - Map<GreetingPhrase, String> result = greeterService.greetMe("Chris"); - Assert.assertEquals(1, result.size()); - GreetingPhrase phrase = result.keySet().iterator().next(); - Assert.assertEquals("Hi from custom intent", phrase.getPhrase()); - } finally { - Thread.currentThread().setContextClassLoader(cl); - } + GreeterService greeterService = createGreeterServiceProxy("http://localhost:9090/greeter"); + Map<GreetingPhrase, String> result = greeterService.greetMe("Chris"); + Assert.assertEquals(1, result.size()); + GreetingPhrase phrase = result.keySet().iterator().next(); + Assert.assertEquals("Hi from custom intent", phrase.getPhrase()); } } http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b77a9030/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java ---------------------------------------------------------------------- diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java index e3a832f..3c3861b 100644 --- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java +++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java @@ -53,8 +53,6 @@ public class TestExportService extends AbstractDosgiTest { return new Option[] { MultiBundleTools.getDistro(), systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"), - mavenBundle().groupId("org.apache.servicemix.bundles") - .artifactId("org.apache.servicemix.bundles.junit").version("4.9_2"), mavenBundle().groupId("org.apache.cxf.dosgi.samples") .artifactId("cxf-dosgi-ri-samples-greeter-interface").versionAsInProject(), mavenBundle().groupId("org.apache.cxf.dosgi.samples")
