Added:
trunk/src/atunit/NoUnitException.java
trunk/src/atunit/TooManyUnitsException.java
trunk/src/atunit/jmock/NoMockeryException.java
trunk/src/atunit/jmock/TooManyMockeriesException.java
Modified:
trunk/build.xml
trunk/src/atunit/AtUnit.java
trunk/src/atunit/jmock/JMockFramework.java
trunk/src/atunit/spring/SpringContainer.java
trunk/test/atunit/core/AtUnitTests.java
trunk/test/atunit/jmock/JMockFrameworkTests.java
Log:
- cleaned up exceptions: made them top level types, added messages and
javadoc where needed
- bumped version to 0.7
Modified: trunk/build.xml
==============================================================================
--- trunk/build.xml (original)
+++ trunk/build.xml Sun Nov 11 19:09:23 2007
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="atunit" default="dist">
- <property name="version" value="0.6"/>
+ <property name="version" value="0.7"/>
<property name="ant.build.javac.source" value="1.5"/>
Modified: trunk/src/atunit/AtUnit.java
==============================================================================
--- trunk/src/atunit/AtUnit.java (original)
+++ trunk/src/atunit/AtUnit.java Sun Nov 11 19:09:23 2007
@@ -141,17 +141,5 @@
return mockFrameworkClass.newInstance();
}
-
-
- @SuppressWarnings("serial")
- public static class NoUnitException extends Exception {
- }
-
- @SuppressWarnings("serial")
- public static class TooManyUnitsException extends Exception {
- public TooManyUnitsException(String msg) {
- super(msg);
- }
- }
}
Added: trunk/src/atunit/NoUnitException.java
==============================================================================
--- (empty file)
+++ trunk/src/atunit/NoUnitException.java Sun Nov 11 19:09:23 2007
@@ -0,0 +1,30 @@
+/**
+ * Copyright (C) 2007 Logan Johnson
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package atunit;
+
+/**
+ * Thrown when the test has no field annotated with {@link Unit}.
+ *
+ * @author Logan Johnson <logan....@gmail.com>
+ *
+ */
+@SuppressWarnings("serial")
+public class NoUnitException extends Exception {
+ public NoUnitException() {
+ super("Every AtUnit test must have exactly one field annotated with @Unit");
+ }
+}
\ No newline at end of file
Added: trunk/src/atunit/TooManyUnitsException.java
==============================================================================
--- (empty file)
+++ trunk/src/atunit/TooManyUnitsException.java Sun Nov 11 19:09:23 2007
@@ -0,0 +1,30 @@
+/**
+ * Copyright (C) 2007 Logan Johnson
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package atunit;
+
+/**
+ * Thrown when a test has more than one field annotated with {@link Unit}.
+ *
+ * @author Logan Johnson <logan....@gmail.com>
+ *
+ */
+@SuppressWarnings("serial")
+public class TooManyUnitsException extends Exception {
+ public TooManyUnitsException(String msg) {
+ super(msg);
+ }
+}
\ No newline at end of file
Modified: trunk/src/atunit/jmock/JMockFramework.java
==============================================================================
--- trunk/src/atunit/jmock/JMockFramework.java (original)
+++ trunk/src/atunit/jmock/JMockFramework.java Sun Nov 11 19:09:23 2007
@@ -95,15 +95,5 @@
return jmockFields;
}
-
- @SuppressWarnings("serial")
- public static class NoMockeryException extends Exception {
- }
- @SuppressWarnings("serial")
- public static class TooManyMockeriesException extends Exception {
- public TooManyMockeriesException(String msg) {
- super(msg);
- }
- }
}
Added: trunk/src/atunit/jmock/NoMockeryException.java
==============================================================================
--- (empty file)
+++ trunk/src/atunit/jmock/NoMockeryException.java Sun Nov 11 19:09:23 2007
@@ -0,0 +1,39 @@
+/**
+ * Copyright (C) 2007 Logan Johnson
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package atunit.jmock;
+
+import org.jmock.Mockery;
+
+/**
+ * Thrown when a test has fields marked as mocks, but no field with a type
+ * assignable from {@link Mockery}.
+ * <p>
+ * JMock mock objects are useless without access to the {@code Mockery}
+ * (context) from which they were created; presence of the former
without the
+ * latter implies a mistake.
+ *
+ * @author Logan Johnson <logan....@gmail.com>
+ *
+ */
+@SuppressWarnings("serial")
+public class NoMockeryException extends Exception {
+ public NoMockeryException() {
+ super("This test requests mock objects, but not the Mockery from
which" +
+ " they were created; declare a field of type Mockery, or perhaps" +
+ " consider using stubs instead of mocks.");
+ }
+}
\ No newline at end of file
Added: trunk/src/atunit/jmock/TooManyMockeriesException.java
==============================================================================
--- (empty file)
+++ trunk/src/atunit/jmock/TooManyMockeriesException.java Sun Nov 11
19:09:23 2007
@@ -0,0 +1,32 @@
+/**
+ * Copyright (C) 2007 Logan Johnson
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package atunit.jmock;
+
+import org.jmock.Mockery;
+
+/**
+ * Thrown when a test has more than one field of type {@link Mockery}.
+ *
+ *
+ * @author Logan Johnson <logan....@gmail.com>
+ */
+@SuppressWarnings("serial")
+public class TooManyMockeriesException extends Exception {
+ public TooManyMockeriesException(String msg) {
+ super(msg);
+ }
+}
\ No newline at end of file
Modified: trunk/src/atunit/spring/SpringContainer.java
==============================================================================
--- trunk/src/atunit/spring/SpringContainer.java (original)
+++ trunk/src/atunit/spring/SpringContainer.java Sun Nov 11 19:09:23 2007
@@ -135,7 +135,7 @@
return beandef;
}
- public static class InstanceHolderFactoryBean implements FactoryBean {
+ protected static class InstanceHolderFactoryBean implements
FactoryBean {
final Class<?> type;
final Object instance;
Modified: trunk/test/atunit/core/AtUnitTests.java
==============================================================================
--- trunk/test/atunit/core/AtUnitTests.java (original)
+++ trunk/test/atunit/core/AtUnitTests.java Sun Nov 11 19:09:23 2007
@@ -27,6 +27,8 @@
import atunit.AtUnit;
import atunit.ContainerClass;
import atunit.MockFrameworkClass;
+import atunit.NoUnitException;
+import atunit.TooManyUnitsException;
import atunit.Unit;
@@ -57,14 +59,14 @@
public void tNoUnit() {
Result result = junit.run(TestClasses.NoUnit.class);
assertFalse(result.wasSuccessful());
- assertTrue(result.getFailures().get(0).getException() instanceof AtUnit.NoUnitException);
+ assertTrue(result.getFailures().get(0).getException() instanceof NoUnitException);
}
@Test
public void tTooManyUnits() {
Result result = junit.run(TestClasses.TooManyUnits.class);
assertFalse(result.wasSuccessful());
- assertTrue(result.getFailures().get(0).getException() instanceof AtUnit.TooManyUnitsException);
+ assertTrue(result.getFailures().get(0).getException() instanceof TooManyUnitsException);
}
protected static class TestClasses {
Modified: trunk/test/atunit/jmock/JMockFrameworkTests.java
==============================================================================
--- trunk/test/atunit/jmock/JMockFrameworkTests.java (original)
+++ trunk/test/atunit/jmock/JMockFrameworkTests.java Sun Nov 11
19:09:23 2007
@@ -54,7 +54,7 @@
public void tMockWithoutMockery() {
Result result = junit.run(TestClasses.MockWithoutMockery.class);
assertFalse(result.wasSuccessful());
- assertTrue(result.getFailures().get(0).getException() instanceof JMockFramework.NoMockeryException);
+ assertTrue(result.getFailures().get(0).getException() instanceof NoMockeryException);
}
@Test