ConfigurationAdmin implements ConfigurationAdminMBean { public TabularData getProperties(String pid) throws IOException { return getPropertiesForLocation(pid, null); } 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 testGetProperties() 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); Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put("one", "value"); props.put("two", 2); when(admin.getConfiguration(eq(pid), anyString())).thenReturn(config); when(config.getProperties()).thenReturn(props); ConfigurationAdmin mbean = new ConfigurationAdmin(admin); TabularData properties = mbean.getPropertiesForLocation(pid, null); assertNotNull(properties); assertEquals(PROPERTIES_TYPE, properties.getTabularType()); assertEquals(2, properties.values().size()); PropertyData<? extends Object> oneData = PropertyData.from(properties.get(new Object[]{ "one"})); assertEquals("value", oneData.getValue()); PropertyData<? extends Object> twoData = PropertyData.from(properties.get(new Object[]{ "two"})); assertEquals(2, twoData.getValue()); assertEquals("2", twoData.getEncodedValue()); }