[jboss-cvs] JBossAS SVN: r107679 - in projects/ejb3/branches/jboss-ejb3-core-1.3/src: test/java/org/jboss/ejb3/core/test and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Aug 19 09:21:14 EDT 2010
Author: wolfc
Date: 2010-08-19 09:21:14 -0400 (Thu, 19 Aug 2010)
New Revision: 107679
Added:
projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2146/
projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2146/AuroraBean.java
projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2146/AuroraLocal.java
projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2146/unit/
projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2146/unit/WaiterTestCase.java
Modified:
projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/statistics/InvocationStatistics.java
Log:
EJBTHREE-2154: created methods and test on TimeStatistics
Modified: projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/statistics/InvocationStatistics.java
===================================================================
--- projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/statistics/InvocationStatistics.java 2010-08-19 05:53:52 UTC (rev 107678)
+++ projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/statistics/InvocationStatistics.java 2010-08-19 13:21:14 UTC (rev 107679)
@@ -51,11 +51,31 @@
{
private static final long serialVersionUID = -3717837456831579570L;
- public AtomicLong count = new AtomicLong();
- public volatile long minTime = Long.MAX_VALUE;
- public volatile long maxTime;
- public AtomicLong totalTime = new AtomicLong();
+ private AtomicLong count = new AtomicLong();
+ private volatile long minTime = Long.MAX_VALUE;
+ private volatile long maxTime;
+ private AtomicLong totalTime = new AtomicLong();
+ public long getCount()
+ {
+ return count.get();
+ }
+
+ public long getMaxTime()
+ {
+ return maxTime;
+ }
+
+ public long getMinTime()
+ {
+ return minTime;
+ }
+
+ public long getTotalTime()
+ {
+ return totalTime.get();
+ }
+
public void reset()
{
count.set(0);
Added: projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2146/AuroraBean.java
===================================================================
--- projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2146/AuroraBean.java (rev 0)
+++ projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2146/AuroraBean.java 2010-08-19 13:21:14 UTC (rev 107679)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.core.test.ejbthree2146;
+
+import javax.ejb.Stateless;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+ at Stateless
+public class AuroraBean implements AuroraLocal
+{
+ @Override
+ public void sleep(long timeout, TimeUnit unit) throws InterruptedException
+ {
+ Thread.sleep(unit.toMillis(timeout));
+ }
+}
Added: projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2146/AuroraLocal.java
===================================================================
--- projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2146/AuroraLocal.java (rev 0)
+++ projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2146/AuroraLocal.java 2010-08-19 13:21:14 UTC (rev 107679)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.core.test.ejbthree2146;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public interface AuroraLocal
+{
+ void sleep(long timeout, TimeUnit unit) throws InterruptedException;
+}
Added: projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2146/unit/WaiterTestCase.java
===================================================================
--- projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2146/unit/WaiterTestCase.java (rev 0)
+++ projects/ejb3/branches/jboss-ejb3-core-1.3/src/test/java/org/jboss/ejb3/core/test/ejbthree2146/unit/WaiterTestCase.java 2010-08-19 13:21:14 UTC (rev 107679)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.core.test.ejbthree2146.unit;
+
+import org.jboss.ejb3.core.test.common.AbstractEJB3TestCase;
+import org.jboss.ejb3.core.test.ejbthree2146.AuroraBean;
+import org.jboss.ejb3.core.test.ejbthree2146.AuroraLocal;
+import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.statistics.InvocationStatistics;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test whether we can actually get some stats.
+ * This is to the contract with ejb3-metrics-deployer.
+ *
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class WaiterTestCase extends AbstractEJB3TestCase
+{
+ private static SessionContainer container;
+
+ @AfterClass
+ public static void afterClass() throws Exception
+ {
+ undeployEjb(container);
+
+ AbstractEJB3TestCase.afterClass();
+ }
+
+ @BeforeClass
+ public static void beforeClass() throws Exception
+ {
+ AbstractEJB3TestCase.beforeClass();
+
+ container = deploySessionEjb(AuroraBean.class);
+ }
+
+ @Test
+ public void testStats() throws Exception
+ {
+ AuroraLocal bean = lookup("AuroraBean/local", AuroraLocal.class);
+
+ InvocationStatistics stats = container.getInvokeStats();
+
+ // Since we don't have a prince at hand, lets not sleep forever
+ bean.sleep(100, MILLISECONDS);
+
+ InvocationStatistics.TimeStatistic methodStat = stats.getStats().get("sleep");
+ assertNotNull(methodStat);
+ long count = methodStat.getCount();
+ assertEquals(1, count);
+ long maxTime = methodStat.getMaxTime();
+ long minTime = methodStat.getMinTime();
+ long totalTime = methodStat.getTotalTime();
+ assertTrue(maxTime == minTime);
+ assertTrue(minTime == totalTime);
+ }
+}
More information about the jboss-cvs-commits
mailing list