Allow properties to override default test settings.
This commit is contained in:
14
pom.xml
14
pom.xml
@@ -9,7 +9,19 @@
|
||||
|
||||
<name>couchbase-spring</name>
|
||||
<url>https://github.com/couchbaselabs/couchbase-spring</url>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
@@ -26,18 +26,24 @@ import com.couchbase.client.CouchbaseClient;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
@Configuration
|
||||
public class TestApplicationConfig {
|
||||
|
||||
@Autowired
|
||||
private Environment env;
|
||||
|
||||
@Bean
|
||||
public CouchbaseClient couchbaseClient() throws IOException {
|
||||
return new CouchbaseClient(
|
||||
Arrays.asList(URI.create("http://127.0.0.1:8091/pools")),
|
||||
"default",
|
||||
""
|
||||
);
|
||||
String defaultHost = "http://127.0.0.1:8091/pools";
|
||||
String host = env.getProperty("couchbase.host", defaultHost);
|
||||
|
||||
String bucket = env.getProperty("couchbase.bucket", "default");
|
||||
String pass = env.getProperty("couchbase.password", "");
|
||||
return new CouchbaseClient(Arrays.asList(URI.create(host)), bucket, pass);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user