use of org.eclipse.gemini.blueprint.mock.MockBundle in project motech by motech.
the class MotechOsgiApplicationContextCreatorTest method shouldReturnApplicationOfTypeWebApplicationContext.
@Test
public void shouldReturnApplicationOfTypeWebApplicationContext() throws Exception {
MockBundle bundle = new MockBundle();
MockBundleContext bundleContext = new MockBundleContext(bundle);
ConfigurationScanner configurationScanner = mock(ConfigurationScanner.class);
when(configurationScanner.getConfigurations(bundle)).thenReturn(new String[] { "resource.xml" });
MotechOsgiApplicationContextCreator contextCreator = new MotechOsgiApplicationContextCreator();
contextCreator.setConfigurationScanner(configurationScanner);
MotechOsgiConfigurableApplicationContext applicationContext = (MotechOsgiConfigurableApplicationContext) contextCreator.createApplicationContext(bundleContext);
assertThat(applicationContext, notNullValue());
}
use of org.eclipse.gemini.blueprint.mock.MockBundle in project motech by motech.
the class HttpContextFactoryTest method shouldCreateFileSystemAwareUiHttpContext.
@Test
public void shouldCreateFileSystemAwareUiHttpContext() {
HttpContext httpContext = mock(HttpContext.class);
PowerMockito.mockStatic(ApplicationEnvironment.class);
MockBundle bundle = new MockBundle("org.motechproject.com-sms-api-bundle");
when(ApplicationEnvironment.isInDevelopmentMode()).thenReturn(true);
when(ApplicationEnvironment.getModulePath(new BundleName("org.motechproject.com-sms-api-bundle"))).thenReturn("/Users/s/project/motech/modules/sms/src/main/resources");
FileSystemAwareUIHttpContext fileSystemAwareUIHttpContext = (FileSystemAwareUIHttpContext) HttpContextFactory.getHttpContext(httpContext, bundle);
assertThat(fileSystemAwareUIHttpContext, IsNot.not(notNull()));
assertThat(fileSystemAwareUIHttpContext.getResourceRootDirectoryPath(), Is.is("/Users/s/project/motech/modules/sms/src/main/resources"));
}
use of org.eclipse.gemini.blueprint.mock.MockBundle in project motech by motech.
the class ApplicationContextServiceReferenceUtilsTest method shouldNotRecogniseAsApplicationContextServiceWhenObjectClassIsDifferent.
@Test
public void shouldNotRecogniseAsApplicationContextServiceWhenObjectClassIsDifferent() {
ServiceReference serviceReference = mock(ServiceReference.class);
when(serviceReference.getBundle()).thenReturn(new MockBundle("mock-bundle"));
when(serviceReference.getProperty(ApplicationContextServiceReferenceUtils.SERVICE_NAME)).thenReturn("mock-bundle");
when(serviceReference.getProperty(Constants.OBJECTCLASS)).thenReturn(new String[] { "abcd", "he.llo", "xyz" });
assertTrue(ApplicationContextServiceReferenceUtils.isNotValid(serviceReference));
}
use of org.eclipse.gemini.blueprint.mock.MockBundle in project motech by motech.
the class ApplicationContextServiceReferenceUtilsTest method shouldRecogniseAsApplicationContextService.
@Test
public void shouldRecogniseAsApplicationContextService() {
ServiceReference serviceReference = mock(ServiceReference.class);
when(serviceReference.getBundle()).thenReturn(new MockBundle("mock-bundle"));
when(serviceReference.getProperty(ApplicationContextServiceReferenceUtils.SERVICE_NAME)).thenReturn("mock-bundle");
when(serviceReference.getProperty(Constants.OBJECTCLASS)).thenReturn(new String[] { "abcd", ApplicationContext.class.getName(), "xyz" });
assertTrue(ApplicationContextServiceReferenceUtils.isValid(serviceReference));
}
use of org.eclipse.gemini.blueprint.mock.MockBundle in project motech by motech.
the class ApplicationContextServiceReferenceUtilsTest method shouldNotRecogniseAsApplicationContextServiceWhenServiceNameIsDifferent.
@Test
public void shouldNotRecogniseAsApplicationContextServiceWhenServiceNameIsDifferent() {
ServiceReference serviceReference = mock(ServiceReference.class);
when(serviceReference.getBundle()).thenReturn(new MockBundle("mock-bundle"));
when(serviceReference.getProperty(ApplicationContextServiceReferenceUtils.SERVICE_NAME)).thenReturn("another-mock-bundle");
when(serviceReference.getProperty(Constants.OBJECTCLASS)).thenReturn(new String[] { "abcd", ApplicationContext.class.getName(), "xyz" });
assertTrue(ApplicationContextServiceReferenceUtils.isNotValid(serviceReference));
}
Aggregations