diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/internal/BaseOpenStackMockTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/internal/BaseOpenStackMockTest.java index 39d95d208b..bbec24c0a7 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/internal/BaseOpenStackMockTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/internal/BaseOpenStackMockTest.java @@ -28,6 +28,7 @@ import java.util.Properties; import java.util.Set; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; +import java.util.regex.Pattern; import org.jclouds.ContextBuilder; import org.jclouds.concurrent.config.ExecutorServiceModule; @@ -62,6 +63,11 @@ public class BaseOpenStackMockTest { private final Set modules = ImmutableSet. of( new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor())); + /** + * Pattern for replacing the URL token with the correct local address. + */ + private static final Pattern urlTokenPattern = Pattern.compile(":\\s*\"\\s*URL"); + @SuppressWarnings("serial") public A api(String uri, String provider, Properties overrides) { if (!overrides.containsKey(PROPERTY_MAX_RETRIES)) { @@ -102,10 +108,11 @@ public class BaseOpenStackMockTest { if (response.getBody() != null) { /* * "URL" must be used in the service catalog sample (such as - * access.json or accessRackspace) for the declared service + * access.json or accessRackspace.json) for the declared service * endpoints. */ - String newBody = new String(response.getBody()).replace(":\"URL", ":\"" + url.toString()); + String newBody = urlTokenPattern.matcher(new String(response.getBody())).replaceAll(": \"" + url.toString()); + response = response.setBody(newBody); } return response;