You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2006/01/09 23:23:00 UTC
svn commit: r367416 - in /beehive/trunk:
docs/forrest/release/src/documentation/content/xdocs/controls/tutorial_controls.xml
samples/controls-blank/build.xml samples/controls-blank/src/pkg/Hello.java
samples/controls-blank/src/pkg/HelloImpl.java
Author: ekoneil
Date: Mon Jan 9 14:22:53 2006
New Revision: 367416
URL: http://svn.apache.org/viewcvs?rev=367416&view=rev
Log:
Few changes to the controls-blank web application. Also adds the Ant task for testing to the Forrest documentation.
BB: self
Test: build.dist pass
Modified:
beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/controls/tutorial_controls.xml
beehive/trunk/samples/controls-blank/build.xml
beehive/trunk/samples/controls-blank/src/pkg/Hello.java
beehive/trunk/samples/controls-blank/src/pkg/HelloImpl.java
Modified: beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/controls/tutorial_controls.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/controls/tutorial_controls.xml?rev=367416&r1=367415&r2=367416&view=diff
==============================================================================
--- beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/controls/tutorial_controls.xml (original)
+++ beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/controls/tutorial_controls.xml Mon Jan 9 14:22:53 2006
@@ -141,15 +141,15 @@
<title>Create a JUnit Test Class</title>
<p>
Now that the control builds successfully, it's time to write a JUnit test case to ensure that the
- Control operates as it is intended. To do this, create a <code>tests</code> directory to contain
- the JUnit test cases for the control. The directory should be created under <code>controls_tutorial/tests</code>
+ Control operates as it is intended. To do this, create a <code>test</code> directory to contain
+ the JUnit test cases for the control. The directory should be created under <code>controls_tutorial/test</code>
with the command:
</p>
- <source>mkdir tests</source>
+ <source>mkdir test</source>
<p>
In this directory, create a Java package to contain the source of a JUnit test with:
</p>
- <source>mkdir tests/testpackage</source>
+ <source>mkdir test/testpackage</source>
<p>
Now, create a JUnit test case called <code>HelloControlTest.java</code>. This class wil declare an instance of the
Hello control and unit test its API. This class should appear as follows:
@@ -161,7 +161,7 @@
import pkg.Hello;
-public class Tests
+public class HelloControlTest
extends ControlTestCase {
@Control
@@ -171,7 +171,7 @@
throws Exception {
String message = _helloControl.hello();
- assertEquals("Hello!", message, "Failed to receive message 'Hello!'.");
+ assertEquals("Failed to receive message \"Hello!\"", "Hello!", message);
}
}</source>
</section>
@@ -179,19 +179,49 @@
<title>Edit build.xml to Compile and Run the JUnit Test</title>
<p>
Now that the test has been written, the Ant build.xml file still needs to change to support building
- and running JUnit tests. To do this, add the following target to build the JUnit tests; this target
- would appear as follows:
+ and running JUnit tests. To do this, add the following <code>test</code> target to the build.xml file:
</p>
- <source>
-todo
- </source>
+ <source><target name="test">
+ <property name="test.src" location="test"/>
+ <property name="test.classes" location="${build.dir}/test-classes"/>
+ <property name="test.beansrc" location="${build.dir}/test-beansrc"/>
+
+ <mkdir dir="${test.classes}"/>
+ <mkdir dir="${test.beansrc}"/>
+
+ <path id="test.classpath">
+ <path refid="build.classpath"/>
+ <pathelement location="${build.dir}/${build.jar}"/>
+ <pathelement location="${junit.home}/junit.jar"/>
+ </path>
+
+ <build-controls srcdir="${test.src}"
+ destdir="${test.classes}"
+ tempdir="${test.beansrc}"
+ classpathref="test.classpath"/>
+
+ <path id="test-run.classpath">
+ <path refid="test.classpath"/>
+ <pathelement location="${test.classes}"/>
+ <pathelement location="${beehive.home}/lib/common/commons-discovery-0.2.jar"/>
+ <pathelement location="${beehive.home}/lib/common/commons-logging-1.0.4.jar"/>
+ </path>
+
+ <java classname="junit.textui.TestRunner"
+ classpathref="test-run.classpath">
+ <arg line="testpackage.HelloControlTest"/>
+ </java>
+</target></source>
<p>
- Now, add a target to run the JUnit tests. This can be done in several different ways; here, Ant's
- JUnit targets are used.
+ This target first builds the test source files. Then, it runs the JUnit tests, reporting errors
+ if tests fail.
</p>
- <source>
-todo
- </source>
+ <note>
+ There are lots of ways to run JUnit tests in Ant including the use of the <code><junit></code>
+ Ant tasks. This tutorial has taken a simple approach to running JUnit; this example test should
+ run in other JUnit execution environments as well. For information on configuring Ant's JUnit
+ tasks, see <a href="file:///c:/java/apache-ant-1.6.5/docs/manual/OptionalTasks/junit.html">here</a>.
+ </note>
</section>
<section id="run-test">
<title>Run the Test</title>
@@ -257,14 +287,14 @@
throws Exception {
String message = _helloControl.hello();
- assertEquals("Hello!", message, "Failed to receive message 'Hello!'.");
+ assertEquals("Failed to receive message \"Hello!\"", "Hello!", message);
}
<strong>public void testParam()
throws Exception {
String message = _helloControl.hello("World");
- assertEquals("Hello, World!", message, "Failed to receive message 'Hello, World!'.");
+ assertEquals("Failed to receive message \"Hello, World!\"", "Hello, World!", message);
}</strong>
}</source>
</section>
Modified: beehive/trunk/samples/controls-blank/build.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/controls-blank/build.xml?rev=367416&r1=367415&r2=367416&view=diff
==============================================================================
--- beehive/trunk/samples/controls-blank/build.xml (original)
+++ beehive/trunk/samples/controls-blank/build.xml Mon Jan 9 14:22:53 2006
@@ -49,20 +49,20 @@
tempdir="${build.beansrc}"
classpathref="build.classpath"/>
- <control-jar destfile="${build.dir}/${build.jar}" basedir="${build.classes}" />
+ <control-jar destfile="${build.dir}/${build.jar}" basedir="${build.classes}" />
</target>
<target name="usage" description="Print the usage for this build.xml">
<echo message=""/>
<echo message=""/>
- <echo message="Controls Project Template Build file"/>
+ <echo message="Controls Project Build file"/>
<echo message=""/>
<echo message=""/>
<echo message="----------------------------------------------------------------"/>
<echo message="| Standard Targets |"/>
<echo message="----------------------------------------------------------------"/>
<echo message="clean - Delete all generated files"/>
- <echo message="build - Build control sources"/>
+ <echo message="build - Build control source files"/>
<echo message="----------------------------------------------------------------"/>
</target>
Modified: beehive/trunk/samples/controls-blank/src/pkg/Hello.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/controls-blank/src/pkg/Hello.java?rev=367416&r1=367415&r2=367416&view=diff
==============================================================================
--- beehive/trunk/samples/controls-blank/src/pkg/Hello.java (original)
+++ beehive/trunk/samples/controls-blank/src/pkg/Hello.java Mon Jan 9 14:22:53 2006
@@ -17,11 +17,10 @@
*/
package pkg;
-import org.apache.beehive.controls.api.bean.*;
+import org.apache.beehive.controls.api.bean.ControlInterface;
@ControlInterface
-public interface Hello
-{
+public interface Hello {
String hello();
}
Modified: beehive/trunk/samples/controls-blank/src/pkg/HelloImpl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/controls-blank/src/pkg/HelloImpl.java?rev=367416&r1=367415&r2=367416&view=diff
==============================================================================
--- beehive/trunk/samples/controls-blank/src/pkg/HelloImpl.java (original)
+++ beehive/trunk/samples/controls-blank/src/pkg/HelloImpl.java Mon Jan 9 14:22:53 2006
@@ -17,14 +17,14 @@
*/
package pkg;
-import org.apache.beehive.controls.api.bean.*;
+import org.apache.beehive.controls.api.bean.ControlImplementation;
@ControlImplementation(isTransient=true)
-public class HelloImpl implements Hello
-{
- public String hello()
- {
- return "hello!";
+public class HelloImpl
+ implements Hello {
+
+ public String hello() {
+ return "Hello!";
}
}