use of org.apache.aries.jmx.codec.BundleData.Header in project aries by apache.
the class BundleState method getHeaders.
private TabularData getHeaders(Dictionary<String, String> bundleHeaders) {
List<Header> headers = new ArrayList<Header>();
Enumeration<String> keys = bundleHeaders.keys();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
headers.add(new Header(key, bundleHeaders.get(key)));
}
TabularData headerTable = new TabularDataSupport(HEADERS_TYPE);
for (Header header : headers) {
headerTable.put(header.toCompositeData());
}
return headerTable;
}
use of org.apache.aries.jmx.codec.BundleData.Header in project aries by apache.
the class BundleDataTest method testHeaderToCompositeData.
@Test
public void testHeaderToCompositeData() throws Exception {
Header h1 = new Header("a", "b");
CompositeData compositeData = h1.toCompositeData();
assertEquals("a", compositeData.get(KEY));
assertEquals("b", compositeData.get(VALUE));
}
use of org.apache.aries.jmx.codec.BundleData.Header in project aries by apache.
the class BundleDataTest method testHeaderFromCompositeData.
@Test
public void testHeaderFromCompositeData() throws Exception {
CompositeData compositeData = new CompositeDataSupport(HEADER_TYPE, new String[] { KEY, VALUE }, new String[] { "c", "d" });
Header header = Header.from(compositeData);
assertEquals("c", header.getKey());
assertEquals("d", header.getValue());
}
use of org.apache.aries.jmx.codec.BundleData.Header in project aries by apache.
the class BundleDataTest method testFromCompositeData.
@Test
public void testFromCompositeData() throws Exception {
Map<String, Object> items = new HashMap<String, Object>();
items.put(EXPORTED_PACKAGES, new String[] { "org.apache.aries.jmx;1.0.0" });
items.put(FRAGMENT, false);
items.put(FRAGMENTS, new Long[0]);
items.put(HOSTS, new Long[0]);
items.put(IDENTIFIER, new Long(3));
items.put(IMPORTED_PACKAGES, new String[] { "org.apache.aries.jmx.b1;0.0.0", "org.apache.aries.jmx.b2;2.0.1" });
items.put(LAST_MODIFIED, new Long(8797));
items.put(LOCATION, "");
items.put(ACTIVATION_POLICY_USED, true);
items.put(PERSISTENTLY_STARTED, false);
items.put(REGISTERED_SERVICES, new Long[0]);
items.put(REMOVAL_PENDING, false);
items.put(REQUIRED, true);
items.put(REQUIRED_BUNDLES, new Long[] { new Long(44), new Long(66) });
items.put(REQUIRING_BUNDLES, new Long[0]);
items.put(SERVICES_IN_USE, new Long[] { new Long(15), new Long(16), new Long(17) });
items.put(START_LEVEL, 1);
items.put(STATE, "ACTIVE");
items.put(SYMBOLIC_NAME, "test");
items.put(VERSION, "0.0.0");
TabularData headerTable = new TabularDataSupport(HEADERS_TYPE);
headerTable.put(new Header("a", "a").toCompositeData());
headerTable.put(new Header("b", "b").toCompositeData());
items.put(HEADERS, headerTable);
CompositeData compositeData = new CompositeDataSupport(BUNDLE_TYPE, items);
BundleData b = BundleData.from(compositeData);
assertEquals("test", b.getSymbolicName());
assertEquals("0.0.0", b.getVersion());
assertEquals(2, b.getHeaders().size());
assertArrayEquals(new String[] { "org.apache.aries.jmx;1.0.0" }, b.getExportedPackages());
assertArrayEquals(new String[] { "org.apache.aries.jmx.b1;0.0.0", "org.apache.aries.jmx.b2;2.0.1" }, b.getImportedPackages());
assertArrayEquals(new long[] { 44, 66 }, b.getRequiredBundles());
assertArrayEquals(new long[] { 15, 16, 17 }, b.getServicesInUse());
//default no return stub
assertEquals("ACTIVE", b.getState());
assertEquals(0, b.getHosts().length);
assertEquals(0, b.getFragments().length);
}
Aggregations