cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [1/2] cxf git commit: Adding JAX-RS LB test
Date Mon, 03 Apr 2017 12:16:27 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 3b3b81e69 -> 0e955bc5d


Adding JAX-RS LB test


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

Branch: refs/heads/3.0.x-fixes
Commit: 0e955bc5da84d0826dd8dfbb01737b5d2d286636
Parents: 3b6be59
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Fri Mar 31 15:07:09 2017 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Mon Apr 3 13:16:11 2017 +0100

----------------------------------------------------------------------
 .../jaxrs/failover/FailoverWebClientTest.java   |  2 +-
 .../jaxrs/failover/LoadDistributorServer.java   | 43 +++++++++++
 .../failover/LoadDistributorWebClientTest.java  | 80 ++++++++++++++++++++
 .../cxf/systest/jaxrs/failover/cxf-client.xml   | 43 +++++++++++
 .../systest/jaxrs/failover/cxf-lb-service.xml   | 65 ++++++++++++++++
 5 files changed, 232 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/0e955bc5/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/FailoverWebClientTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/FailoverWebClientTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/FailoverWebClientTest.java
index eb7269f..f77a429 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/FailoverWebClientTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/FailoverWebClientTest.java
@@ -50,7 +50,7 @@ public class FailoverWebClientTest extends AbstractBusClientServerTestBase
{
     }
 
     @Test
-    public void testEchoXmlBookQuery() throws Exception {
+    public void testFailover() throws Exception {
         String address = "http://localhost:" + PORT1 + "/bookstore";
 
         FailoverFeature failoverFeature = new FailoverFeature();

http://git-wip-us.apache.org/repos/asf/cxf/blob/0e955bc5/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorServer.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorServer.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorServer.java
new file mode 100644
index 0000000..99a7436
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorServer.java
@@ -0,0 +1,43 @@
+/**
+ * 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.failover;
+
+import java.net.URL;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class LoadDistributorServer extends AbstractBusTestServerBase {
+    protected void run()  {
+        URL busFile = Server.class.getResource("cxf-lb-service.xml");
+        Bus busLocal = new SpringBusFactory().createBus(busFile);
+        BusFactory.setDefaultBus(busLocal);
+        setBus(busLocal);
+
+        try {
+            new Server();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/0e955bc5/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorWebClientTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorWebClientTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorWebClientTest.java
new file mode 100644
index 0000000..03ce218
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorWebClientTest.java
@@ -0,0 +1,80 @@
+/**
+ * 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.failover;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.cxf.clustering.LoadDistributorFeature;
+import org.apache.cxf.clustering.SequentialStrategy;
+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.testutil.common.AbstractBusClientServerTestBase;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * A test for the load distributor using a WebClient object
+ */
+public class LoadDistributorWebClientTest extends AbstractBusClientServerTestBase {
+    static final String PORT1 = allocatePort(LoadDistributorServer.class);
+    static final String PORT2 = allocatePort(LoadDistributorServer.class, 2);
+
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        AbstractResourceInfo.clearAllMaps();
+        assertTrue("server did not launch correctly",
+                   launchServer(LoadDistributorServer.class, true));
+        createStaticBus();
+    }
+
+    @Test
+    public void testLoadDistributor() throws Exception {
+        URL busFile = LoadDistributorWebClientTest.class.getResource("cxf-client.xml");
+
+        String address = "http://localhost:" + PORT1 + "/bookstore";
+
+        LoadDistributorFeature feature = new LoadDistributorFeature();
+        SequentialStrategy strategy = new SequentialStrategy();
+        List<String> addresses = new ArrayList<>();
+        addresses.add(address);
+        addresses.add("http://localhost:" + PORT2 + "/bookstore");
+        strategy.setAlternateAddresses(addresses);
+        feature.setStrategy(strategy);
+
+        WebClient webClient = WebClient.create(address, null,
+                                               Collections.singletonList(feature),
+                                               busFile.toString()).accept("application/xml");
+
+        Book b = webClient.get(Book.class);
+        assertEquals(124L, b.getId());
+        assertEquals("root", b.getName());
+
+        b = webClient.get(Book.class);
+        assertEquals(124L, b.getId());
+        assertEquals("root", b.getName());
+
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf/blob/0e955bc5/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/failover/cxf-client.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/failover/cxf-client.xml
b/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/failover/cxf-client.xml
new file mode 100644
index 0000000..89d1245
--- /dev/null
+++ b/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/failover/cxf-client.xml
@@ -0,0 +1,43 @@
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xmlns:jaxrs="http://cxf.apache.org/jaxrs-client"
+   xmlns:cxf="http://cxf.apache.org/core"
+   xmlns:http="http://cxf.apache.org/transports/http/configuration"
+   xmlns:sec="http://cxf.apache.org/configuration/security"
+   xmlns:clustering="http://cxf.apache.org/clustering"
+   xmlns:util="http://www.springframework.org/schema/util"
+   xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
+http://cxf.apache.org/jaxrs-client http://cxf.apache.org/schemas/jaxrs-client.xsd
+http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+http://cxf.apache.org/clustering http://cxf.apache.org/schemas/clustering.xsd
+http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
+
+    <cxf:bus>
+        <cxf:features>
+            <cxf:logging/>
+        </cxf:features>
+    </cxf:bus>
+    
+</beans>
+

http://git-wip-us.apache.org/repos/asf/cxf/blob/0e955bc5/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/failover/cxf-lb-service.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/failover/cxf-lb-service.xml
b/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/failover/cxf-lb-service.xml
new file mode 100644
index 0000000..f16dd36
--- /dev/null
+++ b/systests/jaxrs/src/test/resources/org/apache/cxf/systest/jaxrs/failover/cxf-lb-service.xml
@@ -0,0 +1,65 @@
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:cxf="http://cxf.apache.org/core"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:sec="http://cxf.apache.org/configuration/security"
+  xmlns:http="http://cxf.apache.org/transports/http/configuration"
+  xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
+  xmlns:jaxws="http://cxf.apache.org/jaxws"
+  xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+  xsi:schemaLocation="
+            http://cxf.apache.org/core
+            http://cxf.apache.org/schemas/core.xsd
+            http://cxf.apache.org/configuration/security
+            http://cxf.apache.org/schemas/configuration/security.xsd
+            http://cxf.apache.org/jaxws
+            http://cxf.apache.org/schemas/jaxws.xsd
+            http://cxf.apache.org/jaxrs
+            http://cxf.apache.org/schemas/jaxrs.xsd
+            http://cxf.apache.org/transports/http/configuration
+            http://cxf.apache.org/schemas/configuration/http-conf.xsd
+            http://cxf.apache.org/transports/http-jetty/configuration
+            http://cxf.apache.org/schemas/configuration/http-jetty.xsd
+            http://www.springframework.org/schema/beans
+            http://www.springframework.org/schema/beans/spring-beans.xsd">
+   
+   <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+   
+   <cxf:bus>
+        <cxf:features>
+            <cxf:logging/>
+        </cxf:features>
+   </cxf:bus>
+   
+   <bean id="serviceBean" class="org.apache.cxf.systest.jaxrs.BookStore"/>
+   
+   <jaxrs:server address="http://localhost:${testutil.ports.LoadDistributorServer}/">
+       <jaxrs:serviceBeans>
+          <ref bean="serviceBean"/>
+       </jaxrs:serviceBeans>
+   </jaxrs:server>
+   
+   <jaxrs:server address="http://localhost:${testutil.ports.LoadDistributorServer.2}/">
+       <jaxrs:serviceBeans>
+          <ref bean="serviceBean"/>
+       </jaxrs:serviceBeans>
+   </jaxrs:server>
+   
+</beans>


Mime
View raw message