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 2013/08/19 12:45:02 UTC
svn commit: r1515348 - in /cxf/trunk:
rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorTest.java
Author: sergeyb
Date: Mon Aug 19 10:45:02 2013
New Revision: 1515348
URL: http://svn.apache.org/r1515348
Log:
[CXF-5184] Updating FailoverTargetSelector to deal with cases when REQUEST_URI starts with ENDPOINT_ADDRESS, major help from Jacek Obarymski appreciated
Modified:
cxf/trunk/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorTest.java
Modified: cxf/trunk/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java?rev=1515348&r1=1515347&r2=1515348&view=diff
==============================================================================
--- cxf/trunk/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java (original)
+++ cxf/trunk/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java Mon Aug 19 10:45:02 2013
@@ -315,7 +315,7 @@ public class FailoverTargetSelector exte
String endpointAddress,
Conduit cond) {
String requestURI = (String)message.get(Message.REQUEST_URI);
- if (requestURI != null && endpointAddress != null && !requestURI.startsWith(endpointAddress)) {
+ if (requestURI != null && endpointAddress != null && !requestURI.equals(endpointAddress)) {
String basePath = (String)message.get(Message.BASE_PATH);
if (basePath != null && requestURI.startsWith(basePath)) {
String pathInfo = requestURI.substring(basePath.length());
Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorTest.java?rev=1515348&r1=1515347&r2=1515348&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorTest.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/LoadDistributorTest.java Mon Aug 19 10:45:02 2013
@@ -26,6 +26,7 @@ import javax.ws.rs.core.Response;
import org.apache.cxf.clustering.FailoverFeature;
import org.apache.cxf.clustering.FailoverTargetSelector;
+import org.apache.cxf.clustering.LoadDistributorFeature;
import org.apache.cxf.clustering.LoadDistributorTargetSelector;
import org.apache.cxf.clustering.SequentialStrategy;
import org.apache.cxf.endpoint.ConduitSelector;
@@ -74,11 +75,28 @@ public class LoadDistributorTest extends
}
@Test
- public void testSequentialStrategy() throws Exception {
+ public void testMultipleAltAddresses() throws Exception {
FailoverFeature feature = getFeature(Server.ADDRESS2, Server.ADDRESS3);
strategyTest(Server.ADDRESS1, feature);
}
+ @Test
+ public void testSingleAltAddress() throws Exception {
+ LoadDistributorFeature feature = new LoadDistributorFeature();
+ List<String> alternateAddresses = new ArrayList<String>();
+ alternateAddresses.add(Server.ADDRESS2);
+ SequentialStrategy strategy = new SequentialStrategy();
+ strategy.setAlternateAddresses(alternateAddresses);
+ feature.setStrategy(strategy);
+
+ BookStore bookStore = getBookStore(Server.ADDRESS1, feature);
+ Book book = bookStore.getBook("123");
+ assertEquals("unexpected id", 123L, book.getId());
+
+ book = bookStore.getBook("123");
+ assertEquals("unexpected id", 123L, book.getId());
+ }
+
private FailoverFeature getFeature(String ...address) {
FailoverFeature feature = new FailoverFeature();