Repository: aries-jax-rs-whiteboard Updated Branches: refs/heads/master 3df0d7a93 -> 757c964c9
reuseable test functions Signed-off-by: Raymond Auge <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/repo Commit: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/commit/757c964c Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/757c964c Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/757c964c Branch: refs/heads/master Commit: 757c964c952f61e11dd570247c2f6ae44d082406 Parents: 3df0d7a Author: Raymond Auge <[email protected]> Authored: Fri Aug 4 09:39:46 2017 -0400 Committer: Raymond Auge <[email protected]> Committed: Fri Aug 4 09:39:46 2017 -0400 ---------------------------------------------------------------------- jax-rs.itests/src/main/java/test/JaxrsTest.java | 40 ++----------- .../src/main/java/test/types/TestHelper.java | 61 ++++++++++++++++++++ 2 files changed, 65 insertions(+), 36 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/757c964c/jax-rs.itests/src/main/java/test/JaxrsTest.java ---------------------------------------------------------------------- diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java b/jax-rs.itests/src/main/java/test/JaxrsTest.java index 1f50052..b8abfa3 100644 --- a/jax-rs.itests/src/main/java/test/JaxrsTest.java +++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java @@ -23,12 +23,8 @@ import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.*; import java.util.Dictionary; import java.util.Hashtable; -import org.junit.After; -import org.junit.Before; import org.junit.Test; import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; import org.osgi.framework.PrototypeServiceFactory; import org.osgi.framework.ServiceFactory; import org.osgi.framework.ServiceRegistration; @@ -42,9 +38,9 @@ import test.types.TestAddonLifecycle; import test.types.TestApplication; import test.types.TestApplicationConflict; import test.types.TestFilter; +import test.types.TestHelper; import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Application; import javax.ws.rs.core.Response; @@ -53,21 +49,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; -public class JaxrsTest { - - private ServiceTracker<ClientBuilder, ClientBuilder> _clientBuilderTracker; - - @After - public void after() { - _clientBuilderTracker.close(); - } - - @Before - public void before() { - _clientBuilderTracker = new ServiceTracker<>(bundleContext, ClientBuilder.class, null); - - _clientBuilderTracker.open(); - } +public class JaxrsTest extends TestHelper { @Test public void testApplication() { @@ -103,6 +85,7 @@ public class JaxrsTest { target("http://localhost:8080"). path("test-application"); + @SuppressWarnings("rawtypes") ServiceTracker serviceTracker = new ServiceTracker<>( bundleContext, FailedApplicationDTO.class, null); @@ -162,6 +145,7 @@ public class JaxrsTest { target("http://localhost:8080"). path("test-application"); + @SuppressWarnings("rawtypes") ServiceTracker serviceTracker = new ServiceTracker<>( bundleContext, FailedApplicationDTO.class, null); @@ -214,9 +198,6 @@ public class JaxrsTest { } } - static BundleContext bundleContext = FrameworkUtil.getBundle( - JaxrsTest.class).getBundleContext(); - @Test public void testApplicationReadd() { Client client = createClient(); @@ -742,19 +723,6 @@ public class JaxrsTest { } } - private Client createClient() { - ClientBuilder clientBuilder; - - try { - clientBuilder = _clientBuilderTracker.waitForService(5000); - - return clientBuilder.build(); - } - catch (InterruptedException ie) { - throw new RuntimeException(ie); - } - } - private ServiceRegistration<?> registerAddon(Object instance, Object ... keyValues) { Dictionary<String, Object> properties = new Hashtable<>(); http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/757c964c/jax-rs.itests/src/main/java/test/types/TestHelper.java ---------------------------------------------------------------------- diff --git a/jax-rs.itests/src/main/java/test/types/TestHelper.java b/jax-rs.itests/src/main/java/test/types/TestHelper.java new file mode 100644 index 0000000..3803558 --- /dev/null +++ b/jax-rs.itests/src/main/java/test/types/TestHelper.java @@ -0,0 +1,61 @@ +/* + * 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 test.types; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; + +import org.junit.After; +import org.junit.Before; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.util.tracker.ServiceTracker; + +public class TestHelper { + + public static BundleContext bundleContext = FrameworkUtil.getBundle( + TestHelper.class).getBundleContext(); + + private ServiceTracker<ClientBuilder, ClientBuilder> _clientBuilderTracker; + + @After + public void after() { + _clientBuilderTracker.close(); + } + + @Before + public void before() { + _clientBuilderTracker = new ServiceTracker<>(bundleContext, ClientBuilder.class, null); + + _clientBuilderTracker.open(); + } + + protected Client createClient() { + ClientBuilder clientBuilder; + + try { + clientBuilder = _clientBuilderTracker.waitForService(5000); + + return clientBuilder.build(); + } + catch (InterruptedException ie) { + throw new RuntimeException(ie); + } + } + +}
