Search in sources :

Example 1 with StdCouchDbInstance

use of org.ektorp.impl.StdCouchDbInstance in project apex-malhar by apache.

the class CouchDbStore method connect.

@Override
public void connect() throws IOException {
    StdHttpClient.Builder builder = new StdHttpClient.Builder();
    if (dbUrl != null) {
        try {
            builder.url(dbUrl);
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException(e.getMessage());
        }
    }
    if (userName != null) {
        builder.username(userName);
    }
    if (password != null) {
        builder.password(password);
    }
    HttpClient httpClient = builder.build();
    couchInstance = new StdCouchDbInstance(httpClient);
    dbConnector = couchInstance.createConnector(dbName, false);
}
Also used : StdHttpClient(org.ektorp.http.StdHttpClient) MalformedURLException(java.net.MalformedURLException) HttpClient(org.ektorp.http.HttpClient) StdHttpClient(org.ektorp.http.StdHttpClient) StdCouchDbInstance(org.ektorp.impl.StdCouchDbInstance)

Example 2 with StdCouchDbInstance

use of org.ektorp.impl.StdCouchDbInstance in project apex-malhar by apache.

the class CouchDBTestHelper method setup.

static void setup() {
    StdHttpClient.Builder builder = new StdHttpClient.Builder();
    HttpClient httpClient = builder.build();
    StdCouchDbInstance instance = new StdCouchDbInstance(httpClient);
    DbPath dbPath = new DbPath(TEST_DB);
    if (instance.checkIfDbExists((dbPath))) {
        instance.deleteDatabase(dbPath.getPath());
    }
    connector = instance.createConnector(TEST_DB, true);
}
Also used : StdHttpClient(org.ektorp.http.StdHttpClient) HttpClient(org.ektorp.http.HttpClient) StdHttpClient(org.ektorp.http.StdHttpClient) StdCouchDbInstance(org.ektorp.impl.StdCouchDbInstance) DbPath(org.ektorp.DbPath)

Example 3 with StdCouchDbInstance

use of org.ektorp.impl.StdCouchDbInstance in project apex-malhar by apache.

the class CouchDBTestHelper method teardown.

static void teardown() {
    StdHttpClient.Builder builder = new StdHttpClient.Builder();
    HttpClient httpClient = builder.build();
    StdCouchDbInstance instance = new StdCouchDbInstance(httpClient);
    DbPath dbPath = new DbPath(TEST_DB);
    if (instance.checkIfDbExists((dbPath))) {
        instance.deleteDatabase(dbPath.getPath());
    }
}
Also used : StdHttpClient(org.ektorp.http.StdHttpClient) HttpClient(org.ektorp.http.HttpClient) StdHttpClient(org.ektorp.http.StdHttpClient) StdCouchDbInstance(org.ektorp.impl.StdCouchDbInstance) DbPath(org.ektorp.DbPath)

Example 4 with StdCouchDbInstance

use of org.ektorp.impl.StdCouchDbInstance in project sw360portal by sw360.

the class DatabaseConnectorTest method testSetUp.

@Test
public void testSetUp() throws Exception {
    // Default connector for testing
    HttpClient httpClient = new StdHttpClient.Builder().url(COUCH_DB_URL).build();
    CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);
    CouchDbConnector db = new StdCouchDbConnector(COUCH_DB_DATABASE, dbInstance, factory);
    // Check that the document was inserted
    assertTrue(db.contains(id));
}
Also used : StdHttpClient(org.ektorp.http.StdHttpClient) HttpClient(org.ektorp.http.HttpClient) StdCouchDbInstance(org.ektorp.impl.StdCouchDbInstance) CouchDbInstance(org.ektorp.CouchDbInstance) StdCouchDbInstance(org.ektorp.impl.StdCouchDbInstance) StdCouchDbConnector(org.ektorp.impl.StdCouchDbConnector) StdCouchDbConnector(org.ektorp.impl.StdCouchDbConnector) CouchDbConnector(org.ektorp.CouchDbConnector) Test(org.junit.Test)

Example 5 with StdCouchDbInstance

use of org.ektorp.impl.StdCouchDbInstance in project sw360portal by sw360.

the class DatabaseConnectorTest method tearDown.

@After
public void tearDown() throws Exception {
    // Default connector for testing
    HttpClient httpClient = new StdHttpClient.Builder().url(COUCH_DB_URL).build();
    CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);
    if (dbInstance.checkIfDbExists(COUCH_DB_DATABASE)) {
        dbInstance.deleteDatabase(COUCH_DB_DATABASE);
    }
}
Also used : StdHttpClient(org.ektorp.http.StdHttpClient) HttpClient(org.ektorp.http.HttpClient) StdCouchDbInstance(org.ektorp.impl.StdCouchDbInstance) CouchDbInstance(org.ektorp.CouchDbInstance) StdCouchDbInstance(org.ektorp.impl.StdCouchDbInstance) After(org.junit.After)

Aggregations

StdHttpClient (org.ektorp.http.StdHttpClient)8 StdCouchDbInstance (org.ektorp.impl.StdCouchDbInstance)8 HttpClient (org.ektorp.http.HttpClient)7 StdCouchDbConnector (org.ektorp.impl.StdCouchDbConnector)4 CouchDbInstance (org.ektorp.CouchDbInstance)3 IOException (java.io.IOException)2 CouchDbConnector (org.ektorp.CouchDbConnector)2 DbPath (org.ektorp.DbPath)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 MalformedURLException (java.net.MalformedURLException)1 InMemoryCouchDb (mcouch.core.InMemoryCouchDb)1 CouchDBObjectMapperFactory (org.apache.gora.couchdb.util.CouchDBObjectMapperFactory)1 TestObject (org.eclipse.sw360.testthrift.TestObject)1 ObjectMapperFactory (org.ektorp.impl.ObjectMapperFactory)1 After (org.junit.After)1 Before (org.junit.Before)1 Test (org.junit.Test)1