ApplicationPath { public static String get(Bundle bundle) { return bundle.getHeaders().get(HEADER_APPLICATON_PATH); } private  ApplicationPath(); static String get(Bundle bundle); static String get(BundleContext bundleContext); static String get(ComponentContext componentContext); static final String HEADER_APPLICATON_PATH; static final String PROPERTY_APPLICATON_PATH; }
@Test public void testBundle() { assertEquals(TEST_PATH, ApplicationPath.get(bundle)); }
@Test public void testBundle_HeaderNotSet() { when(bundle.getHeaders()).thenReturn(new Hashtable<String, String>()); assertNull(ApplicationPath.get(bundle)); }
@Test public void testBundleContext() { assertEquals(TEST_PATH, ApplicationPath.get(bundleContext)); }
@Test public void testComponentContext() { assertEquals(TEST_PATH, ApplicationPath.get(componentContext)); }
@Test public void testComponentContext_UsingBundle() { Bundle usingBundle = mock(Bundle.class); Dictionary<String, String> headers = new Hashtable<>(); headers.put(ApplicationPath.HEADER_APPLICATON_PATH, TEST_PATH_2); when(usingBundle.getHeaders()).thenReturn(headers); when(componentContext.getUsingBundle()).thenReturn(usingBundle); assertEquals(TEST_PATH_2, ApplicationPath.get(componentContext)); }