mirror of https://github.com/apache/jclouds.git
Fix replaceAll regex to handle spaces correctly
This commit is contained in:
parent
235092e517
commit
1982626cd6
|
@ -28,6 +28,7 @@ import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.jclouds.ContextBuilder;
|
import org.jclouds.ContextBuilder;
|
||||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||||
|
@ -58,6 +59,11 @@ public class BaseOpenStackMockTest<A extends Closeable> {
|
||||||
private final Set<Module> modules = ImmutableSet.<Module> of(
|
private final Set<Module> modules = ImmutableSet.<Module> of(
|
||||||
new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor()));
|
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")
|
@SuppressWarnings("serial")
|
||||||
public A api(String uri, String provider, Properties overrides) {
|
public A api(String uri, String provider, Properties overrides) {
|
||||||
if (!overrides.containsKey(PROPERTY_MAX_RETRIES)) {
|
if (!overrides.containsKey(PROPERTY_MAX_RETRIES)) {
|
||||||
|
@ -98,10 +104,11 @@ public class BaseOpenStackMockTest<A extends Closeable> {
|
||||||
if (response.getBody() != null) {
|
if (response.getBody() != null) {
|
||||||
/*
|
/*
|
||||||
* "URL" must be used in the service catalog sample (such as
|
* "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.
|
* 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);
|
response = response.setBody(newBody);
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
|
|
Loading…
Reference in New Issue