aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1339533 - in /aries/trunk/sandbox/jmx-next: jmx-core/src/main/java/org/apache/aries/jmx/framework/ jmx-core/src/test/java/org/apache/aries/jmx/framework/ jmx-itests/src/test/java/org/apache/aries/jmx/framework/
Date Thu, 17 May 2012 09:45:19 GMT
Author: davidb
Date: Thu May 17 09:45:18 2012
New Revision: 1339533

URL: http://svn.apache.org/viewvc?rev=1339533&view=rev
Log:
JMX-Next: Change JMX attribute notifications on ServiceStateMBean.getServiceIds() changed
from Long [] to long []

Modified:
    aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/ServiceState.java
    aries/trunk/sandbox/jmx-next/jmx-core/src/test/java/org/apache/aries/jmx/framework/ServiceStateTest.java
    aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java

Modified: aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/ServiceState.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/ServiceState.java?rev=1339533&r1=1339532&r2=1339533&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/ServiceState.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/framework/ServiceState.java
Thu May 17 09:45:18 2012
@@ -305,11 +305,21 @@ public class ServiceState extends Notifi
             // Sorting is not mandatory, but its nice for the user, note that getServiceIds()
also returns a sorted array
             Collections.sort(with);
 
-            Long[] oldIDs = (eventType == ServiceEvent.REGISTERED ? without : with).toArray(new
Long[] {});
-            Long[] newIDs = (eventType == ServiceEvent.REGISTERED ? with : without).toArray(new
Long[] {});
+            List<Long> oldList = eventType == ServiceEvent.REGISTERED ? without : with;
+            List<Long> newList = eventType == ServiceEvent.REGISTERED ? with : without;
+
+            long[] oldIDs = new long[oldList.size()];
+            for (int i = 0; i < oldIDs.length; i++) {
+                oldIDs[i] = oldList.get(i);
+            }
+
+            long[] newIDs = new long[newList.size()];
+            for (int i = 0; i < newIDs.length; i++) {
+                newIDs[i] = newList.get(i);
+            }
 
             return new AttributeChangeNotification(OBJECTNAME, attributeChangeNotificationSequenceNumber.getAndIncrement(),
-                    System.currentTimeMillis(), "ServiceIds changed", "ServiceIds", "[Ljava.lang.Long;",
oldIDs, newIDs);
+                    System.currentTimeMillis(), "ServiceIds changed", "ServiceIds", "Array
of long", oldIDs, newIDs);
         default:
             return null;
         }

Modified: aries/trunk/sandbox/jmx-next/jmx-core/src/test/java/org/apache/aries/jmx/framework/ServiceStateTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-core/src/test/java/org/apache/aries/jmx/framework/ServiceStateTest.java?rev=1339533&r1=1339532&r2=1339533&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-core/src/test/java/org/apache/aries/jmx/framework/ServiceStateTest.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-core/src/test/java/org/apache/aries/jmx/framework/ServiceStateTest.java
Thu May 17 09:45:18 2012
@@ -157,9 +157,9 @@ public class ServiceStateTest {
         assertEquals(1, attributeChanges.size());
         AttributeChangeNotification ac = attributeChanges.get(0);
         assertEquals("ServiceIds", ac.getAttributeName());
-        assertEquals(0, ((Long [])ac.getOldValue()).length);
-        assertEquals(1, ((Long [])ac.getNewValue()).length);
-        assertEquals(new Long(44), ((Long [])ac.getNewValue())[0]);
+        assertEquals(0, ((long [])ac.getOldValue()).length);
+        assertEquals(1, ((long [])ac.getNewValue()).length);
+        assertEquals(44L, ((long [])ac.getNewValue())[0]);
     }
 
     @Test

Modified: aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java?rev=1339533&r1=1339532&r2=1339533&view=diff
==============================================================================
--- aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java
(original)
+++ aries/trunk/sandbox/jmx-next/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java
Thu May 17 09:45:18 2012
@@ -32,7 +32,6 @@ import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -262,27 +261,23 @@ public class ServiceStateMBeanTest exten
 
         assertEquals("Precondition", 0, attributeChanges.size());
 
-        long[] ids = mbean.getServiceIds();
-        Long[] idsWithoutService = new Long[ids.length];
-        for(int i=0; i < ids.length; i++) {
-            idsWithoutService[i] = ids[i];
-        }
+        long[] idsWithout = mbean.getServiceIds();
 
         String svc = "A String Service";
         ServiceRegistration<?> reg = bundleContext.registerService(String.class.getName(),
svc, null);
         long id = (Long) reg.getReference().getProperty(Constants.SERVICE_ID);
 
-        List<Long> newIDList = new ArrayList<Long>(Arrays.asList(idsWithoutService));
-        newIDList.add(id);
-        Collections.sort(newIDList);
-        Long[] idsWithService = newIDList.toArray(new Long [] {});
+        long[] idsWith = new long[idsWithout.length + 1];
+        System.arraycopy(idsWithout, 0, idsWith, 0, idsWithout.length);
+        idsWith[idsWith.length - 1] = id;
+        Arrays.sort(idsWith);
 
         waitForListToReachSize(attributeChanges, 1);
         AttributeChangeNotification ac = attributeChanges.get(0);
         assertEquals("ServiceIds", ac.getAttributeName());
         assertEquals(1, ac.getSequenceNumber());
-        assertTrue(Arrays.equals(idsWithoutService, (Long []) ac.getOldValue()));
-        assertTrue(Arrays.equals(idsWithService, (Long []) ac.getNewValue()));
+        assertTrue(Arrays.equals(idsWithout, (long []) ac.getOldValue()));
+        assertTrue(Arrays.equals(idsWith, (long []) ac.getNewValue()));
 
         Dictionary<String, Object> props = new Hashtable<String, Object>();
         props.put("somekey", "someval");
@@ -299,8 +294,8 @@ public class ServiceStateMBeanTest exten
         AttributeChangeNotification ac2 = attributeChanges.get(1);
         assertEquals("ServiceIds", ac2.getAttributeName());
         assertEquals(2, ac2.getSequenceNumber());
-        assertTrue(Arrays.equals(idsWithService, (Long []) ac2.getOldValue()));
-        assertTrue(Arrays.equals(idsWithoutService, (Long []) ac2.getNewValue()));
+        assertTrue(Arrays.equals(idsWith, (long []) ac2.getOldValue()));
+        assertTrue(Arrays.equals(idsWithout, (long []) ac2.getNewValue()));
     }
 
     @Test



Mime
View raw message