Search in sources :

Example 1 with HttpClient

use of org.ektorp.http.HttpClient 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 HttpClient

use of org.ektorp.http.HttpClient 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 HttpClient

use of org.ektorp.http.HttpClient 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 HttpClient

use of org.ektorp.http.HttpClient 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 HttpClient

use of org.ektorp.http.HttpClient 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

HttpClient (org.ektorp.http.HttpClient)7 StdHttpClient (org.ektorp.http.StdHttpClient)7 StdCouchDbInstance (org.ektorp.impl.StdCouchDbInstance)7 CouchDbInstance (org.ektorp.CouchDbInstance)3 StdCouchDbConnector (org.ektorp.impl.StdCouchDbConnector)3 CouchDbConnector (org.ektorp.CouchDbConnector)2 DbPath (org.ektorp.DbPath)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 CouchDBObjectMapperFactory (org.apache.gora.couchdb.util.CouchDBObjectMapperFactory)1 GoraException (org.apache.gora.util.GoraException)1 TestObject (org.eclipse.sw360.testthrift.TestObject)1 DocumentNotFoundException (org.ektorp.DocumentNotFoundException)1 ObjectMapperFactory (org.ektorp.impl.ObjectMapperFactory)1 After (org.junit.After)1 Before (org.junit.Before)1 Test (org.junit.Test)1