Search in sources :

Example 1 with ProvisioningServiceMBean

use of org.osgi.jmx.service.provisioning.ProvisioningServiceMBean in project aries by apache.

the class ProvisioningServiceMBeanTest method testMBeanInterface.

@Ignore("For now.. Cannot find public repo for org.eclipse.equinox.ip")
@Test
@SuppressWarnings({ "unchecked" })
public void testMBeanInterface() throws Exception {
    ProvisioningServiceMBean mbean = getMBean(ProvisioningServiceMBean.OBJECTNAME, ProvisioningServiceMBean.class);
    Dictionary<String, Object> info;
    // add information URL (create temp zip file)
    File provZip = createProvAgentConfigZip();
    mbean.addInformationFromZip(provZip.toURI().toURL().toExternalForm());
    //check the info has been added
    info = ps.getInformation();
    assertNotNull(info);
    assertTrue(info.size() >= 1);
    assertProvAgentConfigCorrect(info);
    // test list information
    TabularData data = mbean.listInformation();
    assertNotNull(data);
    assertEquals(JmxConstants.PROPERTIES_TYPE, data.getTabularType());
    assertTrue(data.values().size() >= 1);
    PropertyData<byte[]> configEntry = PropertyData.from(data.get(new Object[] { PROVISIONING_AGENT_CONFIG }));
    assertNotNull(configEntry);
    assertArrayEquals(new byte[] { 10, 20, 30 }, configEntry.getValue());
    // test add information
    PropertyData<String> reference = PropertyData.newInstance(PROVISIONING_REFERENCE, "rsh://0.0.0.0/provX");
    data.put(reference.toCompositeData());
    mbean.addInformation(data);
    info = ps.getInformation();
    assertNotNull(info);
    assertTrue(info.size() >= 2);
    assertProvAgentConfigCorrect(info);
    String ref = (String) info.get(PROVISIONING_REFERENCE);
    assertNotNull(ref);
    assertEquals("rsh://0.0.0.0/provX", ref);
    // test set information
    data.clear();
    PropertyData<String> newRef = PropertyData.newInstance(PROVISIONING_REFERENCE, "rsh://0.0.0.0/newProvRef");
    data.put(newRef.toCompositeData());
    mbean.setInformation(data);
    info = ps.getInformation();
    assertNotNull(info);
    assertTrue(info.size() >= 1);
    assertNull(info.get(PROVISIONING_AGENT_CONFIG));
    ref = (String) info.get(PROVISIONING_REFERENCE);
    assertNotNull(ref);
    assertEquals("rsh://0.0.0.0/newProvRef", ref);
}
Also used : ProvisioningServiceMBean(org.osgi.jmx.service.provisioning.ProvisioningServiceMBean) File(java.io.File) TabularData(javax.management.openmbean.TabularData) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.jmx.AbstractIntegrationTest)

Aggregations

File (java.io.File)1 TabularData (javax.management.openmbean.TabularData)1 AbstractIntegrationTest (org.apache.aries.jmx.AbstractIntegrationTest)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 ProvisioningServiceMBean (org.osgi.jmx.service.provisioning.ProvisioningServiceMBean)1