DATACOUCH-14 - Enable SLF4J as default logging.
If the whole system is constructed through the AbstractCouchbaseConfiguration or the custom <couchbase> xml config, the logger is specified automatically. Please note that this also changes the java config a little bit, but it should also make it easier to construct it.
This commit is contained in:
@@ -42,7 +42,7 @@ public class BucketCreator implements InitializingBean {
|
||||
|
||||
RestTemplate template = new RestTemplate(rf);
|
||||
|
||||
String fullUri = hostUri + "/default/buckets/default";
|
||||
String fullUri = "http://" + hostUri + ":8091/pools/default/buckets/default";
|
||||
|
||||
ResponseEntity<String> entity = null;
|
||||
try {
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.data.couchbase.config.AbstractCouchbaseConfiguration;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Michael Nitschinger
|
||||
@@ -36,21 +37,6 @@ public class TestApplicationConfig extends AbstractCouchbaseConfiguration {
|
||||
@Autowired
|
||||
private Environment env;
|
||||
|
||||
@Bean
|
||||
public String couchbaseHost() {
|
||||
return env.getProperty("couchbase.host", "http://127.0.0.1:8091/pools");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public String couchbaseBucket() {
|
||||
return env.getProperty("couchbase.bucket", "default");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public String couchbasePassword() {
|
||||
return env.getProperty("couchbase.password", "");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public String couchbaseAdminUser() {
|
||||
return env.getProperty("couchbase.adminUser", "Administrator");
|
||||
@@ -61,16 +47,31 @@ public class TestApplicationConfig extends AbstractCouchbaseConfiguration {
|
||||
return env.getProperty("couchbase.adminUser", "password");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> bootstrapHosts() {
|
||||
return Arrays.asList(env.getProperty("couchbase.host", "127.0.0.1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBucketName() {
|
||||
return env.getProperty("couchbase.bucket", "default");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBucketPassword() {
|
||||
return env.getProperty("couchbase.password", "");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BucketCreator bucketCreator() throws Exception {
|
||||
return new BucketCreator(couchbaseHost(), couchbaseAdminUser(), couchbaseAdminPassword());
|
||||
return new BucketCreator(bootstrapHosts().get(0), couchbaseAdminUser(), couchbaseAdminPassword());
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Override
|
||||
@DependsOn("bucketCreator")
|
||||
public CouchbaseClient couchbaseClient() throws Exception {
|
||||
return new CouchbaseClient(Arrays.asList(new URI(couchbaseHost())), couchbaseBucket(), couchbasePassword());
|
||||
return super.couchbaseClient();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ import org.springframework.data.couchbase.core.mapping.Document;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -55,6 +57,21 @@ public class AbstractCouchbaseConfigurationTests {
|
||||
|
||||
class SampleCouchbaseConfiguration extends AbstractCouchbaseConfiguration {
|
||||
|
||||
@Override
|
||||
protected List<String> bootstrapHosts() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBucketName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBucketPassword() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Override
|
||||
public CouchbaseClient couchbaseClient() throws Exception {
|
||||
|
||||
@@ -295,9 +295,10 @@ public class MappingCouchbaseConverterTests {
|
||||
source.put("attr2", cattr2);
|
||||
|
||||
ListEntity readConverted = converter.read(ListEntity.class, source);
|
||||
System.out.println(readConverted.attr0);
|
||||
System.out.println(readConverted.attr1);
|
||||
System.out.println(readConverted.attr2);
|
||||
assertEquals(2, readConverted.attr0.size());
|
||||
assertEquals(0, readConverted.attr1.size());
|
||||
assertEquals(1, readConverted.attr2.size());
|
||||
assertEquals(2, readConverted.attr2.get(0).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user