p-unit-devel Mailing List for p-unit (Page 2)
Status: Beta
Brought to you by:
zhanghuangzhu
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(182) |
Jun
(46) |
Jul
(3) |
Aug
(2) |
Sep
(1) |
Oct
(7) |
Nov
(18) |
Dec
(8) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(9) |
Feb
(5) |
Mar
(10) |
Apr
(17) |
May
(16) |
Jun
(16) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Andrew Z. <zha...@gm...> - 2008-05-28 01:06:28
|
Hi, Does anyone use p-unit to test the performance of different JREs? If no one uses this functionality, I'll remove the code from p-unit, to make it easy maintainable. Thanks! -- Best regards, Andrew Zhang db4o - database for Android: www.db4o.com http://zhanghuangzhu.blogspot.com/ |
|
From: <zha...@us...> - 2008-05-28 00:44:39
|
Revision: 311
http://p-unit.svn.sourceforge.net/p-unit/?rev=311&view=rev
Author: zhanghuangzhu
Date: 2008-05-27 17:44:46 -0700 (Tue, 27 May 2008)
Log Message:
-----------
az: applied nested beforeClass/afterClass/setUp/tearDown patch from Chris Wilson.
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/convention/AnnotationFilterTest.java
trunk/punit.test/src/tests/api/org/punit/convention/NameConventionFilterTest.java
trunk/punit.test/src/tests/api/org/punit/runner/ConcurrentRunnerTest.java
trunk/punit.test/src/tests/api/org/punit/testclasses/AnnotationTestClass.java
trunk/punit.test/src/tests/api/org/punit/testclasses/TestClass0.java
Added Paths:
-----------
trunk/punit.test/src/tests/api/org/punit/testclasses/SuperAnnotationTestClass.java
Modified: trunk/punit.test/src/tests/api/org/punit/convention/AnnotationFilterTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/convention/AnnotationFilterTest.java 2008-05-28 00:44:26 UTC (rev 310)
+++ trunk/punit.test/src/tests/api/org/punit/convention/AnnotationFilterTest.java 2008-05-28 00:44:46 UTC (rev 311)
@@ -109,6 +109,23 @@
assertNull(_filter.getAfterClassMethod(TestClass1.class));
}
+ public void testGetNestedBeforeClass() {
+ assertTrue(_filter.getBeforeClassMethod(AnnotationTestClass.class).length == 2);
+
+ }
+
+ public void testGetNestedAfterClass() {
+ assertTrue(_filter.getAfterClassMethod(AnnotationTestClass.class).length == 2);
+ }
+
+ public void testGetNestedSetupMethod() {
+ assertTrue(_filter.getSetUpMethod(AnnotationTestClass.class).length == 2);
+ }
+
+ public void testGetNestedTearDownMethod() {
+ assertTrue(_filter.getTearDownMethod(AnnotationTestClass.class).length == 2);
+ }
+
@Ignore
static class ExcludedClass {
Modified: trunk/punit.test/src/tests/api/org/punit/convention/NameConventionFilterTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/convention/NameConventionFilterTest.java 2008-05-28 00:44:26 UTC (rev 310)
+++ trunk/punit.test/src/tests/api/org/punit/convention/NameConventionFilterTest.java 2008-05-28 00:44:46 UTC (rev 311)
@@ -63,12 +63,12 @@
}
public void testGetBeforeClass() {
- assertEquals("beforeClass", _convention.getBeforeClassMethod(TestClass0.class).getName());
+ assertEquals("beforeClass", _convention.getBeforeClassMethod(TestClass0.class)[0].getName());
assertNull(_convention.getBeforeClassMethod(TestClass1.class));
}
public void testGetAfterClass() {
- assertEquals("afterClass", _convention.getAfterClassMethod(TestClass0.class).getName());
+ assertEquals("afterClass", _convention.getAfterClassMethod(TestClass0.class)[0].getName());
assertNull(_convention.getAfterClassMethod(TestClass1.class));
}
Modified: trunk/punit.test/src/tests/api/org/punit/runner/ConcurrentRunnerTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/runner/ConcurrentRunnerTest.java 2008-05-28 00:44:26 UTC (rev 310)
+++ trunk/punit.test/src/tests/api/org/punit/runner/ConcurrentRunnerTest.java 2008-05-28 00:44:46 UTC (rev 311)
@@ -22,12 +22,15 @@
public class ConcurrentRunnerTest extends TestCase {
- private ConcurrentRunner _runner = new ConcurrentRunner();
+ private ConcurrentRunner _runner;
public static void main(String[] args) {
new SoloRunner().run(ConcurrentRunnerTest.class);
}
-
+
+ public void setUp() {
+ _runner = new ConcurrentRunner();
+ }
public void testMain() {
ConcurrentRunner.main(new String[] { TestSuiteClass.class.getName() });
}
Modified: trunk/punit.test/src/tests/api/org/punit/testclasses/AnnotationTestClass.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/testclasses/AnnotationTestClass.java 2008-05-28 00:44:26 UTC (rev 310)
+++ trunk/punit.test/src/tests/api/org/punit/testclasses/AnnotationTestClass.java 2008-05-28 00:44:46 UTC (rev 311)
@@ -8,7 +8,7 @@
import org.punit.runner.*;
@Test(concurrentCount=5)
-public class AnnotationTestClass {
+public class AnnotationTestClass extends SuperAnnotationTestClass {
public static void main(String[] args) {
SoloRunner soloRunner = new SoloRunner();
@@ -126,5 +126,6 @@
Assert.assertTrue(_setUp);
Assert.assertTrue(_tearDown);
+ SuperAnnotationTestClass.assertTestClassRun();
}
}
Added: trunk/punit.test/src/tests/api/org/punit/testclasses/SuperAnnotationTestClass.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/testclasses/SuperAnnotationTestClass.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/testclasses/SuperAnnotationTestClass.java 2008-05-28 00:44:46 UTC (rev 311)
@@ -0,0 +1,54 @@
+package tests.api.org.punit.testclasses;
+
+import junit.framework.*;
+
+import org.punit.annotation.*;
+import org.punit.annotation.Test;
+
+@Test(concurrentCount=5)
+public class SuperAnnotationTestClass {
+
+ private static boolean _beforeClass;
+ private static boolean _afterClass;
+ private static boolean _setUp;
+ private static boolean _tearDown;
+
+ public static void reset() {
+ _setUp = false;
+ _tearDown = false;
+ _beforeClass = false;
+ _afterClass = false;
+ }
+
+ @SuppressWarnings("unused")
+ @BeforeClass
+ private static void beforeClassMethod() {
+ _beforeClass = true;
+ }
+
+ @SuppressWarnings("unused")
+ @AfterClass
+ private static void afterClassMethod() {
+ _afterClass = true;
+ }
+
+ @SuppressWarnings("unused")
+ @Before
+ private void before() {
+ _setUp = true;
+ }
+
+ @SuppressWarnings("unused")
+ @After
+ private void after() {
+ _tearDown = true;
+ }
+
+ public static void assertTestClassRun() {
+ Assert.assertTrue(_beforeClass);
+ Assert.assertTrue(_afterClass);
+
+ Assert.assertTrue(_setUp);
+ Assert.assertTrue(_tearDown);
+ }
+}
\ No newline at end of file
Property changes on: trunk/punit.test/src/tests/api/org/punit/testclasses/SuperAnnotationTestClass.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/punit.test/src/tests/api/org/punit/testclasses/TestClass0.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/testclasses/TestClass0.java 2008-05-28 00:44:26 UTC (rev 310)
+++ trunk/punit.test/src/tests/api/org/punit/testclasses/TestClass0.java 2008-05-28 00:44:46 UTC (rev 311)
@@ -37,10 +37,12 @@
}
private void setUp() {
+ System.err.println("setup");
_setUp = true;
}
private void tearDown() {
+ System.err.println("tearDown");
_tearDown = true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-05-28 00:44:19
|
Revision: 310
http://p-unit.svn.sourceforge.net/p-unit/?rev=310&view=rev
Author: zhanghuangzhu
Date: 2008-05-27 17:44:26 -0700 (Tue, 27 May 2008)
Log Message:
-----------
az: applied nested beforeClass/afterClass/setUp/tearDown patch from Chris Wilson.
Modified Paths:
--------------
trunk/punit/src/org/punit/convention/AnnotationConvention.java
trunk/punit/src/org/punit/convention/ByNameConvention.java
trunk/punit/src/org/punit/convention/Convention.java
trunk/punit/src/org/punit/exception/PUnitException.java
trunk/punit/src/org/punit/method/runner/AbstractMethodRunner.java
trunk/punit/src/org/punit/runner/AbstractRunner.java
trunk/punit/src/org/punit/util/AnnotationUtil.java
Added Paths:
-----------
trunk/punit/src/org/punit/exception/AnnotationException.java
Modified: trunk/punit/src/org/punit/convention/AnnotationConvention.java
===================================================================
--- trunk/punit/src/org/punit/convention/AnnotationConvention.java 2008-05-22 12:47:41 UTC (rev 309)
+++ trunk/punit/src/org/punit/convention/AnnotationConvention.java 2008-05-28 00:44:26 UTC (rev 310)
@@ -4,7 +4,12 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
import org.punit.annotation.Test;
+import org.punit.exception.AnnotationException;
import org.punit.util.AnnotationUtil;
import org.punit.util.ReflectionUtil;
@@ -95,40 +100,110 @@
}
@SuppressWarnings("unchecked")
- public Method getAfterClassMethod(Class test) {
- Method method = AnnotationUtil.getMethodByAnnotation(test, _afterClass);
- if (method == null) {
- method = _delegate.getAfterClassMethod(test);
+ public Method[] getAfterClassMethod(Class test) {
+ return getAfterClassMethod(test, false);
+ }
+ @SuppressWarnings("unchecked")
+ private Method[] getAfterClassMethod(Class test, boolean annotationOnly) {
+ if (test == null) return new Method[0];
+
+ Method[] annotatedMethods = AnnotationUtil.getMethodsByAnnotation(test, _afterClass);
+ if (annotatedMethods != null && annotatedMethods.length > 1) throw new AnnotationException( "Too many @AfterClass annotations - only one allowed per class" );
+
+ // Get the AfterClass methods from the superclasses (if any) - only look at annotations, though
+ Method[] superMethods = getAfterClassMethod(test.getSuperclass(), true);
+
+ // Look for un-anotated method in this class if there has been no annotated methods in superclass
+ if (annotationOnly = false && (annotatedMethods == null || annotatedMethods.length == 0) && (superMethods == null || superMethods.length==0)) {
+ return _delegate.getAfterClassMethod(test);
}
- return method;
+
+ // This classes method needs to be on the list before its superclasses
+ List<Method> methodsList = new ArrayList<Method>();
+ if (annotatedMethods != null && annotatedMethods.length > 0) methodsList.add(annotatedMethods[0]);
+ if (superMethods != null) methodsList.addAll(Arrays.asList(superMethods));
+
+ return methodsList.size() == 0 ? null : methodsList.toArray(new Method[0]);
}
@SuppressWarnings("unchecked")
- public Method getBeforeClassMethod(Class test) {
- Method method = AnnotationUtil
- .getMethodByAnnotation(test, _beforeClass);
- if (method == null) {
- method = _delegate.getBeforeClassMethod(test);
+ public Method[] getBeforeClassMethod(Class test) {
+ return getBeforeClassMethod(test, false);
+ }
+ @SuppressWarnings("unchecked")
+ private Method[] getBeforeClassMethod(Class test, boolean annotationOnly) {
+ if (test == null) return new Method[0];
+
+ Method[] annotatedMethods = AnnotationUtil
+ .getMethodsByAnnotation(test, _beforeClass);
+ if (annotatedMethods != null && annotatedMethods.length > 1) throw new AnnotationException( "Too many @BeforeClass annotations - only one allowed per class" );
+
+ // Get the BeforeClass methods from the superclasses (if any) - only look at annotations, though
+ Method[] superMethods = getBeforeClassMethod(test.getSuperclass(), true);
+
+ // Look for un-anotated method in this class if there has been no annotated methods in superclass
+ if (annotationOnly = false && (annotatedMethods == null || annotatedMethods.length == 0) && (superMethods == null || superMethods.length==0)) {
+ return _delegate.getBeforeClassMethod(test);
}
- return method;
+
+ // This classes method needs to be on the list after its superclasses
+ List<Method> methodsList = new ArrayList<Method>();
+ if (superMethods != null) methodsList.addAll(Arrays.asList(superMethods));
+ if (annotatedMethods != null && annotatedMethods.length > 0) methodsList.add(annotatedMethods[0]);
+
+ return methodsList.size() == 0 ? null : methodsList.toArray(new Method[0]);
}
@SuppressWarnings("unchecked")
- public Method getSetUpMethod(Class test) {
- Method method = AnnotationUtil.getMethodByAnnotation(test, _before);
- if (method == null) {
- method = _delegate.getSetUpMethod(test);
+ public Method[] getSetUpMethod(Class test) {
+ return getSetUpMethod(test, false);
+ }
+ @SuppressWarnings("unchecked")
+ private Method[] getSetUpMethod(Class test, boolean annotationOnly) {
+ if (test == null) return new Method[0];
+
+ Method[] annotatedMethods = AnnotationUtil.getMethodsByAnnotation(test, _before);
+
+ // Get the Before methods from the superclasses (if any)
+ Method[] superMethods = getSetUpMethod(test.getSuperclass(), true);
+
+ // Look for un-anotated method in this class if there has been no annotated methods in superclass
+ if (annotationOnly = false && (annotatedMethods == null || annotatedMethods.length == 0) && (superMethods == null || superMethods.length==0)) {
+ return _delegate.getSetUpMethod(test);
}
- return method;
+
+ // This classes method needs to be on the list after its superclasses
+ List<Method> methodsList = new ArrayList<Method>();
+ if (superMethods != null) methodsList.addAll(Arrays.asList(superMethods));
+ if (annotatedMethods != null) methodsList.addAll(Arrays.asList(annotatedMethods));
+
+ return methodsList.size() == 0 ? null : methodsList.toArray(new Method[0]);
}
@SuppressWarnings("unchecked")
- public Method getTearDownMethod(Class test) {
- Method method = AnnotationUtil.getMethodByAnnotation(test, _after);
- if (method == null) {
- method = _delegate.getTearDownMethod(test);
+ public Method[] getTearDownMethod(Class test) {
+ return getTearDownMethod(test, false);
+ }
+ @SuppressWarnings("unchecked")
+ private Method[] getTearDownMethod(Class test, boolean annotationOnly) {
+ if (test == null) return new Method[0];
+
+ Method[] annotatedMethods = AnnotationUtil.getMethodsByAnnotation(test, _after);
+
+ // Get the After methods from the superclasses (if any)
+ Method[] superMethods = getTearDownMethod(test.getSuperclass(), true);
+
+ // Look for un-anotated method in this class if there has been no annotated methods in superclass
+ if (annotationOnly = false && (annotatedMethods == null || annotatedMethods.length == 0) && (superMethods == null || superMethods.length==0)) {
+ return _delegate.getTearDownMethod(test);
}
- return method;
+
+ // This classes method needs to be on the list before its superclasses
+ List<Method> methodsList = new ArrayList<Method>();
+ if (annotatedMethods != null) methodsList.addAll(Arrays.asList(annotatedMethods));
+ if (superMethods != null) methodsList.addAll(Arrays.asList(superMethods));
+
+ return methodsList.size() == 0 ? null : methodsList.toArray(new Method[0]);
}
}
Modified: trunk/punit/src/org/punit/convention/ByNameConvention.java
===================================================================
--- trunk/punit/src/org/punit/convention/ByNameConvention.java 2008-05-22 12:47:41 UTC (rev 309)
+++ trunk/punit/src/org/punit/convention/ByNameConvention.java 2008-05-28 00:44:26 UTC (rev 310)
@@ -75,31 +75,33 @@
}
}
- public Method getAfterClassMethod(Class<?> test) {
+ public Method[] getAfterClassMethod(Class<?> test) {
Method method = ReflectionUtil.getMethodAndSetAccessibleWithAncestor(test,
"afterClass", new Class[] {}); //$NON-NLS-1$
if (method != null && ReflectionUtil.isStatic(method)) {
- return method;
+ return new Method[]{method};
}
return null;
}
- public Method getBeforeClassMethod(Class<?> test) {
+ public Method[] getBeforeClassMethod(Class<?> test) {
Method method = ReflectionUtil.getMethodAndSetAccessibleWithAncestor(test,
"beforeClass", new Class[] {}); //$NON-NLS-1$
if (method != null && ReflectionUtil.isStatic(method)) {
- return method;
+ return new Method[]{method};
}
return null;
}
- public Method getSetUpMethod(Class<?> test) {
- return ReflectionUtil.getMethodAndSetAccessibleWithAncestor(test,
+ public Method[] getSetUpMethod(Class<?> test) {
+ Method m = ReflectionUtil.getMethodAndSetAccessibleWithAncestor(test,
"setUp", new Class[] {}); //$NON-NLS-1$
+ return m == null ? null : new Method[]{m};
}
- public Method getTearDownMethod(Class<?> test) {
- return ReflectionUtil.getMethodAndSetAccessibleWithAncestor(test,
+ public Method[] getTearDownMethod(Class<?> test) {
+ Method m = ReflectionUtil.getMethodAndSetAccessibleWithAncestor(test,
"tearDown", new Class[] {}); //$NON-NLS-1$
+ return m == null ? null : new Method[]{m};
}
}
Modified: trunk/punit/src/org/punit/convention/Convention.java
===================================================================
--- trunk/punit/src/org/punit/convention/Convention.java 2008-05-22 12:47:41 UTC (rev 309)
+++ trunk/punit/src/org/punit/convention/Convention.java 2008-05-28 00:44:26 UTC (rev 310)
@@ -34,13 +34,13 @@
public int getConcurrentCount(Object testInstance, Method method);
- public Method getSetUpMethod(Class<?> test);
+ public Method[] getSetUpMethod(Class<?> test);
- public Method getTearDownMethod(Class<?> test);
+ public Method[] getTearDownMethod(Class<?> test);
- public Method getBeforeClassMethod(Class<?> test);
+ public Method[] getBeforeClassMethod(Class<?> test);
- public Method getAfterClassMethod(Class<?> test);
+ public Method[] getAfterClassMethod(Class<?> test);
public boolean isPUnitTest(Class<?> clazz);
Added: trunk/punit/src/org/punit/exception/AnnotationException.java
===================================================================
--- trunk/punit/src/org/punit/exception/AnnotationException.java (rev 0)
+++ trunk/punit/src/org/punit/exception/AnnotationException.java 2008-05-28 00:44:26 UTC (rev 310)
@@ -0,0 +1,10 @@
+package org.punit.exception;
+
+public class AnnotationException extends PUnitException {
+
+ private static final long serialVersionUID = 7258575188079634724L;
+
+ public AnnotationException(String message) {
+ super(message);
+ }
+}
Property changes on: trunk/punit/src/org/punit/exception/AnnotationException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/punit/src/org/punit/exception/PUnitException.java
===================================================================
--- trunk/punit/src/org/punit/exception/PUnitException.java 2008-05-22 12:47:41 UTC (rev 309)
+++ trunk/punit/src/org/punit/exception/PUnitException.java 2008-05-28 00:44:26 UTC (rev 310)
@@ -17,4 +17,8 @@
public PUnitException(String message, Throwable e) {
super(message, e);
}
+
+ public PUnitException(String message) {
+ super(message);
+ }
}
Modified: trunk/punit/src/org/punit/method/runner/AbstractMethodRunner.java
===================================================================
--- trunk/punit/src/org/punit/method/runner/AbstractMethodRunner.java 2008-05-22 12:47:41 UTC (rev 309)
+++ trunk/punit/src/org/punit/method/runner/AbstractMethodRunner.java 2008-05-28 00:44:26 UTC (rev 310)
@@ -38,9 +38,9 @@
protected transient Class<?> _class;
- protected transient Method _setUpMethod;
+ protected transient Method[] _setUpMethods;
- protected transient Method _tearDownMethod;
+ protected transient Method[] _tearDownMethods;
private transient Method _checkMethod;
@@ -137,8 +137,8 @@
_class = testInstance.getClass();
_params = params;
_method = method;
- _setUpMethod = _convention.getSetUpMethod(_class);
- _tearDownMethod = _convention.getTearDownMethod(_class);
+ _setUpMethods = _convention.getSetUpMethod(_class);
+ _tearDownMethods = _convention.getTearDownMethod(_class);
_checkMethod = _convention.getCheckMethod(method);
_expectedException = _convention.getExpectedException(method);
long toWork = _convention.toWork(_testInstance);
@@ -206,24 +206,28 @@
}
private void setUp() throws Throwable {
- if (_setUpMethod != null) {
- try {
- ReflectionUtil.invokeMethod(_setUpMethod, _testInstance,
- new Object[] {});
- } catch (ReflectionException e) {
- throw e.getCause();
- }
+ if (_setUpMethods != null) {
+ for (Method setUpMethod : _setUpMethods) {
+ try {
+ ReflectionUtil.invokeMethod(setUpMethod, _testInstance,
+ new Object[] {});
+ } catch (ReflectionException e) {
+ throw e.getCause();
+ }
+ }
}
}
private void tearDown() throws Throwable {
- if (_tearDownMethod != null) {
- try {
- ReflectionUtil.invokeMethod(_tearDownMethod, _testInstance,
- new Object[] {});
- } catch (ReflectionException e) {
- throw e.getCause();
- }
+ if (_tearDownMethods != null) {
+ for (Method tearDownMethod : _tearDownMethods) {
+ try {
+ ReflectionUtil.invokeMethod(tearDownMethod, _testInstance,
+ new Object[] {});
+ } catch (ReflectionException e) {
+ throw e.getCause();
+ }
+ }
}
}
Modified: trunk/punit/src/org/punit/runner/AbstractRunner.java
===================================================================
--- trunk/punit/src/org/punit/runner/AbstractRunner.java 2008-05-22 12:47:41 UTC (rev 309)
+++ trunk/punit/src/org/punit/runner/AbstractRunner.java 2008-05-28 00:44:26 UTC (rev 310)
@@ -291,18 +291,24 @@
}
private void beforeClass(Class<?> clazz) {
- Method beforeClassMethod = _convention.getBeforeClassMethod(clazz);
- if (beforeClassMethod != null) {
- ReflectionUtil.invokeMethod(beforeClassMethod, null,
- new Object[] {});
+ Method[] beforeClassMethods = _convention.getBeforeClassMethod(clazz);
+ if (beforeClassMethods == null) return;
+ for (Method beforeClassMethod : beforeClassMethods) {
+ if (beforeClassMethod != null) {
+ ReflectionUtil.invokeMethod(beforeClassMethod, null,
+ new Object[] {});
+ }
}
}
private void afterClass(Class<?> clazz) {
- Method afterClassMethod = _convention.getAfterClassMethod(clazz);
- if (afterClassMethod != null) {
- ReflectionUtil
- .invokeMethod(afterClassMethod, null, new Object[] {});
+ Method[] afterClassMethods = _convention.getAfterClassMethod(clazz);
+ if (afterClassMethods == null) return;
+ for (Method afterClassMethod : afterClassMethods) {
+ if (afterClassMethod != null) {
+ ReflectionUtil
+ .invokeMethod(afterClassMethod, null, new Object[] {});
+ }
}
}
Modified: trunk/punit/src/org/punit/util/AnnotationUtil.java
===================================================================
--- trunk/punit/src/org/punit/util/AnnotationUtil.java 2008-05-22 12:47:41 UTC (rev 309)
+++ trunk/punit/src/org/punit/util/AnnotationUtil.java 2008-05-28 00:44:26 UTC (rev 310)
@@ -4,20 +4,23 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
public class AnnotationUtil {
- public static <T extends Annotation> Method getMethodByAnnotation(
+ public static <T extends Annotation> Method[] getMethodsByAnnotation(
Class<?> clazz, Class<T> annotationClass) {
Method[] methods = clazz.getDeclaredMethods();
+ List<Method> annotationMethodsList = new ArrayList<Method>();
for (int i = 0; i < methods.length; ++i) {
Method method = methods[i];
Annotation annotation = method.getAnnotation(annotationClass);
if (annotation != null) {
method.setAccessible(true);
- return method;
+ annotationMethodsList.add(method);
}
}
- return null;
+ return annotationMethodsList.toArray(new Method[0]);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chris W. <ch...@cj...> - 2008-05-27 18:53:31
|
Hi, I've attached the patch. Hope its OK. I have added a couple of tests but it might be a good idea to lay out a couple more in depth tests or something. As I said, the code returns a Method[] for the relevant methods - this is perhaps a little clunky for the name based convention, but its probably the smallest change to do it this way. I have used recursive methods with a second, inner method to ensure that if mixing a name and annotation based test the annotation takes priority. Let me know if there's a problem with any of this. Cheers, Chris 2008/5/26 Andrew Zhang <zha...@gm...>: > Hi Chris, > > Thanks for the point! > > Would you please send me the patch via mail? I'd like to have a look at the > patch since it's the first time. If everything works well, you may check in > the code by yourself next time. Thanks for your work! > > On Wed, May 21, 2008 at 11:04 PM, Chris Wilson <ch...@cj...> wrote: >> >> Hi, >> >> I have just started using P-Unit for performance testing in a project >> and come across a couple of problems. One, which I reported on your >> bugs page, is that the extensions delivered on your website are not >> compiled with java 1.5, but 1.6 - as opposed to the main p-unit code. >> >> The second is that in Junit4 it is possible to nest @BeforeClass (etc) >> calls so super classes get their @BeforeClass methods called before >> the subclass. I have been using that feature in my JUnit tests and >> needed it in my P-Unit tests so I have implemented that and have a >> couple of questions. >> >> Firstly this obviously breaks being able to directly use the setup or >> @BeforeClass methods interchangably - its no-longer obvious what to >> do. I have currently implemented it to ignore the setup method >> altogether, but I guess the right solution is probably to ignore it if >> there are any contradictory annotations? >> >> Secondly I have altered the convention class to return Method[] for >> the four method classes - I think this is the right solution, but it >> makes the ByNameConvention a bit clunky, returning single element >> arrays and the like. >> >> Any thoughts on these? >> >> For more information of how JUnit 4 treats these cases see: >> http://www.devx.com/Java/Article/31983/0/page/3 >> >> I have, as I say, written this code. I just need to clean it up a bit >> and re-implement the setup bits and I can either mail it here for your >> opinions or check it in - either would be fine for me, just let me >> know. >> >> Cheers, >> >> Chris Wilson >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by: Microsoft >> Defy all challenges. Microsoft(R) Visual Studio 2008. >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >> _______________________________________________ >> P-unit-devel mailing list >> P-u...@li... >> https://lists.sourceforge.net/lists/listinfo/p-unit-devel > > > > -- > Best regards, > Andrew Zhang > > db4o - database for Android: www.db4o.com > http://zhanghuangzhu.blogspot.com/ |
|
From: Andrew Z. <zha...@gm...> - 2008-05-26 00:52:42
|
Hi Chris, Thanks for the point! Would you please send me the patch via mail? I'd like to have a look at the patch since it's the first time. If everything works well, you may check in the code by yourself next time. Thanks for your work! On Wed, May 21, 2008 at 11:04 PM, Chris Wilson <ch...@cj...> wrote: > Hi, > > I have just started using P-Unit for performance testing in a project > and come across a couple of problems. One, which I reported on your > bugs page, is that the extensions delivered on your website are not > compiled with java 1.5, but 1.6 - as opposed to the main p-unit code. > > The second is that in Junit4 it is possible to nest @BeforeClass (etc) > calls so super classes get their @BeforeClass methods called before > the subclass. I have been using that feature in my JUnit tests and > needed it in my P-Unit tests so I have implemented that and have a > couple of questions. > > Firstly this obviously breaks being able to directly use the setup or > @BeforeClass methods interchangably - its no-longer obvious what to > do. I have currently implemented it to ignore the setup method > altogether, but I guess the right solution is probably to ignore it if > there are any contradictory annotations? > > Secondly I have altered the convention class to return Method[] for > the four method classes - I think this is the right solution, but it > makes the ByNameConvention a bit clunky, returning single element > arrays and the like. > > Any thoughts on these? > > For more information of how JUnit 4 treats these cases see: > http://www.devx.com/Java/Article/31983/0/page/3 > > I have, as I say, written this code. I just need to clean it up a bit > and re-implement the setup bits and I can either mail it here for your > opinions or check it in - either would be fine for me, just let me > know. > > Cheers, > > Chris Wilson > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > P-unit-devel mailing list > P-u...@li... > https://lists.sourceforge.net/lists/listinfo/p-unit-devel > -- Best regards, Andrew Zhang db4o - database for Android: www.db4o.com http://zhanghuangzhu.blogspot.com/ |
|
From: <zha...@us...> - 2008-05-22 12:47:33
|
Revision: 309
http://p-unit.svn.sourceforge.net/p-unit/?rev=309&view=rev
Author: zhanghuangzhu
Date: 2008-05-22 05:47:41 -0700 (Thu, 22 May 2008)
Log Message:
-----------
Andrew Zhang: use java 5.0.
Added Paths:
-----------
trunk/punit.extension/.settings/
trunk/punit.extension/.settings/org.eclipse.jdt.core.prefs
Added: trunk/punit.extension/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/punit.extension/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/punit.extension/.settings/org.eclipse.jdt.core.prefs 2008-05-22 12:47:41 UTC (rev 309)
@@ -0,0 +1,12 @@
+#Thu May 22 20:46:37 CST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Property changes on: trunk/punit.extension/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Name: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Chris W. <ch...@cj...> - 2008-05-21 15:04:06
|
Hi, I have just started using P-Unit for performance testing in a project and come across a couple of problems. One, which I reported on your bugs page, is that the extensions delivered on your website are not compiled with java 1.5, but 1.6 - as opposed to the main p-unit code. The second is that in Junit4 it is possible to nest @BeforeClass (etc) calls so super classes get their @BeforeClass methods called before the subclass. I have been using that feature in my JUnit tests and needed it in my P-Unit tests so I have implemented that and have a couple of questions. Firstly this obviously breaks being able to directly use the setup or @BeforeClass methods interchangably - its no-longer obvious what to do. I have currently implemented it to ignore the setup method altogether, but I guess the right solution is probably to ignore it if there are any contradictory annotations? Secondly I have altered the convention class to return Method[] for the four method classes - I think this is the right solution, but it makes the ByNameConvention a bit clunky, returning single element arrays and the like. Any thoughts on these? For more information of how JUnit 4 treats these cases see: http://www.devx.com/Java/Article/31983/0/page/3 I have, as I say, written this code. I just need to clean it up a bit and re-implement the setup bits and I can either mail it here for your opinions or check it in - either would be fine for me, just let me know. Cheers, Chris Wilson |
|
From: <zha...@us...> - 2008-05-02 15:43:55
|
Revision: 308
http://p-unit.svn.sourceforge.net/p-unit/?rev=308&view=rev
Author: zhanghuangzhu
Date: 2008-05-02 08:25:20 -0700 (Fri, 02 May 2008)
Log Message:
-----------
Andrew Zhang: added Assert.assertEquals for Iterator & Iterable.
Modified Paths:
--------------
trunk/punit/src/org/punit/assertion/Assert.java
Modified: trunk/punit/src/org/punit/assertion/Assert.java
===================================================================
--- trunk/punit/src/org/punit/assertion/Assert.java 2008-04-23 01:39:59 UTC (rev 307)
+++ trunk/punit/src/org/punit/assertion/Assert.java 2008-05-02 15:25:20 UTC (rev 308)
@@ -2,6 +2,8 @@
package org.punit.assertion;
+import java.util.*;
+
import org.punit.message.Messages;
public class Assert {
@@ -52,6 +54,18 @@
}
}
+ public static void assertEquals(Iterable<?> iter1, Iterable<?>iter2) {
+ assertEquals(iter1.iterator(), iter2.iterator());
+ }
+
+ public static void assertEquals(Iterator<?> iter1, Iterator<?>iter2) {
+ while(iter1.hasNext() && iter2.hasNext()) {
+ assertEquals(iter1.next(), iter2.next());
+ }
+ assertFalse(iter1.hasNext());
+ assertFalse(iter2.hasNext());
+ }
+
public static void assertTrue(boolean flag) {
if(!flag) {
fail(Boolean.TRUE, Boolean.FALSE);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-23 01:39:53
|
Revision: 307
http://p-unit.svn.sourceforge.net/p-unit/?rev=307&view=rev
Author: zhanghuangzhu
Date: 2008-04-22 18:39:59 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
az: added export.jardesc into svn:ignore
Property Changed:
----------------
trunk/punit.android/
Property changes on: trunk/punit.android
___________________________________________________________________
Name: svn:ignore
+ export.jardesc
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-23 01:25:13
|
Revision: 306
http://p-unit.svn.sourceforge.net/p-unit/?rev=306&view=rev
Author: zhanghuangzhu
Date: 2008-04-22 18:25:16 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
az: move tearDown to tearDownAfterWatchers.
Modified Paths:
--------------
trunk/punit/src/org/punit/method/runner/AbstractMethodRunner.java
Modified: trunk/punit/src/org/punit/method/runner/AbstractMethodRunner.java
===================================================================
--- trunk/punit/src/org/punit/method/runner/AbstractMethodRunner.java 2008-04-23 01:21:10 UTC (rev 305)
+++ trunk/punit/src/org/punit/method/runner/AbstractMethodRunner.java 2008-04-23 01:25:16 UTC (rev 306)
@@ -191,8 +191,6 @@
} else if (_convention.isParameterizedTest(_class)) {
((Parameterized) _testInstance)
.tearDownBeforeWatchers((Parameter) params[0]);
- } else {
- tearDown();
}
}
@@ -202,6 +200,8 @@
} else if (_convention.isParameterizedTest(_class)) {
((Parameterized) _testInstance)
.tearDownAfterWatchers((Parameter) params[0]);
+ } else {
+ tearDown();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-23 01:21:06
|
Revision: 305
http://p-unit.svn.sourceforge.net/p-unit/?rev=305&view=rev
Author: zhanghuangzhu
Date: 2008-04-22 18:21:10 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
Andrew Zhang: move setUp to setUpBeforeWatchers.
Modified Paths:
--------------
trunk/punit/src/org/punit/method/runner/AbstractMethodRunner.java
Modified: trunk/punit/src/org/punit/method/runner/AbstractMethodRunner.java
===================================================================
--- trunk/punit/src/org/punit/method/runner/AbstractMethodRunner.java 2008-04-22 16:03:32 UTC (rev 304)
+++ trunk/punit/src/org/punit/method/runner/AbstractMethodRunner.java 2008-04-23 01:21:10 UTC (rev 305)
@@ -171,6 +171,8 @@
} else if (_convention.isParameterizedTest(_class)) {
((Parameterized) _testInstance)
.setUpBeforeWatchers((Parameter) params[0]);
+ } else {
+ setUp();
}
}
@@ -180,9 +182,7 @@
} else if (_convention.isParameterizedTest(_class)) {
((Parameterized) _testInstance)
.setUpAfterWatchers((Parameter) params[0]);
- } else {
- setUp();
- }
+ }
}
private void tearDownBeforeWatchers(Object[] params) throws Throwable {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-22 16:03:34
|
Revision: 304
http://p-unit.svn.sourceforge.net/p-unit/?rev=304&view=rev
Author: zhanghuangzhu
Date: 2008-04-22 09:03:32 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
Andrew Zhang: added addWatcher in Runner.
Modified Paths:
--------------
trunk/punit/src/org/punit/runner/AbstractRunner.java
trunk/punit/src/org/punit/runner/Runner.java
trunk/punit/src/org/punit/runner/VanillaRunner.java
Modified: trunk/punit/src/org/punit/runner/AbstractRunner.java
===================================================================
--- trunk/punit/src/org/punit/runner/AbstractRunner.java 2008-04-18 06:51:22 UTC (rev 303)
+++ trunk/punit/src/org/punit/runner/AbstractRunner.java 2008-04-22 16:03:32 UTC (rev 304)
@@ -18,6 +18,7 @@
import org.punit.reporter.stream.console.*;
import org.punit.type.*;
import org.punit.util.*;
+import org.punit.watcher.*;
public abstract class AbstractRunner implements Runner {
@@ -156,6 +157,10 @@
filterNonParentEventListeners();
run(clazz);
}
+
+ public void addWatcher(Watcher watcher) {
+ _methodRunner.addWatcher(watcher);
+ }
private void readOutputStream(Process p) {
new StreamReaderThread(p.getInputStream(), false).start();
Modified: trunk/punit/src/org/punit/runner/Runner.java
===================================================================
--- trunk/punit/src/org/punit/runner/Runner.java 2008-04-18 06:51:22 UTC (rev 303)
+++ trunk/punit/src/org/punit/runner/Runner.java 2008-04-22 16:03:32 UTC (rev 304)
@@ -9,6 +9,7 @@
import org.punit.method.runner.*;
import org.punit.reporter.*;
import org.punit.type.*;
+import org.punit.watcher.*;
public interface Runner extends EventRegistry, Name, Serializable, Cloneable {
@@ -29,4 +30,6 @@
public String resultFolder();
public void shutdown();
+
+ public void addWatcher(Watcher watcher);
}
Modified: trunk/punit/src/org/punit/runner/VanillaRunner.java
===================================================================
--- trunk/punit/src/org/punit/runner/VanillaRunner.java 2008-04-18 06:51:22 UTC (rev 303)
+++ trunk/punit/src/org/punit/runner/VanillaRunner.java 2008-04-22 16:03:32 UTC (rev 304)
@@ -7,6 +7,7 @@
import org.punit.method.builder.*;
import org.punit.method.runner.*;
import org.punit.reporter.*;
+import org.punit.watcher.*;
public class VanillaRunner implements Runner {
@@ -69,4 +70,8 @@
public void shutdown() {
_runner.shutdown();
}
+
+ public void addWatcher(Watcher watcher) {
+ _runner.addWatcher(watcher);
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-18 06:51:16
|
Revision: 303
http://p-unit.svn.sourceforge.net/p-unit/?rev=303&view=rev
Author: zhanghuangzhu
Date: 2008-04-17 23:51:22 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
Andrew Zhang: typo, SEPERATOR -> SEPARATOR.
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/exception/ConcurrentExceptionTest.java
Modified: trunk/punit.test/src/tests/api/org/punit/exception/ConcurrentExceptionTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/exception/ConcurrentExceptionTest.java 2008-04-18 06:51:14 UTC (rev 302)
+++ trunk/punit.test/src/tests/api/org/punit/exception/ConcurrentExceptionTest.java 2008-04-18 06:51:22 UTC (rev 303)
@@ -13,6 +13,6 @@
IllegalArgumentException iae = new IllegalArgumentException("IAE"); //$NON-NLS-1$
concurrentException.add(iae);
String message = concurrentException.getMessage();
- assertEquals(npe + ReporterUtil.LINE_SEPERATOR + iae + ReporterUtil.LINE_SEPERATOR, message);
+ assertEquals(npe + ReporterUtil.LINE_SEPARATOR + iae + ReporterUtil.LINE_SEPARATOR, message);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-18 06:51:09
|
Revision: 302
http://p-unit.svn.sourceforge.net/p-unit/?rev=302&view=rev
Author: zhanghuangzhu
Date: 2008-04-17 23:51:14 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
Andrew Zhang: typo, SEPERATOR -> SEPARATOR.
Modified Paths:
--------------
trunk/punit/src/org/punit/exception/ConcurrentException.java
trunk/punit/src/org/punit/reporter/stream/StreamLogger.java
trunk/punit/src/org/punit/util/ReporterUtil.java
Modified: trunk/punit/src/org/punit/exception/ConcurrentException.java
===================================================================
--- trunk/punit/src/org/punit/exception/ConcurrentException.java 2008-04-18 06:37:58 UTC (rev 301)
+++ trunk/punit/src/org/punit/exception/ConcurrentException.java 2008-04-18 06:51:14 UTC (rev 302)
@@ -55,7 +55,7 @@
Iterator<Throwable> iter = _throwables.iterator();
while(iter.hasNext()) {
sb.append(iter.next());
- sb.append(ReporterUtil.LINE_SEPERATOR);
+ sb.append(ReporterUtil.LINE_SEPARATOR);
}
return sb.toString();
}
Modified: trunk/punit/src/org/punit/reporter/stream/StreamLogger.java
===================================================================
--- trunk/punit/src/org/punit/reporter/stream/StreamLogger.java 2008-04-18 06:37:58 UTC (rev 301)
+++ trunk/punit/src/org/punit/reporter/stream/StreamLogger.java 2008-04-18 06:51:14 UTC (rev 302)
@@ -41,7 +41,7 @@
sb.append(Messages.getString("logger.01")); //$NON-NLS-1$
sb.append(" "); //$NON-NLS-1$
sb.append(clazz.getName());
- sb.append(ReporterUtil.LINE_SEPERATOR);
+ sb.append(ReporterUtil.LINE_SEPARATOR);
log(sb.toString(), Level.INFO);
}
@@ -83,7 +83,7 @@
}
sb.append(") - "); //$NON-NLS-1$
sb.append(_timeWatcher.stringValue());
- sb.append(ReporterUtil.LINE_SEPERATOR);
+ sb.append(ReporterUtil.LINE_SEPARATOR);
log(sb.toString(), Level.SEVERE);
}
@@ -107,7 +107,7 @@
StringBuffer sb = new StringBuffer();
sb.append(Messages.getString("logger.06")); //$NON-NLS-1$
sb.append(suite.getClass().getName());
- sb.append(ReporterUtil.LINE_SEPERATOR);
+ sb.append(ReporterUtil.LINE_SEPARATOR);
log(sb.toString(), Level.INFO);
}
@@ -140,10 +140,10 @@
sb.append("]"); //$NON-NLS-1$
}
- sb.append(ReporterUtil.LINE_SEPERATOR);
+ sb.append(ReporterUtil.LINE_SEPARATOR);
if(t != null) {
sb.append(t.toString());
- sb.append(ReporterUtil.LINE_SEPERATOR);
+ sb.append(ReporterUtil.LINE_SEPARATOR);
}
return sb.toString();
}
@@ -158,11 +158,11 @@
}
public void logln(Level level) {
- log(ReporterUtil.LINE_SEPERATOR, level);
+ log(ReporterUtil.LINE_SEPARATOR, level);
}
public void logln(String message, Level level) {
- log(message + ReporterUtil.LINE_SEPERATOR, level);
+ log(message + ReporterUtil.LINE_SEPARATOR, level);
}
public void log(String message, Level level) {
Modified: trunk/punit/src/org/punit/util/ReporterUtil.java
===================================================================
--- trunk/punit/src/org/punit/util/ReporterUtil.java 2008-04-18 06:37:58 UTC (rev 301)
+++ trunk/punit/src/org/punit/util/ReporterUtil.java 2008-04-18 06:51:14 UTC (rev 302)
@@ -10,14 +10,10 @@
public class ReporterUtil {
- public final static String LINE_SEPERATOR;
+ public final static String LINE_SEPARATOR = System.getProperty("line.separator", "\n"); //$NON-NLS-1$;
private static boolean _isResultFolderCreated;
- static {
- LINE_SEPERATOR = System.getProperty("line.separator"); //$NON-NLS-1$
- }
-
public static String simpleMethodName(Method method) {
Class<?>[] params = method.getParameterTypes();
String[] paramsNames = new String[params.length];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-18 06:37:51
|
Revision: 301
http://p-unit.svn.sourceforge.net/p-unit/?rev=301&view=rev
Author: zhanghuangzhu
Date: 2008-04-17 23:37:58 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
az: make buildMethodResultString protect
Modified Paths:
--------------
trunk/punit/src/org/punit/reporter/stream/StreamLogger.java
Modified: trunk/punit/src/org/punit/reporter/stream/StreamLogger.java
===================================================================
--- trunk/punit/src/org/punit/reporter/stream/StreamLogger.java 2008-04-18 01:20:12 UTC (rev 300)
+++ trunk/punit/src/org/punit/reporter/stream/StreamLogger.java 2008-04-18 06:37:58 UTC (rev 301)
@@ -117,11 +117,14 @@
public void onMethodEnd(Method method, Object instance, Object[] params,
Throwable t, List<Watcher> watchers) {
- logTestMethodResult(method, params, watchers, t);
+ String methodResult = buildMethodResultString(method, params,
+ watchers, t);
+ log(methodResult, Level.INFO);
}
- private void logTestMethodResult(Method method, Object[] params, List<Watcher> watchers, Throwable t) {
- final StringBuffer sb = new StringBuffer();
+ protected String buildMethodResultString(Method method,
+ Object[] params, List<Watcher> watchers, Throwable t) {
+ final StringBuffer sb = new StringBuffer();
String simpleMethodName = ReporterUtil.simpleMethodName(method, params);
sb.append(simpleMethodName);
if (watchers.size() > 0) {
@@ -142,8 +145,8 @@
sb.append(t.toString());
sb.append(ReporterUtil.LINE_SEPERATOR);
}
- log(sb.toString(), Level.INFO);
- }
+ return sb.toString();
+ }
public void setWriter(PrintWriter writer) {
_writer = writer;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-18 01:20:23
|
Revision: 300
http://p-unit.svn.sourceforge.net/p-unit/?rev=300&view=rev
Author: zhanghuangzhu
Date: 2008-04-17 18:20:12 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
az: added method info in failure
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
Added Paths:
-----------
trunk/punit.test/src/tests/api/org/punit/reporter/TestResultTest.java
Modified: trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2008-04-18 01:19:53 UTC (rev 299)
+++ trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2008-04-18 01:20:12 UTC (rev 300)
@@ -6,6 +6,7 @@
import tests.api.org.punit.exception.*;
import tests.api.org.punit.method.builder.*;
import tests.api.org.punit.method.runner.*;
+import tests.api.org.punit.reporter.*;
import tests.api.org.punit.reporter.stream.*;
import tests.api.org.punit.runner.*;
import tests.api.org.punit.util.*;
@@ -42,6 +43,7 @@
SoloRunnerTest.class,
StreamLoggerTest.class,
TestMethodBuilderTest.class,
+ TestResultTest.class,
TimeWatcherTest.class
};
}
Added: trunk/punit.test/src/tests/api/org/punit/reporter/TestResultTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/reporter/TestResultTest.java (rev 0)
+++ trunk/punit.test/src/tests/api/org/punit/reporter/TestResultTest.java 2008-04-18 01:20:12 UTC (rev 300)
@@ -0,0 +1,22 @@
+package tests.api.org.punit.reporter;
+
+import java.lang.reflect.*;
+
+import junit.framework.*;
+
+import org.punit.reporter.*;
+
+public class TestResultTest extends TestCase {
+
+ private org.punit.reporter.TestResult _testResult = new org.punit.reporter.TestResult();
+
+ public void testOnMethodEnd() throws Exception {
+ Method method = getClass().getDeclaredMethod("testOnMethodEnd", new Class [] {});
+ RuntimeException e = new RuntimeException();
+ _testResult.onMethodEnd(method, this, null, e , null);
+ assertEquals(1, _testResult.failures().size());
+ Failure failure = _testResult.failures().get(0);
+ assertSame(e, failure.throwable);
+ assertSame(method, failure.method);
+ }
+}
Property changes on: trunk/punit.test/src/tests/api/org/punit/reporter/TestResultTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-18 01:19:53
|
Revision: 299
http://p-unit.svn.sourceforge.net/p-unit/?rev=299&view=rev
Author: zhanghuangzhu
Date: 2008-04-17 18:19:53 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
az: added method info in failure
Modified Paths:
--------------
trunk/punit/src/org/punit/reporter/TestResult.java
trunk/punit/src/org/punit/reporter/stream/StreamLogger.java
Added Paths:
-----------
trunk/punit/src/org/punit/reporter/Failure.java
Added: trunk/punit/src/org/punit/reporter/Failure.java
===================================================================
--- trunk/punit/src/org/punit/reporter/Failure.java (rev 0)
+++ trunk/punit/src/org/punit/reporter/Failure.java 2008-04-18 01:19:53 UTC (rev 299)
@@ -0,0 +1,12 @@
+package org.punit.reporter;
+
+import java.lang.reflect.*;
+
+public class Failure {
+ public final Throwable throwable;
+ public final Method method;
+ public Failure(Method m, Throwable t) {
+ method = m;
+ throwable = t;
+ }
+}
Property changes on: trunk/punit/src/org/punit/reporter/Failure.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/punit/src/org/punit/reporter/TestResult.java
===================================================================
--- trunk/punit/src/org/punit/reporter/TestResult.java 2008-04-18 00:55:11 UTC (rev 298)
+++ trunk/punit/src/org/punit/reporter/TestResult.java 2008-04-18 01:19:53 UTC (rev 299)
@@ -13,13 +13,13 @@
private transient int _methodCount;
- private List<Throwable> _failures = new ArrayList<Throwable>();
+ private List<Failure> _failures = new LinkedList<Failure>();
public void onMethodEnd(Method method, Object testInstance,
Object[] params, Throwable t, List<Watcher> Watchers) {
countMethod();
if (t != null) {
- addThrowable(t);
+ addFailure(new Failure(method, t));
}
}
@@ -27,15 +27,15 @@
++_methodCount;
}
- public synchronized void addThrowable(Throwable t) {
- _failures.add(t);
+ public synchronized void addFailure(Failure failure) {
+ _failures.add(failure);
}
public int methodCount() {
return _methodCount;
}
- public List<Throwable> failures() {
+ public List<Failure> failures() {
return _failures;
}
Modified: trunk/punit/src/org/punit/reporter/stream/StreamLogger.java
===================================================================
--- trunk/punit/src/org/punit/reporter/stream/StreamLogger.java 2008-04-18 00:55:11 UTC (rev 298)
+++ trunk/punit/src/org/punit/reporter/stream/StreamLogger.java 2008-04-18 01:19:53 UTC (rev 299)
@@ -72,7 +72,7 @@
sb.append(result.methodCount());
sb.append(", "); //$NON-NLS-1$
sb.append(Messages.getString("logger.failures")); //$NON-NLS-1$
- List<Throwable> failures = result.failures();
+ List<Failure> failures = result.failures();
int failuresCount = failures.size();
sb.append(failuresCount);
sb.append(" ("); //$NON-NLS-1$
@@ -88,13 +88,12 @@
}
private void logFailures(TestResult result) {
- List<Throwable> failures = result.failures();
- Iterator<Throwable> iter = failures.iterator();
+ List<Failure> failures = result.failures();
int count = 0;
- while (iter.hasNext()) {
+ for(Failure failure : failures) {
log(++count + ")", Level.SEVERE); //$NON-NLS-1$
if (shouldLog(Level.SEVERE)) {
- iter.next().printStackTrace(_writer);
+ failure.throwable.printStackTrace(_writer);
}
}
_writer.flush();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-18 00:55:04
|
Revision: 298
http://p-unit.svn.sourceforge.net/p-unit/?rev=298&view=rev
Author: zhanghuangzhu
Date: 2008-04-17 17:55:11 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
az: simplify test suite builder logic.
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
Modified: trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2008-04-18 00:54:09 UTC (rev 297)
+++ trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2008-04-18 00:55:11 UTC (rev 298)
@@ -8,7 +8,6 @@
import tests.api.org.punit.method.runner.*;
import tests.api.org.punit.reporter.stream.*;
import tests.api.org.punit.runner.*;
-import tests.api.org.punit.suite.builder.*;
import tests.api.org.punit.util.*;
import tests.api.org.punit.watcher.*;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-18 00:54:02
|
Revision: 297
http://p-unit.svn.sourceforge.net/p-unit/?rev=297&view=rev
Author: zhanghuangzhu
Date: 2008-04-17 17:54:09 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
az: simplify test suite builder logic.
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
trunk/punit.test/src/tests/api/org/punit/runner/AbstractRunnerTest.java
Removed Paths:
-------------
trunk/punit.test/src/tests/api/org/punit/suite/builder/
Modified: trunk/punit.test/src/tests/api/org/punit/all/AllTests.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2008-04-18 00:53:53 UTC (rev 296)
+++ trunk/punit.test/src/tests/api/org/punit/all/AllTests.java 2008-04-18 00:54:09 UTC (rev 297)
@@ -43,7 +43,6 @@
SoloRunnerTest.class,
StreamLoggerTest.class,
TestMethodBuilderTest.class,
- TestSuiteBuilderTest.class,
TimeWatcherTest.class
};
}
Modified: trunk/punit.test/src/tests/api/org/punit/runner/AbstractRunnerTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/runner/AbstractRunnerTest.java 2008-04-18 00:53:53 UTC (rev 296)
+++ trunk/punit.test/src/tests/api/org/punit/runner/AbstractRunnerTest.java 2008-04-18 00:54:09 UTC (rev 297)
@@ -2,12 +2,11 @@
package tests.api.org.punit.runner;
-import junit.framework.TestCase;
+import junit.framework.*;
-import org.punit.method.builder.MethodBuilderImpl;
-import org.punit.method.runner.SoloMethodRunner;
-import org.punit.runner.AbstractRunner;
-import org.punit.suite.builder.TestSuiteBuilderImpl;
+import org.punit.method.builder.*;
+import org.punit.method.runner.*;
+import org.punit.runner.*;
public class AbstractRunnerTest extends TestCase {
@@ -33,8 +32,7 @@
private static final long serialVersionUID = 1L;
public MockAbstractRunner() {
- super(new TestSuiteBuilderImpl(), new MethodBuilderImpl(),
- new SoloMethodRunner());
+ super(new MethodBuilderImpl(), new SoloMethodRunner());
}
public String punitName() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-18 00:53:46
|
Revision: 296
http://p-unit.svn.sourceforge.net/p-unit/?rev=296&view=rev
Author: zhanghuangzhu
Date: 2008-04-17 17:53:53 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
az: simplify test suite builder logic.
Modified Paths:
--------------
trunk/punit/src/org/punit/runner/AbstractRunner.java
trunk/punit/src/org/punit/runner/ConcurrentRunner.java
trunk/punit/src/org/punit/runner/Runner.java
trunk/punit/src/org/punit/runner/SoloRunner.java
trunk/punit/src/org/punit/runner/VanillaRunner.java
Removed Paths:
-------------
trunk/punit/src/org/punit/suite/builder/
Modified: trunk/punit/src/org/punit/runner/AbstractRunner.java
===================================================================
--- trunk/punit/src/org/punit/runner/AbstractRunner.java 2008-04-17 02:18:56 UTC (rev 295)
+++ trunk/punit/src/org/punit/runner/AbstractRunner.java 2008-04-18 00:53:53 UTC (rev 296)
@@ -16,14 +16,11 @@
import org.punit.method.runner.*;
import org.punit.reporter.*;
import org.punit.reporter.stream.console.*;
-import org.punit.suite.builder.*;
import org.punit.type.*;
import org.punit.util.*;
public abstract class AbstractRunner implements Runner {
- private TestSuiteBuilder _testSuiteBuiler;
-
private TestMethodBuilder _testMethodBuilder;
private MethodRunner _methodRunner;
@@ -46,9 +43,7 @@
private AtomicBoolean _isAlive = new AtomicBoolean(true);
- public AbstractRunner(TestSuiteBuilder testSuiteBuiler,
- TestMethodBuilder testMethodBuilder, MethodRunner testMethodRunner) {
- _testSuiteBuiler = testSuiteBuiler;
+ public AbstractRunner(TestMethodBuilder testMethodBuilder, MethodRunner testMethodRunner) {
_testMethodBuilder = testMethodBuilder;
_methodRunner = testMethodRunner;
_methodRunner.setRunner(this);
@@ -59,37 +54,65 @@
public void setConvention(Convention convention) {
_convention = convention;
- _testSuiteBuiler.setConvention(convention);
_testMethodBuilder.setConvention(convention);
_methodRunner.setConvention(convention);
}
public int run(Class<?> clazz) {
onRunnerStart(clazz);
- Object[] testClasses = _testSuiteBuiler.buildTestClasses(clazz);
- runTestClasses(testClasses);
+ startExecutorPool();
+ runTest(clazz);
+ waitExecutorPoolTermination();
onRunnerEnd(clazz);
return _testResult.failures().size();
}
+
+ @SuppressWarnings("unchecked")
+ private void runTest(Class<?> clazz) {
+ if(isTestSuite(clazz)) {
+ runTestSuite((Class<? extends TestSuite>) clazz);
+ } else {
+ runTestClass(clazz);
+ }
+ }
+
+ private boolean isTestSuite(Class<?> clazz) {
+ return TestSuite.class.isAssignableFrom(clazz);
+ }
+
+ private void runTestSuite(Class <? extends TestSuite> testSuiteClass) {
+ if(_convention.isExcluded(testSuiteClass)) {
+ return;
+ }
+ final TestSuite suite = (TestSuite) ReflectionUtil.newInstance(testSuiteClass);
+ onSuiteStart(suite);
+ for(Class<?> clazz : suite.testSuite()) {
+ runTest(clazz);
+ }
+ onSuiteEnd(suite);
+ }
+ private void onSuiteStart(final TestSuite suite) {
+ notifyListeners(new Notifier() {
+ public void run(EventListener listener) {
+ listener.onSuiteStart(suite);
+ }
+ });
+ }
+
+ private void onSuiteEnd(final TestSuite suite) {
+ notifyListeners(new Notifier() {
+ public void run(EventListener listener) {
+ listener.onSuiteEnd(suite);
+ }
+ });
+ }
+
public int run(Class<?> clazz, RunnerProperties properties) {
setRunnerProperties(properties);
return run(clazz);
}
- private void runTestClasses(Object[] testClasses) {
- startExecutorPool();
- for (int i = 0; i < testClasses.length && isAlive(); ++i) {
- Object testClass = testClasses[i];
- if (isTestSuiteLabel(testClass)) {
- onSuite(((TestSuiteLabel) testClass));
- } else {
- runTestClass((Class<?>) testClass);
- }
- }
- waitExecutorPoolTermination();
- }
-
public void setExecutorPool(ExecutorPool pool) {
_executorPool = pool;
}
@@ -294,19 +317,6 @@
});
}
- private void onSuite(final TestSuiteLabel suiteLabel) {
- notifyListeners(new Notifier() {
- public void run(EventListener listener) {
- TestSuite suite = suiteLabel.suite();
- if (suiteLabel.isStart()) {
- listener.onSuiteStart(suite);
- } else {
- listener.onSuiteEnd(suite);
- }
- }
- });
- }
-
private void onClassStart(final Object testInstance) {
notifyListeners(new Notifier() {
public void run(EventListener listener) {
@@ -365,10 +375,6 @@
return _methodRunner;
}
- public TestSuiteBuilder suiteBuilder() {
- return _testSuiteBuiler;
- }
-
private void registerDefaultListeners() {
addInternalEventListener(_testResult);
addEventListener(_consoleLogger);
@@ -398,10 +404,6 @@
return _consoleLogger;
}
- private boolean isTestSuiteLabel(Object testClass) {
- return testClass instanceof TestSuiteLabel;
- }
-
public Object clone() {
try {
AbstractRunner runner = (AbstractRunner) super.clone();
Modified: trunk/punit/src/org/punit/runner/ConcurrentRunner.java
===================================================================
--- trunk/punit/src/org/punit/runner/ConcurrentRunner.java 2008-04-17 02:18:56 UTC (rev 295)
+++ trunk/punit/src/org/punit/runner/ConcurrentRunner.java 2008-04-18 00:53:53 UTC (rev 296)
@@ -1,11 +1,10 @@
/* (C) Copyright 2007, by Andrew Zhang */
package org.punit.runner;
-import org.punit.message.Messages;
-import org.punit.method.builder.MethodBuilderImpl;
-import org.punit.method.runner.ConcurrentMethodRunner;
-import org.punit.suite.builder.TestSuiteBuilderImpl;
-import org.punit.util.RunnerUtil;
+import org.punit.message.*;
+import org.punit.method.builder.*;
+import org.punit.method.runner.*;
+import org.punit.util.*;
public class ConcurrentRunner extends AbstractRunner {
@@ -22,7 +21,7 @@
}
public ConcurrentRunner(int concurrentCount) {
- super(new TestSuiteBuilderImpl(), new MethodBuilderImpl(), new ConcurrentMethodRunner(concurrentCount));
+ super(new MethodBuilderImpl(), new ConcurrentMethodRunner(concurrentCount));
}
public String punitName() {
Modified: trunk/punit/src/org/punit/runner/Runner.java
===================================================================
--- trunk/punit/src/org/punit/runner/Runner.java 2008-04-17 02:18:56 UTC (rev 295)
+++ trunk/punit/src/org/punit/runner/Runner.java 2008-04-18 00:53:53 UTC (rev 296)
@@ -2,14 +2,13 @@
package org.punit.runner;
-import java.io.Serializable;
+import java.io.*;
-import org.punit.events.EventRegistry;
-import org.punit.method.builder.TestMethodBuilder;
-import org.punit.method.runner.MethodRunner;
-import org.punit.reporter.TestResult;
-import org.punit.suite.builder.TestSuiteBuilder;
-import org.punit.type.Name;
+import org.punit.events.*;
+import org.punit.method.builder.*;
+import org.punit.method.runner.*;
+import org.punit.reporter.*;
+import org.punit.type.*;
public interface Runner extends EventRegistry, Name, Serializable, Cloneable {
@@ -23,8 +22,6 @@
public MethodRunner methodRunner();
- public TestSuiteBuilder suiteBuilder();
-
public TestResult testResult();
public void resultFolder(String folder);
Modified: trunk/punit/src/org/punit/runner/SoloRunner.java
===================================================================
--- trunk/punit/src/org/punit/runner/SoloRunner.java 2008-04-17 02:18:56 UTC (rev 295)
+++ trunk/punit/src/org/punit/runner/SoloRunner.java 2008-04-18 00:53:53 UTC (rev 296)
@@ -5,7 +5,6 @@
import org.punit.message.*;
import org.punit.method.builder.*;
import org.punit.method.runner.*;
-import org.punit.suite.builder.*;
import org.punit.util.*;
public class SoloRunner extends AbstractRunner {
@@ -17,8 +16,7 @@
}
public SoloRunner() {
- super(new TestSuiteBuilderImpl(), new MethodBuilderImpl(),
- new SoloMethodRunner());
+ super(new MethodBuilderImpl(), new SoloMethodRunner());
}
public String punitName() {
Modified: trunk/punit/src/org/punit/runner/VanillaRunner.java
===================================================================
--- trunk/punit/src/org/punit/runner/VanillaRunner.java 2008-04-17 02:18:56 UTC (rev 295)
+++ trunk/punit/src/org/punit/runner/VanillaRunner.java 2008-04-18 00:53:53 UTC (rev 296)
@@ -7,7 +7,6 @@
import org.punit.method.builder.*;
import org.punit.method.runner.*;
import org.punit.reporter.*;
-import org.punit.suite.builder.*;
public class VanillaRunner implements Runner {
@@ -47,10 +46,6 @@
return _runner.run(clazz, properties);
}
- public TestSuiteBuilder suiteBuilder() {
- return _runner.suiteBuilder();
- }
-
public TestResult testResult() {
return _runner.testResult();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-17 02:18:50
|
Revision: 295
http://p-unit.svn.sourceforge.net/p-unit/?rev=295&view=rev
Author: zhanghuangzhu
Date: 2008-04-16 19:18:56 -0700 (Wed, 16 Apr 2008)
Log Message:
-----------
az: remove TestResult as a field.
Modified Paths:
--------------
trunk/punit/src/org/punit/reporter/stream/StreamLogger.java
Modified: trunk/punit/src/org/punit/reporter/stream/StreamLogger.java
===================================================================
--- trunk/punit/src/org/punit/reporter/stream/StreamLogger.java 2008-04-17 00:57:31 UTC (rev 294)
+++ trunk/punit/src/org/punit/reporter/stream/StreamLogger.java 2008-04-17 02:18:56 UTC (rev 295)
@@ -21,8 +21,6 @@
protected transient PrintWriter _writer;
- protected transient TestResult _result;
-
public Level _level = Level.INFO;
private TimeWatcher _timeWatcher;
@@ -36,7 +34,6 @@
public void onRunnerStart(Class<?> clazz, Runner runner) {
startTimeWatcher();
- _result = runner.testResult();
StringBuffer sb = new StringBuffer();
sb.append("["); //$NON-NLS-1$
sb.append(runner.punitName());
@@ -54,7 +51,8 @@
}
public void onRunnerEnd(Class<?> clazz, Runner runner) {
- logResult();
+ TestResult result = runner.testResult();
+ logResult(result);
closeStream();
}
@@ -62,19 +60,19 @@
_writer.close();
}
- public void logResult() {
+ public void logResult(TestResult result) {
stopTimeWatcher();
- logResultSummary();
- logFailures();
+ logResultSummary(result);
+ logFailures(result);
}
- private void logResultSummary() {
+ private void logResultSummary(TestResult result) {
StringBuffer sb = new StringBuffer();
sb.append(Messages.getString("logger.total")); //$NON-NLS-1$
- sb.append(_result.methodCount());
+ sb.append(result.methodCount());
sb.append(", "); //$NON-NLS-1$
sb.append(Messages.getString("logger.failures")); //$NON-NLS-1$
- List<Throwable> failures = _result.failures();
+ List<Throwable> failures = result.failures();
int failuresCount = failures.size();
sb.append(failuresCount);
sb.append(" ("); //$NON-NLS-1$
@@ -89,8 +87,8 @@
log(sb.toString(), Level.SEVERE);
}
- private void logFailures() {
- List<Throwable> failures = _result.failures();
+ private void logFailures(TestResult result) {
+ List<Throwable> failures = result.failures();
Iterator<Throwable> iter = failures.iterator();
int count = 0;
while (iter.hasNext()) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-17 00:57:25
|
Revision: 294
http://p-unit.svn.sourceforge.net/p-unit/?rev=294&view=rev
Author: zhanghuangzhu
Date: 2008-04-16 17:57:31 -0700 (Wed, 16 Apr 2008)
Log Message:
-----------
az: added shutdown in Runner.
Modified Paths:
--------------
trunk/punit.test/src/tests/api/org/punit/runner/AbstractRunnerTest.java
Modified: trunk/punit.test/src/tests/api/org/punit/runner/AbstractRunnerTest.java
===================================================================
--- trunk/punit.test/src/tests/api/org/punit/runner/AbstractRunnerTest.java 2008-04-17 00:57:18 UTC (rev 293)
+++ trunk/punit.test/src/tests/api/org/punit/runner/AbstractRunnerTest.java 2008-04-17 00:57:31 UTC (rev 294)
@@ -21,6 +21,12 @@
assertNotSame(runner.methodRunner(), cloned.methodRunner());
assertNotSame(runner.methodRunner().watchers(), cloned.methodRunner().watchers());
}
+
+ public void testShutdown() {
+ MockAbstractRunner runner = new MockAbstractRunner();
+ runner.shutdown();
+ assertFalse(runner.isAlive());
+ }
static class MockAbstractRunner extends AbstractRunner {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-17 00:57:16
|
Revision: 293
http://p-unit.svn.sourceforge.net/p-unit/?rev=293&view=rev
Author: zhanghuangzhu
Date: 2008-04-16 17:57:18 -0700 (Wed, 16 Apr 2008)
Log Message:
-----------
az: added shutdown in Runner.
Modified Paths:
--------------
trunk/punit/src/org/punit/runner/AbstractRunner.java
trunk/punit/src/org/punit/runner/Runner.java
trunk/punit/src/org/punit/runner/VanillaRunner.java
Modified: trunk/punit/src/org/punit/runner/AbstractRunner.java
===================================================================
--- trunk/punit/src/org/punit/runner/AbstractRunner.java 2008-04-15 14:58:21 UTC (rev 292)
+++ trunk/punit/src/org/punit/runner/AbstractRunner.java 2008-04-17 00:57:18 UTC (rev 293)
@@ -5,6 +5,7 @@
import java.io.*;
import java.lang.reflect.*;
import java.util.*;
+import java.util.concurrent.atomic.*;
import org.punit.convention.*;
import org.punit.events.EventListener;
@@ -42,6 +43,8 @@
private Convention _convention;
private String _folder;
+
+ private AtomicBoolean _isAlive = new AtomicBoolean(true);
public AbstractRunner(TestSuiteBuilder testSuiteBuiler,
TestMethodBuilder testMethodBuilder, MethodRunner testMethodRunner) {
@@ -76,7 +79,7 @@
private void runTestClasses(Object[] testClasses) {
startExecutorPool();
- for (int i = 0; i < testClasses.length; ++i) {
+ for (int i = 0; i < testClasses.length && isAlive(); ++i) {
Object testClass = testClasses[i];
if (isTestSuiteLabel(testClass)) {
onSuite(((TestSuiteLabel) testClass));
@@ -412,4 +415,12 @@
public TestResult testResult() {
return _testResult;
}
+
+ public void shutdown() {
+ _isAlive.set(false);
+ }
+
+ public boolean isAlive() {
+ return _isAlive.get();
+ }
}
Modified: trunk/punit/src/org/punit/runner/Runner.java
===================================================================
--- trunk/punit/src/org/punit/runner/Runner.java 2008-04-15 14:58:21 UTC (rev 292)
+++ trunk/punit/src/org/punit/runner/Runner.java 2008-04-17 00:57:18 UTC (rev 293)
@@ -31,4 +31,5 @@
public String resultFolder();
+ public void shutdown();
}
Modified: trunk/punit/src/org/punit/runner/VanillaRunner.java
===================================================================
--- trunk/punit/src/org/punit/runner/VanillaRunner.java 2008-04-15 14:58:21 UTC (rev 292)
+++ trunk/punit/src/org/punit/runner/VanillaRunner.java 2008-04-17 00:57:18 UTC (rev 293)
@@ -1,4 +1,4 @@
-/* (C) Copyright 2007, by Andrew Zhang */
+/* (C) Copyright 2007 - 2008, by Andrew Zhang */
package org.punit.runner;
import java.util.*;
@@ -70,4 +70,8 @@
public String punitName() {
return _runner.punitName();
}
+
+ public void shutdown() {
+ _runner.shutdown();
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-15 14:58:27
|
Revision: 292
http://p-unit.svn.sourceforge.net/p-unit/?rev=292&view=rev
Author: zhanghuangzhu
Date: 2008-04-15 07:58:21 -0700 (Tue, 15 Apr 2008)
Log Message:
-----------
Andrew Zhang: changed p-unit version, and make StreamLogger not abstract.
Modified Paths:
--------------
trunk/punit/src/org/punit/PUnit.java
trunk/punit/src/org/punit/reporter/stream/StreamLogger.java
Modified: trunk/punit/src/org/punit/PUnit.java
===================================================================
--- trunk/punit/src/org/punit/PUnit.java 2008-04-06 15:22:45 UTC (rev 291)
+++ trunk/punit/src/org/punit/PUnit.java 2008-04-15 14:58:21 UTC (rev 292)
@@ -2,11 +2,12 @@
package org.punit;
+
public class PUnit {
/**
* @return returns the version of punit.
*/
public static String version() {
- return "0.12"; //$NON-NLS-1$
+ return "0.14"; //$NON-NLS-1$
}
}
Modified: trunk/punit/src/org/punit/reporter/stream/StreamLogger.java
===================================================================
--- trunk/punit/src/org/punit/reporter/stream/StreamLogger.java 2008-04-06 15:22:45 UTC (rev 291)
+++ trunk/punit/src/org/punit/reporter/stream/StreamLogger.java 2008-04-15 14:58:21 UTC (rev 292)
@@ -15,10 +15,12 @@
import org.punit.util.*;
import org.punit.watcher.*;
-public abstract class StreamLogger extends VanillaEventListener {
+public class StreamLogger extends VanillaEventListener {
- protected transient PrintWriter _writer;
+ private static final long serialVersionUID = -677120489939331361L;
+ protected transient PrintWriter _writer;
+
protected transient TestResult _result;
public Level _level = Level.INFO;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zha...@us...> - 2008-04-06 15:22:40
|
Revision: 291
http://p-unit.svn.sourceforge.net/p-unit/?rev=291&view=rev
Author: zhanghuangzhu
Date: 2008-04-06 08:22:45 -0700 (Sun, 06 Apr 2008)
Log Message:
-----------
az: make p-unit java 5 compile level.
Added Paths:
-----------
trunk/punit.android/.settings/
trunk/punit.android/.settings/org.eclipse.jdt.core.prefs
Added: trunk/punit.android/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/punit.android/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/punit.android/.settings/org.eclipse.jdt.core.prefs 2008-04-06 15:22:45 UTC (rev 291)
@@ -0,0 +1,12 @@
+#Sun Apr 06 22:03:43 CST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Property changes on: trunk/punit.android/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Name: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|