Search in sources :

Example 16 with ContentType

use of ddf.catalog.data.ContentType in project ddf by codice.

the class TestWfsSource method testConfigureFeatureTypes.

@Test
public void testConfigureFeatureTypes() throws WfsException, SecurityServiceException {
    ArgumentCaptor<DescribeFeatureTypeRequest> captor = ArgumentCaptor.forClass(DescribeFeatureTypeRequest.class);
    WfsSource source = getWfsSource(ONE_TEXT_PROPERTY_SCHEMA, MockWfsServer.getFilterCapabilities(), GeospatialUtil.EPSG_4326_URN, 1);
    final String SAMPLE_FEATURE_NAME0 = SAMPLE_FEATURE_NAME + "0";
    verify(mockWfs).describeFeatureType(captor.capture());
    DescribeFeatureTypeRequest describeFeatureType = captor.getValue();
    // sample feature 0 does not have a prefix
    assertThat(SAMPLE_FEATURE_NAME0, equalTo(describeFeatureType.getTypeName()));
    assertTrue(source.isAvailable());
    assertThat(source.featureTypeFilters.size(), is(1));
    WfsFilterDelegate delegate = source.featureTypeFilters.get(new QName(SAMPLE_FEATURE_NAME0));
    assertThat(delegate, notNullValue());
    assertThat(source.getContentTypes().size(), is(1));
    List<ContentType> types = new ArrayList<ContentType>();
    types.addAll(source.getContentTypes());
    assertTrue(SAMPLE_FEATURE_NAME0.equals(types.get(0).getName()));
}
Also used : ContentType(ddf.catalog.data.ContentType) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString) DescribeFeatureTypeRequest(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.DescribeFeatureTypeRequest) Test(org.junit.Test)

Example 17 with ContentType

use of ddf.catalog.data.ContentType in project ddf by codice.

the class CatalogFrameworkImplTest method testPreQueryStopExecution.

@Test(expected = FederationException.class)
public void testPreQueryStopExecution() throws UnsupportedQueryException, FederationException, SourceUnavailableException {
    SourcePoller poller = mock(SourcePoller.class);
    when(poller.getCachedSource(isA(Source.class))).thenReturn(null);
    MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), true, new Date());
    FederationStrategy federationStrategy = mock(FederationStrategy.class);
    QueryRequest request = mock(QueryRequest.class);
    when(request.getQuery()).thenReturn(mock(Query.class));
    PreQueryPlugin stopQueryPlugin = new PreQueryPlugin() {

        @Override
        public QueryRequest process(QueryRequest input) throws PluginExecutionException, StopProcessingException {
            throw new StopProcessingException("Testing that the framework will stop the query.");
        }
    };
    FrameworkProperties frameworkProperties = new FrameworkProperties();
    frameworkProperties.setSourcePoller(poller);
    frameworkProperties.setPreQuery(Arrays.asList(stopQueryPlugin));
    frameworkProperties.setFederationStrategy(federationStrategy);
    frameworkProperties.setCatalogProviders(Collections.singletonList(provider));
    CatalogFrameworkImpl framework = createFramework(frameworkProperties);
    framework.query(request);
}
Also used : ContentType(ddf.catalog.data.ContentType) QueryRequest(ddf.catalog.operation.QueryRequest) Query(ddf.catalog.operation.Query) FederationStrategy(ddf.catalog.federation.FederationStrategy) StopProcessingException(ddf.catalog.plugin.StopProcessingException) Source(ddf.catalog.source.Source) ByteSource(com.google.common.io.ByteSource) CachedSource(ddf.catalog.util.impl.CachedSource) FederatedSource(ddf.catalog.source.FederatedSource) Date(java.util.Date) SourcePoller(ddf.catalog.util.impl.SourcePoller) PreQueryPlugin(ddf.catalog.plugin.PreQueryPlugin) Test(org.junit.Test)

Example 18 with ContentType

use of ddf.catalog.data.ContentType in project ddf by codice.

the class CatalogFrameworkImplTest method testProviderUnavailableCreate.

// End testing CatalogFramework
// Test negative use-cases (expected errors)
/**
     * Tests that the framework properly throws a catalog exception when the local provider is not
     * available for create.
     *
     * @throws SourceUnavailableException
     */
@Test(expected = SourceUnavailableException.class)
public void testProviderUnavailableCreate() throws SourceUnavailableException {
    MockEventProcessor eventAdmin = new MockEventProcessor();
    MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), false, null);
    CatalogFramework framework = createDummyCatalogFramework(provider, storageProvider, eventAdmin, false);
    List<Metacard> metacards = new ArrayList<Metacard>();
    MetacardImpl newCard = new MetacardImpl();
    newCard.setId(null);
    metacards.add(newCard);
    CreateRequest create = new CreateRequestImpl(metacards);
    // expected to throw exception due to catalog provider being unavailable
    try {
        framework.create(create);
    } catch (IngestException e) {
        fail();
    }
}
Also used : Metacard(ddf.catalog.data.Metacard) ContentType(ddf.catalog.data.ContentType) CreateRequest(ddf.catalog.operation.CreateRequest) CatalogFramework(ddf.catalog.CatalogFramework) ArrayList(java.util.ArrayList) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) IngestException(ddf.catalog.source.IngestException) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Example 19 with ContentType

use of ddf.catalog.data.ContentType in project ddf by codice.

the class CatalogFrameworkImplTest method testProviderRuntimeExceptionOnCreate.

@Test(expected = IngestException.class)
public void testProviderRuntimeExceptionOnCreate() throws IngestException {
    MockEventProcessor eventAdmin = new MockEventProcessor();
    // use exception provider instead of memory
    MockExceptionProvider provider = new MockExceptionProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), true, null);
    CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, eventAdmin, true);
    List<Metacard> metacards = new ArrayList<Metacard>();
    MetacardImpl newCard = new MetacardImpl();
    newCard.setId(null);
    metacards.add(newCard);
    CreateRequest create = new CreateRequestImpl((Metacard) null);
    try {
        framework.create(create);
    } catch (SourceUnavailableException e) {
        fail();
    }
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) Metacard(ddf.catalog.data.Metacard) ContentType(ddf.catalog.data.ContentType) CreateRequest(ddf.catalog.operation.CreateRequest) CatalogFramework(ddf.catalog.CatalogFramework) ArrayList(java.util.ArrayList) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Example 20 with ContentType

use of ddf.catalog.data.ContentType in project ddf by codice.

the class WfsSource method getContentTypes.

@Override
public Set<ContentType> getContentTypes() {
    Set<QName> typeNames = featureTypeFilters.keySet();
    Set<ContentType> contentTypes = new HashSet<ContentType>();
    for (QName featureName : typeNames) {
        contentTypes.add(new ContentTypeImpl(featureName.getLocalPart(), getVersion()));
    }
    return contentTypes;
}
Also used : ContentTypeImpl(ddf.catalog.data.impl.ContentTypeImpl) ContentType(ddf.catalog.data.ContentType) QName(javax.xml.namespace.QName) HashSet(java.util.HashSet)

Aggregations

ContentType (ddf.catalog.data.ContentType)45 Test (org.junit.Test)34 CatalogFramework (ddf.catalog.CatalogFramework)17 ArrayList (java.util.ArrayList)17 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)14 Metacard (ddf.catalog.data.Metacard)12 ContentTypeImpl (ddf.catalog.data.impl.ContentTypeImpl)12 Source (ddf.catalog.source.Source)10 Date (java.util.Date)10 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)8 HashSet (java.util.HashSet)8 Matchers.anyString (org.mockito.Matchers.anyString)7 IngestException (ddf.catalog.source.IngestException)6 URI (java.net.URI)5 SourceInfoResponse (ddf.catalog.operation.SourceInfoResponse)4 CatalogProvider (ddf.catalog.source.CatalogProvider)4 SourceDescriptor (ddf.catalog.source.SourceDescriptor)4 SourcePoller (ddf.catalog.util.impl.SourcePoller)4 URISyntaxException (java.net.URISyntaxException)4 QName (javax.xml.namespace.QName)4