ConfigurationAdmin implements ConfigurationAdminMBean { public String getBundleLocation(String pid) throws IOException { if (pid == null || pid.length() < 1) { throw new IOException("Argument pid cannot be null or empty"); } Configuration config = configurationAdmin.getConfiguration(pid, null); String bundleLocation = (config.getBundleLocation() == null) ? "Configuration is not yet bound to a bundle location" : config.getBundleLocation(); return bundleLocation; } ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin configurationAdmin); String createFactoryConfiguration(String factoryPid); String createFactoryConfigurationForLocation(String factoryPid, String location); void delete(String pid); void deleteForLocation(String pid, String location); void deleteConfigurations(String filter); String getBundleLocation(String pid); String[][] getConfigurations(String filter); String getFactoryPid(String pid); String getFactoryPidForLocation(String pid, String location); TabularData getProperties(String pid); TabularData getPropertiesForLocation(String pid, String location); void setBundleLocation(String pid, String location); void update(String pid, TabularData configurationTable); @SuppressWarnings("unchecked") void updateForLocation(String pid, String location, TabularData configurationTable);  }
@Test public void testGetBundleLocation() throws Exception { org.osgi.service.cm.ConfigurationAdmin admin = mock(org.osgi.service.cm.ConfigurationAdmin.class); String pid = "org.apache.aries.jmx.mock"; Configuration config = mock(Configuration.class); when(admin.getConfiguration(pid, null)).thenReturn(config); when(config.getBundleLocation()).thenReturn("/location"); ConfigurationAdmin mbean = new ConfigurationAdmin(admin); assertEquals("/location", mbean.getBundleLocation(pid)); }