use of ddf.catalog.event.EventProcessor in project ddf by codice.
the class CswSubscriptionEndpointTest method setUp.
@Before
public void setUp() throws Exception {
systemKeystoreFile = temporaryFolder.newFile("serverKeystore.jks");
FileOutputStream systemKeyOutStream = new FileOutputStream(systemKeystoreFile);
InputStream systemKeyStream = CswSubscriptionEndpointTest.class.getResourceAsStream("/serverKeystore.jks");
IOUtils.copy(systemKeyStream, systemKeyOutStream);
systemTruststoreFile = temporaryFolder.newFile("serverTruststore.jks");
FileOutputStream systemTrustOutStream = new FileOutputStream(systemTruststoreFile);
InputStream systemTrustStream = CswSubscriptionEndpointTest.class.getResourceAsStream("/serverTruststore.jks");
IOUtils.copy(systemTrustStream, systemTrustOutStream);
System.setProperty(SecurityConstants.KEYSTORE_TYPE, "jks");
System.setProperty(SecurityConstants.TRUSTSTORE_TYPE, "jks");
System.setProperty("ddf.home", "");
System.setProperty(SecurityConstants.KEYSTORE_PATH, systemKeystoreFile.getAbsolutePath());
System.setProperty(SecurityConstants.TRUSTSTORE_PATH, systemTruststoreFile.getAbsolutePath());
System.setProperty(SecurityConstants.KEYSTORE_PASSWORD, password);
System.setProperty(SecurityConstants.TRUSTSTORE_PASSWORD, password);
eventProcessor = mock(EventProcessor.class);
mockInputManager = mock(TransformerManager.class);
mockContext = mock(BundleContext.class);
mockMimeTypeManager = mock(TransformerManager.class);
mockSchemaManager = mock(TransformerManager.class);
validator = mock(Validator.class);
queryFactory = mock(CswQueryFactory.class);
query = mock(QueryRequest.class);
when(queryFactory.getQuery(any(GetRecordsType.class))).thenReturn(query);
serviceRegistration = mock(ServiceRegistration.class);
subscriptionReference = mock(ServiceReference.class);
bundle = mock(Bundle.class);
osgiFilter = mock(org.osgi.framework.Filter.class);
configAdminRef = mock(ServiceReference.class);
configAdmin = mock(ConfigurationAdmin.class);
config = mock(Configuration.class);
Configuration[] configArry = { config };
defaultRequest = createDefaultGetRecordsRequest();
subscription = new CswSubscription(mockMimeTypeManager, defaultRequest.get202RecordsType(), query);
when(osgiFilter.toString()).thenReturn(FILTER_STR);
doReturn(serviceRegistration).when(mockContext).registerService(eq(Subscription.class.getName()), any(Subscription.class), any(Dictionary.class));
doReturn(configAdminRef).when(mockContext).getServiceReference(eq(ConfigurationAdmin.class.getName()));
when(serviceRegistration.getReference()).thenReturn(subscriptionReference);
doReturn(bundle).when(subscriptionReference).getBundle();
when(subscriptionReference.getBundle()).thenReturn(bundle);
when(bundle.getBundleId()).thenReturn(bundleId);
when(mockContext.createFilter(anyString())).thenReturn(osgiFilter);
when(mockContext.getService(eq(configAdminRef))).thenReturn(configAdmin);
when(mockContext.getService(eq(subscriptionReference))).thenReturn(subscription);
when(configAdmin.listConfigurations(eq(FILTER_STR))).thenReturn(configArry);
when(configAdmin.createFactoryConfiguration(anyString(), isNull(String.class))).thenReturn(config);
cswSubscriptionEndpoint = new CswSubscriptionEndpointStub(eventProcessor, mockMimeTypeManager, mockSchemaManager, mockInputManager, validator, queryFactory, mockContext);
}
Aggregations