You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by st...@apache.org on 2005/12/13 21:57:07 UTC

svn commit: r356613 - /beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/controls/tutorial_controls.xml

Author: steveh
Date: Tue Dec 13 12:57:04 2005
New Revision: 356613

URL: http://svn.apache.org/viewcvs?rev=356613&view=rev
Log:
Latest content for controls tutorial.

Modified:
    beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/controls/tutorial_controls.xml

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=356613&r1=356612&r2=356613&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 Tue Dec 13 12:57:04 2005
@@ -34,6 +34,15 @@
                     Installation and Setup</a>
                  </p>
             </section>
+            <section id="install_junit">
+                <title>Install JUnit</title>
+                <p>
+                    <a href="http://sourceforge.net/project/showfiles.php?group_id=15278">Download</a>  the latest version of JUnit.
+                </p>
+                <p>
+                    Unzip the junit.zip file into a directory of your choice.
+                </p>
+            </section>
             <section id="create_control_proj">
                 <title>Create a Control Project</title>
                 <p>
@@ -48,37 +57,22 @@
                     beehive distribution.
                 </p>
                 <p>
-                    For example, if your Beehive distribution is located in <code>/apache/apache-beehive-1.0</code>, 
+                    Add the property <code>junit.home</code> to the file and ensure that it points to your junit installation.
+                </p>
+                <p>
+                    For example, if your Beehive distribution is located at <code>/apache/apache-beehive-1.0</code>
+                    and junit is located at /test-tools/junit, 
                     then your <code>build.properties</code> file would appear as follows.
                 </p>
                 <source>
 beehive.home=<strong>/apache/apache-beehive-1.0</strong>
+                    
+junit.home=<strong>/test-tools/junit</strong>
                 </source>
                 <note>
                     Properties files should use the '/' character to separate drive, directory, and file names.
                 </note>
             </section>
-            <section id="install_junit">
-                <title>Install JUnit</title>
-                <p>
-                    <a href="http://sourceforge.net/project/showfiles.php?group_id=15278">Download</a>  the latest version of JUnit.
-                </p>
-                <p>
-                    Unzip the junit.zip file into a directory of your choice.
-                </p>
-                <p>
-                    In your shell, set <code>JUNIT_HOME</code> to refer to the directory where <code>junit.jar</code> resides:  
-                </p>
-                <source>
-JUNIT_HOME = /some/directory
-                </source>
-                <p>
-                    Add <code>junit.jar</code> to the classpath: 
-                </p>
-                <source>
-export CLASSPATH=$JUNIT_HOME/junit.jar
-                </source>
-            </section>
         </section>
         <section id="compile">
             <title>Step 2: Compile the Control Implementation and Interface Files</title>
@@ -149,7 +143,7 @@
                     <code>controls_tutorial/build/helloControl.jar</code> </p>
             </section>
         </section>
-        <section id="test">
+        <section id="test_setup">
             <title>Step 3: Create a JUnit Test for the Control</title>
             <section id="add_test_class">
                 <title>Add a Test Class</title>
@@ -198,7 +192,7 @@
     &lt;property name="build.classes" location="${build.dir}/classes"/>
     &lt;property name="build.beansrc" location="${build.dir}/beansrc"/>
     &lt;property name="build.jar" value="helloControl.jar"/>
-    <strong>&lt;property name="junit.jar" value="PATH/TO/YOUR/junit.jar"/>
+    <strong>&lt;property name="junit.jar" value="${junit.home}/junit.jar"/>
     &lt;property name="commons.disc.jar" value="${beehive.home}/lib/common/commons-discovery-0.2.jar"/>
     &lt;property name="commons.log.jar" value="${beehive.home}/lib/common/commons-logging-1.0.4.jar"/></strong>
     
@@ -262,12 +256,89 @@
                 </section>
                 <section id="run_test">
                     <title>Run the Test</title>
+                    <p>In your command shell, ensure that you are in the directory <code>controls_tutorial/</code></p>
                     <p>Run the following Ant command to test the control.</p>
                     <source>
 ant clean build test                        
                     </source>
                 </section>
             </section>
+        <section id="add_parameter_method">
+            <title>Step 4: Add a Parameterized Method to the Control</title>
+            <section>
+                <title>Edit the Control Source Files</title>
+                <p>Edit the file <code>HelloImpl.java</code> so it appears as follows. Code to add appears in bold</p>
+                <source>package pkg;
+    
+    import org.apache.beehive.controls.api.bean.ControlImplementation;
+    
+    @ControlImplementation(isTransient=true)
+    public class HelloImpl implements Hello
+    {
+        public String hello()
+        {
+            return "hello!";
+        }
+    
+    <strong>    public String helloParam(String name)
+        {
+            return "Hello, " + name + "!";
+        }</strong>
+    }
+                </source>
+                <p>Edit the file <code>Hello.java</code> so it appears as follows. Code to add appears in bold</p>
+                <source>package pkg;
+    
+    import org.apache.beehive.controls.api.bean.ControlInterface;
+    
+    @ControlInterface
+    public interface Hello
+    {
+        String hello();
+        
+        <strong>String helloParam(String name);</strong>
+    }
+                </source>
+            </section>
+            <section>
+                <title>
+                    Add a Test Case for the New Control Method
+                </title>
+                <p>Edit the file <code>Tests.java</code> so it appears as follows.  Code to add appears in bold.</p>
+                <source>
+package tests;
+
+import org.apache.beehive.controls.api.bean.Control;
+import pkg.Hello;
+
+import org.apache.beehive.controls.test.junit.ControlTestCase;
+
+public class Tests extends ControlTestCase
+{   
+    @Control
+    private Hello _helloControl;
+    
+    public void testHello() throws Exception
+    {
+    	String message = _helloControl.hello();
+        if(!message.equalsIgnoreCase("hello!"))
+            fail("Method hello() failed to return message 'hello!'.");
+    }
+    
+    <strong>public void testParam() throws Exception
+    {
+    	String message = _helloControl.helloParam("World");
+        if(!message.equalsIgnoreCase("Hello, World!"))
+            fail("Method helloParam() failed to return message 'Hello, World!'.");
+    }</strong>
+}                    
+                </source>
+            </section>
+            <section id="run_test2">
+                <title>Run the Test</title>
+                <p>Test the control according to the previous instructions <a href="#run_test">here</a>.</p>
+            </section>            
+         </section>
        </body>
     <footer>
         <legal>Java, J2EE, and JCP are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.<br/>&copy; 2005, Apache Software Foundation