You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2010/10/22 03:41:52 UTC

svn commit: r1026195 - in /openejb/trunk/openejb3: ./ container/openejb-core/src/main/java/org/apache/openejb/monitoring/ container/openejb-core/src/test/java/org/apache/openejb/config/ container/openejb-core/src/test/java/org/apache/openejb/core/state...

Author: dblevins
Date: Fri Oct 22 01:41:52 2010
New Revision: 1026195

URL: http://svn.apache.org/viewvc?rev=1026195&view=rev
Log:
svn merge -r 1023115:1023116 https://svn.apache.org/repos/asf/openejb/branches/openejb-3.1.x

http://svn.apache.org/viewvc?view=revision&revision=1023116
------------------------------------------------------------------------
r1023116 | dblevins | 2010-10-15 14:25:29 -0700 (Fri, 15 Oct 2010) | 3 lines

Hopefully permanently fixes Sweeps test.
Basically added a "long Sweeps.LatestTime" so we can to the millisecond accuracy off the stat and have a greater guarantee it will always pass.  Previously there was only a formatted date string of the last sweep time so all milliseconds were lost -- more if the default system time shaved off seconds too.

------------------------------------------------------------------------

Modified:
    openejb/trunk/openejb3/   (props changed)
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/monitoring/Event.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/BusinessInterfacesTest.java   (props changed)
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessPoolStatsTest.java
    openejb/trunk/openejb3/examples/alternate-descriptors/src/main/resources/META-INF/test.ejb-jar.xml   (props changed)

Propchange: openejb/trunk/openejb3/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Oct 22 01:41:52 2010
@@ -1,3 +1,3 @@
 /openejb/branches/openejb-3.1.1:779593
-/openejb/branches/openejb-3.1.x:945409,945448,1004381,1005322,1021880,1021903,1021955,1021961,1021965,1021975,1021979,1021990,1022375,1022393,1023096,1023125
+/openejb/branches/openejb-3.1.x:945409,945448,1004381,1005322,1021880,1021903,1021955,1021961,1021965,1021975,1021979,1021990,1022375,1022393,1023096,1023116,1023125
 /openejb/branches/openejb-jcdi:984659-985270

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/monitoring/Event.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/monitoring/Event.java?rev=1026195&r1=1026194&r2=1026195&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/monitoring/Event.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/monitoring/Event.java Fri Oct 22 01:41:52 2010
@@ -52,4 +52,9 @@ public class Event {
         DateFormat format = SimpleDateFormat.getDateTimeInstance();
         return format.format(new Date(last));
     }
+
+    @Managed
+    public long getLatestTime() {
+        return this.last.get();
+    }
 }

Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/BusinessInterfacesTest.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Oct 22 01:41:52 2010
@@ -1,3 +1,3 @@
 /openejb/branches/openejb-3.1.1/container/openejb-core/src/test/java/org/apache/openejb/config/UberInterfaceTest.java:779593
-/openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/config/BusinessInterfacesTest.java:945409,945448,1005322,1021880,1021903,1021955,1021961,1021965,1021975,1021979,1021990,1022375,1022393,1023096,1023125
+/openejb/branches/openejb-3.1.x/container/openejb-core/src/test/java/org/apache/openejb/config/BusinessInterfacesTest.java:945409,945448,1005322,1021880,1021903,1021955,1021961,1021965,1021975,1021979,1021990,1022375,1022393,1023096,1023116,1023125
 /openejb/branches/openejb-jcdi/container/openejb-core/src/test/java/org/apache/openejb/config/BusinessInterfacesTest.java:984659-985270

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessPoolStatsTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessPoolStatsTest.java?rev=1026195&r1=1026194&r2=1026195&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessPoolStatsTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessPoolStatsTest.java Fri Oct 22 01:41:52 2010
@@ -31,7 +31,6 @@ import javax.annotation.PreDestroy;
 import javax.annotation.Resource;
 import javax.annotation.PostConstruct;
 import javax.ejb.SessionContext;
-import javax.ejb.ConcurrentAccessTimeoutException;
 import javax.ejb.ConcurrentAccessException;
 import javax.management.AttributeNotFoundException;
 import javax.management.InstanceNotFoundException;
@@ -87,19 +86,25 @@ public class StatelessPoolStatsTest exte
         List<MBeanAttributeInfo> expectedAttributes = new ArrayList<MBeanAttributeInfo>();
         expectedAttributes.add(new MBeanAttributeInfo("AccessTimeouts", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("AccessTimeouts.Latest", "java.lang.String", "", true, false, false));
+        expectedAttributes.add(new MBeanAttributeInfo("AccessTimeouts.LatestTime", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("Aged", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("Aged.Latest", "java.lang.String", "", true, false, false));
+        expectedAttributes.add(new MBeanAttributeInfo("Aged.LatestTime", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("AvailablePermits", "int", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("Flushed", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("Flushed.Latest", "java.lang.String", "", true, false, false));
+        expectedAttributes.add(new MBeanAttributeInfo("Flushed.LatestTime", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("Flushes", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("Flushes.Latest", "java.lang.String", "", true, false, false));
+        expectedAttributes.add(new MBeanAttributeInfo("Flushes.LatestTime", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("GarbageCollected", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("GarbageCollected.Latest", "java.lang.String", "", true, false, false));
+        expectedAttributes.add(new MBeanAttributeInfo("GarbageCollected.LatestTime", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("GarbageCollection", "boolean", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("IdleTimeout", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("IdleTimeouts", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("IdleTimeouts.Latest", "java.lang.String", "", true, false, false));
+        expectedAttributes.add(new MBeanAttributeInfo("IdleTimeouts.LatestTime", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("InstancesActive", "int", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("InstancesIdle", "int", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("InstancesInitializing", "int", "", true, false, false));
@@ -111,15 +116,18 @@ public class StatelessPoolStatsTest exte
         expectedAttributes.add(new MBeanAttributeInfo("MinimumInstances", "int", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("Overdrafts", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("Overdrafts.Latest", "java.lang.String", "", true, false, false));
+        expectedAttributes.add(new MBeanAttributeInfo("Overdrafts.LatestTime", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("PoolVersion", "int", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("ReplaceAged", "boolean", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("ReplaceFlushed", "boolean", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("Replaced", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("Replaced.Latest", "java.lang.String", "", true, false, false));
+        expectedAttributes.add(new MBeanAttributeInfo("Replaced.LatestTime", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("StrictPooling", "boolean", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("SweepInterval", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("Sweeps", "long", "", true, false, false));
         expectedAttributes.add(new MBeanAttributeInfo("Sweeps.Latest", "java.lang.String", "", true, false, false));
+        expectedAttributes.add(new MBeanAttributeInfo("Sweeps.LatestTime", "long", "", true, false, false));
 
 
         // The hardest part, check the values of each, PoolVersion is AtomicaInteger, *.Latest are time-sensitive, so not verified.
@@ -130,7 +138,7 @@ public class StatelessPoolStatsTest exte
         expectedAttributesValue.put("Flushed", (long) 0);
         expectedAttributesValue.put("Flushes", (long) 0);
         expectedAttributesValue.put("GarbageCollected", (long) 0);
-        expectedAttributesValue.put("GarbageCollection", true);
+        expectedAttributesValue.put("GarbageCollection", false);
         expectedAttributesValue.put("IdleTimeout", (long) 0);
         expectedAttributesValue.put("IdleTimeouts", (long) 0);
         expectedAttributesValue.put("InstancesPooled", (int) 3);
@@ -155,7 +163,7 @@ public class StatelessPoolStatsTest exte
         Map<String, Object> actualAttributesValue = new HashMap<String, Object>();
         for (MBeanAttributeInfo info : poolMBeanInfo.getAttributes()) {
             actualAttributes.add(info);
-            if (!info.getName().endsWith(".Latest")) {
+            if (!info.getName().endsWith(".Latest") && !info.getName().endsWith(".LatestTime")) {
                 actualAttributesValue.put(info.getName(), server.getAttribute(objectName, info.getName()));
             }
         }
@@ -479,19 +487,26 @@ public class StatelessPoolStatsTest exte
      */
     public void testSweeps() throws Exception {
     	Properties properties = new Properties();
-    	properties.setProperty("SweepInterval", "1");
+    	properties.setProperty("SweepInterval", "100");
+
+        Date expectedDate = new Date(); // now
 
         deploy("testSweeps", properties);
 
-        assertTrue((Long)(server.getAttribute(objectName, "Sweeps")) >= 1L);
+        Thread.sleep(200);
+
+        final Long sweeps = (Long) (server.getAttribute(objectName, "Sweeps"));
+        assertTrue("sweeps=" + sweeps, sweeps >= 1L);
 
-        //Get current time
-        DateFormat dateFormatter = SimpleDateFormat.getDateTimeInstance();
+        final Object attribute = server.getAttribute(objectName, "Sweeps.LatestTime");
+        final Date actualDate = new Date((Long)attribute);
 
-        Date expected = new Date(System.currentTimeMillis() - 1 * 60 * 1000L);
+        final String message = display("actual", actualDate) + " after " + display("expected", expectedDate);
+        assertTrue(message, actualDate.after(expectedDate));
+    }
 
-        final String latest = (String) (server.getAttribute(objectName, "Sweeps.Latest"));
-        assertTrue(dateFormatter.parse(latest).after(expected));
+    private String display(String name, Date date) {
+        return name + "=" + date.getTime();
     }
 
     /**

Propchange: openejb/trunk/openejb3/examples/alternate-descriptors/src/main/resources/META-INF/test.ejb-jar.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Oct 22 01:41:52 2010
@@ -1,3 +1,3 @@
 /openejb/branches/openejb-3.1.1/examples/alternate-descriptors/src/main/resources/META-INF/ejb-jar.xml:779593
-/openejb/branches/openejb-3.1.x/examples/alternate-descriptors/src/main/resources/META-INF/test.ejb-jar.xml:945409,945448,1005322,1021880,1021903,1021955,1021961,1021965,1021975,1021979,1021990,1022375,1022393,1023096,1023125
+/openejb/branches/openejb-3.1.x/examples/alternate-descriptors/src/main/resources/META-INF/test.ejb-jar.xml:945409,945448,1005322,1021880,1021903,1021955,1021961,1021965,1021975,1021979,1021990,1022375,1022393,1023096,1023116,1023125
 /openejb/branches/openejb-jcdi/examples/alternate-descriptors/src/main/resources/META-INF/test.ejb-jar.xml:984659-985270