use of org.motechproject.osgi.web.bundle.BundleName in project motech by motech.
the class BundleNameTest method shouldUnderscoreBundleName.
@Test
public void shouldUnderscoreBundleName() {
String underscoredBundleName = new BundleName("org.motechproject.com-sms-api-bundle").underscore();
assertThat(underscoredBundleName, Is.is("org_motechproject_com_sms_api_bundle"));
}
use of org.motechproject.osgi.web.bundle.BundleName 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.motechproject.osgi.web.bundle.BundleName in project motech by motech.
the class HttpContextFactory method getHttpContext.
/**
* Decorates the given HttpContext with a @{link FileSystemAwareUIHttpContext} if dynamic resource loading
* is set up.
* @param httpContext the default http context for a given bundle
* @param bundle the bundle for which this http context will be registered
* @return the decorated instance of the provided context if dynamic loading was set up, the original instance otherwise
*/
public static HttpContext getHttpContext(HttpContext httpContext, Bundle bundle) {
LOGGER.info("Environment is " + ApplicationEnvironment.getEnvironment());
if (!ApplicationEnvironment.isInDevelopmentMode()) {
return httpContext;
}
String resourceDirPath = ApplicationEnvironment.getModulePath(new BundleName(bundle.getSymbolicName()));
if (isBlank(resourceDirPath)) {
LOGGER.info(String.format("Resource path not given for bundle %s", bundle.getSymbolicName()));
return httpContext;
}
LOGGER.info(String.format("Resource path for bundle %s is %s", bundle.getSymbolicName(), resourceDirPath));
return new FileSystemAwareUIHttpContext(httpContext, resourceDirPath);
}
use of org.motechproject.osgi.web.bundle.BundleName in project motech by motech.
the class BundleNameTest method shouldTestBundleNameEquality.
@Test
public void shouldTestBundleNameEquality() {
assertThat(new BundleName("bundle-a"), Is.is(new BundleName("bundle-a")));
assertThat(new BundleName("bundle-a"), IsNot.not(new BundleName("bundle-b")));
}
Aggregations