ConfigurationAdmin implements ConfigurationAdminMBean { public String[][] getConfigurations(String filter) throws IOException { if (filter == null || filter.length() < 1) { throw new IOException("Argument filter cannot be null or empty"); } List<String[]> result = new ArrayList<String[]>(); Configuration[] configurations = null; try { configurations = configurationAdmin.listConfigurations(filter); } catch (InvalidSyntaxException e) { throw new IOException("Invalid filter [" + filter + "] : " + e); } if (configurations != null) { for (Configuration config : configurations) { result.add(new String[] { config.getPid(), config.getBundleLocation() }); } } return result.toArray(new String[result.size()][]); } 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 testGetConfigurations() throws Exception { org.osgi.service.cm.ConfigurationAdmin admin = mock(org.osgi.service.cm.ConfigurationAdmin.class); String factoryPid = "org.apache.aries.jmx.factory.mock"; String filter = "(" + org.osgi.service.cm.ConfigurationAdmin.SERVICE_FACTORYPID + "=org.apache.aries.jmx.factory.mock)"; String location = "../location"; Configuration a = mock(Configuration.class); when(a.getPid()).thenReturn(factoryPid + "-2160133952674-0"); when(a.getBundleLocation()).thenReturn(location); Configuration b = mock(Configuration.class); when(b.getPid()).thenReturn(factoryPid + "-1260133982371-1"); when(b.getBundleLocation()).thenReturn(location); when(admin.listConfigurations(filter)).thenReturn(new Configuration[] { a, b}); ConfigurationAdmin mbean = new ConfigurationAdmin(admin); String[][] result = mbean.getConfigurations(filter); assertEquals(2, result.length); assertArrayEquals(new String[]{ factoryPid + "-2160133952674-0", location }, result[0] ); assertArrayEquals(new String[]{ factoryPid + "-1260133982371-1", location }, result[1] ); }