use of ddf.catalog.plugin.StopProcessingException in project ddf by codice.
the class ExceptionsTest method testStopProcessingException.
@Test
public void testStopProcessingException() {
StopProcessingException spe = new StopProcessingException(msg);
assertEquals(spe.getMessage(), msg);
}
use of ddf.catalog.plugin.StopProcessingException in project ddf by codice.
the class CatalogFrameworkImplTest method testPostQueryStopExecution.
@Test(expected = FederationException.class)
public void testPostQueryStopExecution() throws UnsupportedQueryException, FederationException, SourceUnavailableException {
BundleContext context = null;
FilterFactory filterFactory = new FilterFactoryImpl();
Filter filter = filterFactory.like(filterFactory.property(Metacard.METADATA), "goodyear", "*", "?", "/", false);
QueryRequest request = new QueryRequestImpl(new QueryImpl(filter));
SourceResponseImpl sourceResponse = new SourceResponseImpl(request, new ArrayList<Result>());
QueryResponseImpl queryResponse = new QueryResponseImpl(sourceResponse, "anyId");
CatalogProvider provider = mock(CatalogProvider.class);
when(provider.query(isA(QueryRequest.class))).thenReturn(sourceResponse);
FederationStrategy federationStrategy = mock(FederationStrategy.class);
when(federationStrategy.federate(isA(List.class), isA(QueryRequest.class))).thenReturn(queryResponse);
PostQueryPlugin stopQueryPlugin = new PostQueryPlugin() {
@Override
public QueryResponse process(QueryResponse input) throws PluginExecutionException, StopProcessingException {
throw new StopProcessingException("Testing that the framework will stop the query.");
}
};
FrameworkProperties props = new FrameworkProperties();
props.setCatalogProviders(Collections.singletonList((CatalogProvider) provider));
props.setBundleContext(context);
props.setPostQuery(Arrays.asList(stopQueryPlugin));
props.setFederationStrategy(federationStrategy);
props.setQueryResponsePostProcessor(mock(QueryResponsePostProcessor.class));
props.setFilterBuilder(new GeotoolsFilterBuilder());
CatalogFrameworkImpl framework = createFramework(props);
framework.query(request);
}
use of ddf.catalog.plugin.StopProcessingException in project ddf by codice.
the class SortedFederationStrategyTest method testCatchStopProcessingException.
@Test
public void testCatchStopProcessingException() throws Exception {
PreFederatedQueryPlugin mockPlug = mock(PreFederatedQueryPlugin.class);
PreFederatedQueryPlugin mockPlug2 = mock(PreFederatedQueryPlugin.class);
when(mockPlug.process(any(Source.class), any(QueryRequest.class))).thenThrow(new StopProcessingException("test exception"));
strategy = new SortedFederationStrategy(queryExecutor, Arrays.asList(mockPlug, mockPlug2), new ArrayList<>());
QueryRequest fedQueryRequest = new QueryRequestImpl(mockQuery, properties);
strategy.federate(Arrays.asList(mock(Source.class)), fedQueryRequest);
// First plugin throws exception, so second plugin is untouched
verify(mockPlug).process(any(Source.class), any(QueryRequest.class));
verifyZeroInteractions(mockPlug2);
}
Aggregations