Search in sources :

Example 1 with BundleEventData

use of org.apache.aries.jmx.codec.BundleEventData in project aries by apache.

the class BundleStateTest method testNotificationsForBundleEvents.

@Test
public void testNotificationsForBundleEvents() throws Exception {
    StateConfig stateConfig = new StateConfig();
    //holders for Notifications captured
    List<Notification> received = new LinkedList<Notification>();
    List<AttributeChangeNotification> attributeChanges = new LinkedList<AttributeChangeNotification>();
    createBundle(stateConfig, received, attributeChanges);
    assertEquals(2, received.size());
    Notification installed = received.get(0);
    assertEquals(1, installed.getSequenceNumber());
    CompositeData installedCompositeData = (CompositeData) installed.getUserData();
    BundleEventData installedData = BundleEventData.from(installedCompositeData);
    assertEquals("bundle", installedData.getBundleSymbolicName());
    assertEquals(9, installedData.getBundleId());
    assertEquals("file:/location", installedData.getLocation());
    assertEquals(BundleEvent.INSTALLED, installedData.getEventType());
    Notification resolved = received.get(1);
    assertEquals(2, resolved.getSequenceNumber());
    CompositeData resolvedCompositeData = (CompositeData) resolved.getUserData();
    BundleEventData resolvedData = BundleEventData.from(resolvedCompositeData);
    assertEquals("bundle", resolvedData.getBundleSymbolicName());
    assertEquals(9, resolvedData.getBundleId());
    assertEquals("file:/location", resolvedData.getLocation());
    assertEquals(BundleEvent.RESOLVED, resolvedData.getEventType());
    assertEquals(1, attributeChanges.size());
    AttributeChangeNotification ac = attributeChanges.get(0);
    assertEquals("BundleIds", ac.getAttributeName());
    assertEquals(0, ((long[]) ac.getOldValue()).length);
    assertEquals(1, ((long[]) ac.getNewValue()).length);
    assertEquals(9L, ((long[]) ac.getNewValue())[0]);
}
Also used : AttributeChangeNotification(javax.management.AttributeChangeNotification) CompositeData(javax.management.openmbean.CompositeData) BundleEventData(org.apache.aries.jmx.codec.BundleEventData) LinkedList(java.util.LinkedList) AttributeChangeNotification(javax.management.AttributeChangeNotification) Notification(javax.management.Notification) Test(org.junit.Test)

Aggregations

LinkedList (java.util.LinkedList)1 AttributeChangeNotification (javax.management.AttributeChangeNotification)1 Notification (javax.management.Notification)1 CompositeData (javax.management.openmbean.CompositeData)1 BundleEventData (org.apache.aries.jmx.codec.BundleEventData)1 Test (org.junit.Test)1