Search in sources :

Example 1 with CouchDbInstance

use of org.ektorp.CouchDbInstance 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 2 with CouchDbInstance

use of org.ektorp.CouchDbInstance 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)

Example 3 with CouchDbInstance

use of org.ektorp.CouchDbInstance in project sw360portal by sw360.

the class DatabaseConnectorTest method setUp.

@Before
public void setUp() throws Exception {
    // Create the test object
    object = new TestObject();
    object.setName("Test");
    object.setText("This is some nice test text.");
    // Initialize the mapper factory
    factory = new MapperFactory(ImmutableList.<Class<?>>of(TestObject.class), Collections.<Class<?>>emptyList(), Maps.newHashMap());
    // Default connector for testing
    HttpClient httpClient = new StdHttpClient.Builder().url(COUCH_DB_URL).build();
    CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);
    // Create database if it does not exists
    if (!dbInstance.checkIfDbExists(COUCH_DB_DATABASE)) {
        dbInstance.createDatabase(COUCH_DB_DATABASE);
    }
    CouchDbConnector db = new StdCouchDbConnector(COUCH_DB_DATABASE, dbInstance, factory);
    // Add the object
    db.create(object);
    // Save id and rev for teardown
    id = object.getId();
    rev = object.getRevision();
    // Now create the actual database connector
    connector = new DatabaseConnector(DatabaseTestProperties.getConfiguredHttpClient(), COUCH_DB_DATABASE, factory);
}
Also used : StdHttpClient(org.ektorp.http.StdHttpClient) HttpClient(org.ektorp.http.HttpClient) StdCouchDbInstance(org.ektorp.impl.StdCouchDbInstance) TestObject(org.eclipse.sw360.testthrift.TestObject) CouchDbInstance(org.ektorp.CouchDbInstance) StdCouchDbInstance(org.ektorp.impl.StdCouchDbInstance) StdCouchDbConnector(org.ektorp.impl.StdCouchDbConnector) StdCouchDbConnector(org.ektorp.impl.StdCouchDbConnector) CouchDbConnector(org.ektorp.CouchDbConnector) Before(org.junit.Before)

Aggregations

CouchDbInstance (org.ektorp.CouchDbInstance)3 HttpClient (org.ektorp.http.HttpClient)3 StdHttpClient (org.ektorp.http.StdHttpClient)3 StdCouchDbInstance (org.ektorp.impl.StdCouchDbInstance)3 CouchDbConnector (org.ektorp.CouchDbConnector)2 StdCouchDbConnector (org.ektorp.impl.StdCouchDbConnector)2 TestObject (org.eclipse.sw360.testthrift.TestObject)1 After (org.junit.After)1 Before (org.junit.Before)1 Test (org.junit.Test)1