Search in sources :

Example 1 with CSW_FEDERATED_SOURCE_FACTORY_PID

use of org.codice.ddf.itests.common.csw.CswTestCommons.CSW_FEDERATED_SOURCE_FACTORY_PID in project ddf by codice.

the class TestFanout method startCswSource.

private void startCswSource() throws Exception {
    getServiceManager().waitForHttpEndpoint(CSW_PATH + "?_wadl");
    getServiceManager().createManagedService(CSW_FEDERATED_SOURCE_FACTORY_PID, getCswSourceProperties(CSW_SOURCE_ID, CSW_PATH.getUrl(), getServiceManager()));
    long timeout = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(10);
    boolean available = false;
    FederatedSource source = null;
    while (!available) {
        if (source == null) {
            source = getServiceManager().getServiceReferences(FederatedSource.class, null).stream().map(getServiceManager()::getService).filter(src -> CSW_SOURCE_ID.equals(src.getId())).findFirst().orElse(null);
        } else {
            available = source.isAvailable();
        }
        if (System.currentTimeMillis() > timeout) {
            fail("CSW source failed to initialize in time.");
        }
        Thread.sleep(1000);
    }
}
Also used : PaxExam(org.ops4j.pax.exam.junit.PaxExam) RunWith(org.junit.runner.RunWith) HttpStatus(org.apache.http.HttpStatus) RestAssured.given(com.jayway.restassured.RestAssured.given) CSW_FEDERATED_SOURCE_FACTORY_PID(org.codice.ddf.itests.common.csw.CswTestCommons.CSW_FEDERATED_SOURCE_FACTORY_PID) ArrayList(java.util.ArrayList) MediaType(javax.ws.rs.core.MediaType) BeforeExam(org.codice.ddf.itests.common.annotations.BeforeExam) After(org.junit.After) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest) AfterExam(org.codice.ddf.itests.common.annotations.AfterExam) Assert.fail(org.junit.Assert.fail) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) CatalogTestCommons(org.codice.ddf.itests.common.catalog.CatalogTestCommons) LoggingUtils(org.codice.ddf.itests.common.utils.LoggingUtils) Before(org.junit.Before) JsonPath(com.jayway.restassured.path.json.JsonPath) FederatedSource(ddf.catalog.source.FederatedSource) IOException(java.io.IOException) Test(org.junit.Test) RestAssured.get(com.jayway.restassured.RestAssured.get) TimeUnit(java.util.concurrent.TimeUnit) ExamReactorStrategy(org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy) PerSuite(org.ops4j.pax.exam.spi.reactors.PerSuite) List(java.util.List) Matchers.hasItem(org.hamcrest.Matchers.hasItem) CswTestCommons.getCswSourceProperties(org.codice.ddf.itests.common.csw.CswTestCommons.getCswSourceProperties) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Collections(java.util.Collections) FederatedSource(ddf.catalog.source.FederatedSource)

Aggregations

RestAssured.get (com.jayway.restassured.RestAssured.get)1 RestAssured.given (com.jayway.restassured.RestAssured.given)1 JsonPath (com.jayway.restassured.path.json.JsonPath)1 FederatedSource (ddf.catalog.source.FederatedSource)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 TimeUnit (java.util.concurrent.TimeUnit)1 MediaType (javax.ws.rs.core.MediaType)1 HttpStatus (org.apache.http.HttpStatus)1 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)1 AfterExam (org.codice.ddf.itests.common.annotations.AfterExam)1 BeforeExam (org.codice.ddf.itests.common.annotations.BeforeExam)1 CatalogTestCommons (org.codice.ddf.itests.common.catalog.CatalogTestCommons)1 CSW_FEDERATED_SOURCE_FACTORY_PID (org.codice.ddf.itests.common.csw.CswTestCommons.CSW_FEDERATED_SOURCE_FACTORY_PID)1 CswTestCommons.getCswSourceProperties (org.codice.ddf.itests.common.csw.CswTestCommons.getCswSourceProperties)1 LoggingUtils (org.codice.ddf.itests.common.utils.LoggingUtils)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers.equalTo (org.hamcrest.Matchers.equalTo)1