You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2017/08/04 12:22:46 UTC

cxf git commit: [CXF-7466] Renaming some test classes for a start

Repository: cxf
Updated Branches:
  refs/heads/master d86a5597a -> abaaa756e


[CXF-7466] Renaming some test classes for a start


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/abaaa756
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/abaaa756
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/abaaa756

Branch: refs/heads/master
Commit: abaaa756eb2f979792dfb966238eacf58e4144a9
Parents: d86a559
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Fri Aug 4 13:22:31 2017 +0100
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Fri Aug 4 13:22:31 2017 +0100

----------------------------------------------------------------------
 .../reactive/JAXRSCompletionStageTest.java      |  23 +---
 .../jaxrs/reactive/JAXRSObservableTest.java     |  24 ++--
 .../systest/jaxrs/reactive/ReactiveServer.java  |  79 -----------
 .../systest/jaxrs/reactive/ReactiveService.java | 130 -------------------
 4 files changed, 18 insertions(+), 238 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/abaaa756/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSCompletionStageTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSCompletionStageTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSCompletionStageTest.java
index b6a4fb7..6a982a6 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSCompletionStageTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSCompletionStageTest.java
@@ -28,36 +28,25 @@ import javax.xml.ws.Holder;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
 import org.apache.cxf.systest.jaxrs.Book;
-import org.apache.cxf.systest.jaxrs.BookServerAsyncClient;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 
-import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
 public class JAXRSCompletionStageTest extends AbstractBusClientServerTestBase {
-    public static final String PORT = BookServerAsyncClient.PORT;
+    public static final String PORT = CompletableFutureServer.PORT;
 
     @BeforeClass
     public static void startServers() throws Exception {
         AbstractResourceInfo.clearAllMaps();
         assertTrue("server did not launch correctly",
-                   launchServer(BookServerAsyncClient.class, true));
+                   launchServer(CompletableFutureServer.class, true));
         createStaticBus();
     }
 
-    @Before
-    public void setUp() throws Exception {
-        String property = System.getProperty("test.delay");
-        if (property != null) {
-            Thread.sleep(Long.valueOf(property));
-        }
-    }
-
-
     @Test
     public void testGetBookAsyncStage() throws Exception {
-        String address = "http://localhost:" + PORT + "/bookstore/books";
+        String address = "http://localhost:" + PORT + "/completable/books";
         WebClient wc = createWebClient(address);
         CompletionStage<Book> stage = wc.path("123").rx().get(Book.class);
         Book book = stage.toCompletableFuture().join();
@@ -65,7 +54,7 @@ public class JAXRSCompletionStageTest extends AbstractBusClientServerTestBase {
     }
     @Test
     public void testGetBookAsyncStageThenAcceptAsync() throws Exception {
-        String address = "http://localhost:" + PORT + "/bookstore/books";
+        String address = "http://localhost:" + PORT + "/completable/books";
         WebClient wc = createWebClient(address);
         CompletionStage<Book> stage = wc.path("123").rx().get(Book.class);
         Holder<Book> holder = new Holder<Book>();
@@ -81,9 +70,9 @@ public class JAXRSCompletionStageTest extends AbstractBusClientServerTestBase {
 
     @Test
     public void testGetBookAsyncStage404() throws Exception {
-        String address = "http://localhost:" + PORT + "/bookstore/bookheaders/404";
+        String address = "http://localhost:" + PORT + "/completable/books";
         WebClient wc = createWebClient(address);
-        CompletionStage<Book> stage = wc.path("123").rx().get(Book.class);
+        CompletionStage<Book> stage = wc.path("124").rx().get(Book.class);
         try {
             stage.toCompletableFuture().get();
             fail("Exception expected");

http://git-wip-us.apache.org/repos/asf/cxf/blob/abaaa756/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSObservableTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSObservableTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSObservableTest.java
index 08106ea..a0d8af8 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSObservableTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSObservableTest.java
@@ -43,24 +43,24 @@ import org.junit.Test;
 import rx.Observable;
 
 public class JAXRSObservableTest extends AbstractBusClientServerTestBase {
-    public static final String PORT = ReactiveServer.PORT;
+    public static final String PORT = ObservableServer.PORT;
     @BeforeClass
     public static void startServers() throws Exception {
         AbstractResourceInfo.clearAllMaps();
         assertTrue("server did not launch correctly",
-                   launchServer(ReactiveServer.class, true));
+                   launchServer(ObservableServer.class, true));
         createStaticBus();
     }
     @Test
     public void testGetHelloWorldText() throws Exception {
-        String address = "http://localhost:" + PORT + "/reactive/text";
+        String address = "http://localhost:" + PORT + "/observable/text";
         WebClient wc = WebClient.create(address);
         String text = wc.accept("text/plain").get(String.class);
         assertEquals("Hello, world!", text);
     }
     @Test
     public void testGetHelloWorldAsyncText() throws Exception {
-        String address = "http://localhost:" + PORT + "/reactive/textAsync";
+        String address = "http://localhost:" + PORT + "/observable/textAsync";
         WebClient wc = WebClient.create(address);
         String text = wc.accept("text/plain").get(String.class);
         assertEquals("Hello, world!", text);
@@ -68,7 +68,7 @@ public class JAXRSObservableTest extends AbstractBusClientServerTestBase {
 
     @Test
     public void testGetHelloWorldTextObservableSync() throws Exception {
-        String address = "http://localhost:" + PORT + "/reactive/text";
+        String address = "http://localhost:" + PORT + "/observable/text";
         WebClient wc = WebClient.create(address, Collections.singletonList(
             new ObservableReader<Object>()));
         GenericType<Observable<String>> genericResponseType =
@@ -83,7 +83,7 @@ public class JAXRSObservableTest extends AbstractBusClientServerTestBase {
     }
     @Test
     public void testGetHelloWorldJson() throws Exception {
-        String address = "http://localhost:" + PORT + "/reactive/textJson";
+        String address = "http://localhost:" + PORT + "/observable/textJson";
         WebClient wc = WebClient.create(address,
                                         Collections.singletonList(new JacksonJsonProvider()));
         HelloWorldBean bean = wc.accept("application/json").get(HelloWorldBean.class);
@@ -92,22 +92,22 @@ public class JAXRSObservableTest extends AbstractBusClientServerTestBase {
     }
     @Test
     public void testGetHelloWorldJsonList() throws Exception {
-        String address = "http://localhost:" + PORT + "/reactive/textJsonList";
+        String address = "http://localhost:" + PORT + "/observable/textJsonList";
         doTestGetHelloWorldJsonList(address);
     }
     @Test
     public void testGetHelloWorldJsonImplicitList() throws Exception {
-        String address = "http://localhost:" + PORT + "/reactive/textJsonImplicitList";
+        String address = "http://localhost:" + PORT + "/observable/textJsonImplicitList";
         doTestGetHelloWorldJsonList(address);
     }
     @Test
     public void testGetHelloWorldJsonImplicitListAsync() throws Exception {
-        String address = "http://localhost:" + PORT + "/reactive/textJsonImplicitListAsync";
+        String address = "http://localhost:" + PORT + "/observable/textJsonImplicitListAsync";
         doTestGetHelloWorldJsonList(address);
     }
     @Test
     public void testGetHelloWorldJsonImplicitListAsyncStream() throws Exception {
-        String address = "http://localhost:" + PORT + "/reactive/textJsonImplicitListAsyncStream";
+        String address = "http://localhost:" + PORT + "/observable/textJsonImplicitListAsyncStream";
         doTestGetHelloWorldJsonList(address);
     }
     private void doTestGetHelloWorldJsonList(String address) throws Exception {
@@ -127,7 +127,7 @@ public class JAXRSObservableTest extends AbstractBusClientServerTestBase {
 
     @Test
     public void testGetHelloWorldAsyncObservable() throws Exception {
-        String address = "http://localhost:" + PORT + "/reactive/textAsync";
+        String address = "http://localhost:" + PORT + "/observable/textAsync";
         WebClient wc = WebClient.create(address,
                                         Collections.singletonList(new ObservableRxInvokerProvider()));
         Observable<String> obs = wc.accept("text/plain")
@@ -143,7 +143,7 @@ public class JAXRSObservableTest extends AbstractBusClientServerTestBase {
     }
     @Test
     public void testGetHelloWorldAsyncObservable404() throws Exception {
-        String address = "http://localhost:" + PORT + "/reactive/textAsync404";
+        String address = "http://localhost:" + PORT + "/observable/textAsync404";
         Invocation.Builder b = ClientBuilder.newClient().register(new ObservableRxInvokerProvider())
             .target(address).request();
         b.rx(ObservableRxInvoker.class).get(String.class).subscribe(

http://git-wip-us.apache.org/repos/asf/cxf/blob/abaaa756/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveServer.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveServer.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveServer.java
deleted file mode 100644
index aa52b64..0000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveServer.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * 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.cxf.systest.jaxrs.reactive;
-
-import java.util.Collections;
-
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.ext.logging.LoggingOutInterceptor;
-import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
-import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
-import org.apache.cxf.jaxrs.provider.StreamingResponseProvider;
-import org.apache.cxf.jaxrs.rx.provider.ObservableWriter;
-import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
-
-
-public class ReactiveServer extends AbstractBusTestServerBase {
-    public static final String PORT = allocatePort(ReactiveServer.class);
-
-    org.apache.cxf.endpoint.Server server;
-    public ReactiveServer() {
-    }
-
-    protected void run() {
-        Bus bus = BusFactory.getDefaultBus();
-        // Make sure default JSONProvider is not loaded
-        bus.setProperty("skip.default.json.provider.registration", true);
-        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
-        sf.setProvider(new ObservableWriter<Object>());
-        sf.setProvider(new JacksonJsonProvider());
-        StreamingResponseProvider<HelloWorldBean> streamProvider = new StreamingResponseProvider<HelloWorldBean>();
-        streamProvider.setProduceMediaTypes(Collections.singletonList("application/json"));
-        sf.setProvider(streamProvider);
-        sf.getOutInterceptors().add(new LoggingOutInterceptor());
-        sf.setResourceClasses(ReactiveService.class);
-        sf.setResourceProvider(ReactiveService.class,
-                               new SingletonResourceProvider(new ReactiveService(), true));
-        sf.setAddress("http://localhost:" + PORT + "/");
-        server = sf.create();
-    }
-
-    public void tearDown() throws Exception {
-        server.stop();
-        server.destroy();
-        server = null;
-    }
-
-    public static void main(String[] args) {
-        try {
-            ReactiveServer s = new ReactiveServer();
-            s.start();
-        } catch (Exception ex) {
-            ex.printStackTrace();
-            System.exit(-1);
-        } finally {
-            System.out.println("done!");
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/abaaa756/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveService.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveService.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveService.java
deleted file mode 100644
index 0e6066e..0000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveService.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- * 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.cxf.systest.jaxrs.reactive;
-
-
-import java.util.Arrays;
-import java.util.List;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.container.AsyncResponse;
-import javax.ws.rs.container.Suspended;
-
-import org.apache.cxf.jaxrs.rx.server.AbstractAsyncSubscriber;
-import org.apache.cxf.jaxrs.rx.server.JsonStreamingAsyncSubscriber;
-import org.apache.cxf.jaxrs.rx.server.ListAsyncSubscriber;
-
-import rx.Observable;
-import rx.schedulers.Schedulers;
-
-
-@Path("/reactive")
-public class ReactiveService {
-
-    @GET
-    @Produces("text/plain")
-    @Path("text")
-    public Observable<String> getText() {
-        return Observable.just("Hello, world!");
-    }
-
-    @GET
-    @Produces("text/plain")
-    @Path("textAsync")
-    public void getTextAsync(@Suspended final AsyncResponse ar) {
-        Observable.just("Hello, ").map(s -> s + "world!")
-            .subscribe(new StringAsyncSubscriber(ar));
-
-    }
-
-    @GET
-    @Produces("application/json")
-    @Path("textJson")
-    public Observable<HelloWorldBean> getJson() {
-        return Observable.just(new HelloWorldBean());
-    }
-
-    @GET
-    @Produces("application/json")
-    @Path("textJsonImplicitList")
-    public Observable<HelloWorldBean> getJsonImplicitList() {
-        HelloWorldBean bean1 = new HelloWorldBean();
-        HelloWorldBean bean2 = new HelloWorldBean("Ciao");
-        return Observable.just(bean1, bean2);
-    }
-    @GET
-    @Produces("application/json")
-    @Path("textJsonImplicitListAsync")
-    public void getJsonImplicitListAsync(@Suspended AsyncResponse ar) {
-        final HelloWorldBean bean1 = new HelloWorldBean();
-        final HelloWorldBean bean2 = new HelloWorldBean("Ciao");
-        new Thread(new Runnable() {
-            public void run() {
-                try {
-                    Thread.sleep(2000);
-                } catch (InterruptedException ex) {
-                    // ignore
-                }
-                Observable.just(bean1, bean2).subscribe(new ListAsyncSubscriber<HelloWorldBean>(ar));
-            }
-        }).start();
-
-    }
-    @GET
-    @Produces("application/json")
-    @Path("textJsonImplicitListAsyncStream")
-    public void getJsonImplicitListStreamingAsync(@Suspended AsyncResponse ar) {
-        Observable.just("Hello", "Ciao")
-            .map(s -> new HelloWorldBean(s))
-            .subscribeOn(Schedulers.computation())
-            .subscribe(new JsonStreamingAsyncSubscriber<HelloWorldBean>(ar));
-    }
-    @GET
-    @Produces("application/json")
-    @Path("textJsonList")
-    public Observable<List<HelloWorldBean>> getJsonList() {
-        HelloWorldBean bean1 = new HelloWorldBean();
-        HelloWorldBean bean2 = new HelloWorldBean();
-        bean2.setGreeting("Ciao");
-        return Observable.just(Arrays.asList(bean1, bean2));
-    }
-
-    private class StringAsyncSubscriber extends AbstractAsyncSubscriber<String> {
-
-        private StringBuilder sb = new StringBuilder();
-        StringAsyncSubscriber(AsyncResponse ar) {
-            super(ar);
-        }
-        @Override
-        public void onCompleted() {
-            super.resume(sb.toString());
-        }
-
-        @Override
-        public void onNext(String s) {
-            sb.append(s);
-        }
-
-    }
-}
-
-