You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by js...@apache.org on 2004/09/01 00:48:31 UTC

svn commit: rev 37266 - in incubator/beehive/trunk/controls/test: . src/controls/org/apache/beehive/controls/test/controls/composition src/units/org/apache/beehive/controls/test/java/composition tmp

Author: jsong
Date: Tue Aug 31 15:48:29 2004
New Revision: 37266

Added:
   incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/InnerControl.java   (contents, props changed)
   incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/InnerControlEventListener.java   (contents, props changed)
   incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/InnerControlImpl.jcs   (contents, props changed)
   incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/OuterControl.java   (contents, props changed)
   incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/OuterControlImpl.jcs   (contents, props changed)
   incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/composition/
   incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/composition/DeclarativeTest.java   (contents, props changed)
   incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/composition/ProgrammaticTest.java   (contents, props changed)
Removed:
   incubator/beehive/trunk/controls/test/tmp/
Modified:
   incubator/beehive/trunk/controls/test/build.xml
Log:
Add test on controls conposition and remove test files from controls/test/tmp.


Modified: incubator/beehive/trunk/controls/test/build.xml
==============================================================================
--- incubator/beehive/trunk/controls/test/build.xml	(original)
+++ incubator/beehive/trunk/controls/test/build.xml	Tue Aug 31 15:48:29 2004
@@ -12,6 +12,11 @@
   	     classpath="${beehive-antext.jar}" />
     <taskdef name="apt" classname="org.apache.beehive.controls.runtime.generator.AptTask" 
              classpath="../build/jars/controls.jar" onerror="report" />
+    <taskdef name="assemble" classname="org.apache.beehive.controls.runtime.assembly.AssembleTask" 
+             classpath="../build/jars/controls.jar" onerror="report" />  	     
+    <taskdef name="control-jar" 
+             classname="org.apache.beehive.controls.runtime.packaging.ControlJarTask" 
+             classpath="../build/jars/controls.jar" onerror="report" />             
 
     <!-- BeeHive test specific properties -->
     <property name="test.root" location="${basedir}/src"/>
@@ -108,7 +113,7 @@
     <!-- ==================================================================== -->
 
     <target name="build" depends="dirs">
-        <ant target="build-controls" />
+        <ant target="build-beans" />
         <ant target="build-test-drivers" />
         <ant target="build-java-tests" />
     </target>
@@ -123,7 +128,8 @@
         <mkdir dir="${test.logs}" />
     </target>
 
-    <target name="build-controls" depends="dirs" unless="_build.controls.ran">
+    <!-- obsoleted target
+    target name="build-controls" depends="dirs" unless="_build.controls.ran">
 
         <apt srcdir="${controls.src}" destdir="${build.beans}" gendir="${build.beansrc}"
              classpathref="test.classpath" 
@@ -131,9 +137,37 @@
         </apt>
         <jar destfile="${build.jars}/testbeans.jar"  basedir="${build.beans}" />
         <property name="_build.controls.ran" value="true"/>
+    </target-->
+
+    <target name="build-beans" depends="dirs">
+        <!-- Build checkers first so they can be dynamically loaded
+        during build of control extensions.  Checkers may dep on public interfaces,
+        which we need to make sure get pulled in by apt -->
+        <apt srcdir="${controls.src}" destdir="${build.beans}" gendir="${build.beansrc}"
+             classpathref="test.classpath" >
+            <include name="**/checker/*.java"/>
+        </apt>
+        <apt srcdir="${controls.src}" destdir="${build.beans}" gendir="${build.beansrc}"
+             classpathref="test.classpath" compileByExtension="true"
+             srcExtensions="*.java,*.jcx,*.jcs" >
+        </apt>
+        <!-- Do control assembly. -->
+        <assemble moduleDir="${build.beans}"
+                  srcOutputDir="${build.beansrc}"
+                  contextFactoryClassname="org.apache.beehive.controls.runtime.assembly.EJBAssemblyContext$Factory">
+            <classpath>
+                <path refid="test.classpath"/>
+                <pathelement location="${build.beans}"/>
+            </classpath>
+            <fileset dir="${build.beans}">
+                <include name="**/*.controls.properties"/>
+            </fileset>
+        </assemble>
+        <control-jar destfile="${build.jars}/checkinbeans.jar"  basedir="${build.beans}" />
     </target>
 
-    <target name="build-test-drivers" depends="build-controls" unless="_build.test.drivers.ran">
+
+    <target name="build-test-drivers" depends="build-beans" unless="_build.test.drivers.ran">
 	<echo>build helper class for testing controls</echo>
         <!-- Build the test source directory -->
         <javac srcdir="${tests.driver.src}"

Added: incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/InnerControl.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/InnerControl.java	Tue Aug 31 15:48:29 2004
@@ -0,0 +1,55 @@
+package org.apache.beehive.controls.test.controls.composition;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+import org.apache.beehive.controls.api.events.EventSet;
+import org.apache.beehive.controls.api.properties.PropertySet;
+
+/**
+ * A control interface designed to test control composition
+ */
+@ControlInterface
+public interface InnerControl
+{
+	static final String DEFAULT_NAME="Bob";
+	static final String DEFAULT_JOB="cleaner";
+
+    @PropertySet
+    @Target( {ElementType.TYPE, ElementType.FIELD} )
+    @Retention(RetentionPolicy.RUNTIME)
+    public @interface Identity
+    {
+        public String name() default DEFAULT_NAME;
+        //does not have a default value assigned
+		public String job();
+    }
+
+
+
+    @EventSet
+    public interface Activity
+    {
+        void wakeup();
+        int readMessage(String message);
+        String report();
+    }
+
+    @EventSet
+    public interface Action
+    {
+        public Object[] shopping (double credit);
+        public void doStuff(String value);
+    }
+
+	public void fireAllEvents();
+    public void fireEvent(String eventSet, String eventName);
+
+	/*Gets property value from context*/
+    public String getNameFromContext();
+    /*Gets property value from context*/
+    public String getJobFromContext();
+}

Added: incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/InnerControlEventListener.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/InnerControlEventListener.java	Tue Aug 31 15:48:29 2004
@@ -0,0 +1,72 @@
+package org.apache.beehive.controls.test.controls.composition;
+
+/**
+ * A listener class for event raised by InnerControl
+ */
+public class InnerControlEventListener implements InnerControl.Activity,InnerControl.Action
+{
+
+	private boolean wakeupReceived=false;
+	private boolean readMessageReceived=false;
+	private boolean reportReceived=false;
+	private boolean shoppingReceived=false;
+	private boolean doStuffReceived=false;
+
+	/*
+	 * BUG!!?? although the event declares methods wakeup, readMessage and
+	 * report using default accessor,
+	 * implmentation must change the method accessor to public,
+	 * or, a compile error!
+	 *
+	 *  attempting to assign weaker access privileges; was public
+     * [apt]     void wakeup(){wakeupReceived=true;}
+     *
+	 */
+
+	public void wakeup(){wakeupReceived=true;}
+    public int readMessage(String message){
+		readMessageReceived=true;
+		return 0;}
+    public String report(){
+		reportReceived=true;
+		return "a report from event listener";}
+
+    public Object[] shopping (double credit){
+		shoppingReceived=true;
+		//return (Object){"clothes","shoes","food"};
+		return null;
+		}
+    public void doStuff(String value){
+		doStuffReceived=true;
+		}
+
+	public boolean getWakeupResult(){return wakeupReceived;}
+	public boolean getReadMessageResult(){return readMessageReceived;}
+	public boolean getReportResult(){return reportReceived;}
+	public boolean getShoppingResult(){return shoppingReceived;}
+	public boolean getDoStuffResult(){return doStuffReceived;}
+
+	/* checks all the event records.
+	 * returns '0' if all the events have been received.
+	 */
+	public String getFinalResult(){
+
+		String result="";
+
+		if (!wakeupReceived)
+			result="WakeUp not received.";
+		if (!readMessageReceived)
+			result=result+"readMessage not received.";
+		if (!reportReceived)
+			result=result+"report not received.";
+		if (!shoppingReceived)
+			result=result+"shopping not received.";
+		if (!doStuffReceived)
+			result=result+"dostuff not received.";
+
+		if (result.length()==0)
+			result="0";
+
+		return result;
+	}
+}

Added: incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/InnerControlImpl.jcs
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/InnerControlImpl.jcs	Tue Aug 31 15:48:29 2004
@@ -0,0 +1,62 @@
+package org.apache.beehive.controls.test.controls.composition;
+
+import java.lang.reflect.Method;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.events.Client;
+import org.apache.beehive.controls.api.context.Context;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+
+@ControlImplementation
+public class InnerControlImpl implements InnerControl
+{ 
+    @Context ControlBeanContext context;
+    @Client Activity activity;
+    @Client Action action;
+
+
+    /*Gets property value from context*/
+    public String getNameFromContext(){
+
+	Identity identity=(InnerControl.Identity)context.getControlPropertySet(InnerControl.Identity.class);
+	return identity.name();
+    }
+    /*Gets property value from context*/
+    public String getJobFromContext(){
+
+	Identity identity=(InnerControl.Identity)context.getControlPropertySet(InnerControl.Identity.class);
+	return identity.job();    
+    }
+    
+    public void fireEvent(String eventSet, String eventName){
+    	
+    	if ((eventSet!=null)&&(eventName!=null)){
+    	
+    		if (eventSet.equalsIgnoreCase("Activity")){
+    			if (eventName.equalsIgnoreCase("wakeup"))
+    				activity.wakeup();
+    			else if(eventName.equalsIgnoreCase("readMessage"))
+    				activity.readMessage("message from nested control");
+    			else if(eventName.equalsIgnoreCase("report"))
+    				activity.report();    			
+    		}
+    		else if (eventSet.equalsIgnoreCase("Action")){
+    		    	if (eventName.equalsIgnoreCase("shopping"))
+		    		action.shopping(999.99d);
+		    	else if(eventName.equalsIgnoreCase("doStuff"))
+		    		action.doStuff("stuff to do");
+    		}
+    	}
+    	
+    }
+
+    public void fireAllEvents(){
+
+    	activity.wakeup();
+	activity.readMessage("message from nested control");
+	activity.report();    			
+	action.shopping(999.99d);
+	action.doStuff("stuff to do");
+    }
+    
+} 

Added: incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/OuterControl.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/OuterControl.java	Tue Aug 31 15:48:29 2004
@@ -0,0 +1,52 @@
+package org.apache.beehive.controls.test.controls.composition;
+
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+import org.apache.beehive.controls.test.controls.composition.InnerControlBean;
+
+
+
+/**
+ * A control interface designed to test control composition
+ */
+@ControlInterface
+public interface OuterControl
+{
+	/*
+	 * BUG: can not refer to the bean class
+	 *
+	 * Must a outer control declare its inner control by bean or interface?
+	 */
+	public InnerControlBean getDeclaredNestedControl();
+	public InnerControlBean getDeclaredNestedControl2();
+	public InnerControlBean instantiateNestedControlProgrammatically();
+	public InnerControlBean instantiateNestedControlWithProperty();
+
+	/*Test outer control receiving event from nested control using
+	 * EventHandler.
+	 */
+	public String testActivityWakeup();
+	public String testActivityReadMessage();
+	public String testActivityReport();
+	public String testActionShopping();
+	public String testActionDostuff();
+
+	/*Tests outer control receiving event from nested control using
+	 * event listener. The nested control is instantiated programmatically
+	 */
+	public String testEventListener();
+
+	/*Tests outer control receiving event from nested control using
+	 * event listener. The nested control is instantiated decalratively
+	 */
+	public String testEventListenerByDeclare();
+
+	/*Tests outer control receiving event from nested control using
+	 * inner class listener. The nested control is instantiated programmatically
+	 */
+	public String testInnerClassListener();
+	/*Tests outer control receiving event from nested control using
+	 * inner class listener. The nested control is instantiated decalratively
+	 */
+	public String testInnerClassListenerByDeclare();
+}

Added: incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/OuterControlImpl.jcs
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/OuterControlImpl.jcs	Tue Aug 31 15:48:29 2004
@@ -0,0 +1,444 @@
+package org.apache.beehive.controls.test.controls.composition;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.bean.Control;
+import org.apache.beehive.controls.api.context.Context;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+import org.apache.beehive.controls.api.events.EventHandler;
+
+import org.apache.beehive.controls.test.controls.composition.InnerControlBean;
+
+/**
+ * A control implementation designed to test control composition
+ * This control implementation make two instances of nested control
+ * be declaration.
+ */
+@ControlImplementation
+public class OuterControlImpl implements OuterControl
+{ 
+    static final long serialVersionUID = 1L;
+    static final String EVENT_RECEIVED="Event Received";
+    
+    private String innerControlEventHandlerWakeUp="";
+    private String innerControlEventHandlerReadMessage="";
+    private String innerControlEventHandlerReport="";
+    private String innerControlEventHandlerShopping="";
+    private String innerControlEventHandlerDoStuff="";
+    
+    private boolean innerClassWakeUp=false;
+    private boolean innerClassReadMessage=false;
+    private boolean innerClassReport=false;
+    private boolean innerClassShopping=false;
+    private boolean innerClassDoStuff=false;    
+
+    private boolean innerControlInnerClassWakeUp=false;
+    private boolean innerControlInnerClassReadMessage=false;
+    private boolean innerControlInnerClassReport=false;
+    private boolean innerControlInnerClassShopping=false;
+    private boolean innerControlInnerClassDoStuff=false;  
+    
+    /*Instantiates a nested control without reconfiguring the property*/
+    @Control 
+    InnerControlBean innerControl;
+
+    @Control 
+    @InnerControl.Identity(job="farmer")
+    InnerControlBean innerControl2;
+    
+  
+    //
+    // Define various event handlers for the nested controls
+    //
+    @EventHandler(field="innerControl", eventSet=InnerControl.Activity.class, eventName="wakeup")
+    public void innerControlwakeup() { innerControlEventHandlerWakeUp=EVENT_RECEIVED; }
+
+    @EventHandler(field="innerControl", eventSet=InnerControl.Activity.class, eventName="readMessage")
+    public int innerControlreadMessage(String message) { 
+    	innerControlEventHandlerReadMessage=EVENT_RECEIVED;
+    	return 0;
+    }
+
+    @EventHandler(field="innerControl", eventSet=InnerControl.Activity.class, eventName="report")
+    public String innerControlreport() { 
+    	innerControlEventHandlerReport=EVENT_RECEIVED;
+    	return "a report";
+    }
+
+    @EventHandler(field="innerControl", eventSet=InnerControl.Action.class, eventName="shopping")
+    public Object [] innerControlshopping(double credit) { 
+    	innerControlEventHandlerShopping=EVENT_RECEIVED;
+    	return null;
+    }
+
+    @EventHandler(field="innerControl", eventSet=InnerControl.Action.class, eventName="doStuff")
+    public void innerControldoStuff(String vakue) {
+    	innerControlEventHandlerShopping=EVENT_RECEIVED;
+    }
+
+    @EventHandler(field="innerControl2", eventSet=InnerControl.Activity.class, eventName="wakeup")
+    public void innerControl2wakeup() {}
+
+    @EventHandler(field="innerControl2", eventSet=InnerControl.Activity.class, eventName="readMessage")
+    public int innerControl2readMessage(String message) { return 0; }
+
+    @EventHandler(field="innerControl2", eventSet=InnerControl.Activity.class, eventName="report")
+    public String innerControl2report() { return "a report"; }
+
+    @EventHandler(field="innerControl2", eventSet=InnerControl.Action.class, eventName="shopping")
+    public Object [] innerControl2shopping(double credit) { return null; }
+
+    @EventHandler(field="innerControl2", eventSet=InnerControl.Action.class, eventName="doStuff")
+    public void innerControl2doStuff(String vakue) {}
+
+    
+    public InnerControlBean getDeclaredNestedControl(){
+    	return innerControl;
+    }
+
+    public InnerControlBean getDeclaredNestedControl2(){
+    	return innerControl2;
+    }
+    
+    public InnerControlBean instantiateNestedControlProgrammatically(){
+    	try{
+    		InnerControlBean inner=(InnerControlBean)java.beans.Beans.instantiate( 
+    			Thread.currentThread().getContextClassLoader() ,
+			"org.apache.beehive.controls.test.controls.composition.InnerControlBean");
+		return inner;
+	}
+	catch(Exception e){
+		return null;
+	}
+    }
+
+    public InnerControlBean instantiateNestedControlWithProperty(){
+	/*BUG:CR190302*/
+	return null;
+    }
+
+    public String testActivityWakeup(){
+  	
+  	String result="";
+  	if (innerControl==null)
+  		result="inner control is NULL";
+  	else{
+  		innerControl.fireEvent("Activity","wakeup");
+  		/*Wait for the events*/
+  		try{
+			Thread.currentThread().sleep(1000);
+			if (innerControlEventHandlerWakeUp.equals(EVENT_RECEIVED))
+				result="0";
+			else
+				result="Acivity.wakeup not received by EventHandler";
+		}
+		catch(Exception e){
+			result="Thread sleep interrupted."+e.toString();
+		}
+  	}
+  	return result;
+    }
+    public String testActivityReadMessage(){
+    
+  	String result="";
+  	if (innerControl==null)
+  		result="inner control is NULL";
+  	else{
+  		innerControl.fireEvent("Activity","readMessage");
+  		/*Wait for the events*/
+  		try{
+			Thread.currentThread().sleep(1000);
+		
+			if (innerControlEventHandlerReadMessage.equals(EVENT_RECEIVED))
+				result="0";
+			else
+				result="Acivity.readMessage not received by EventHandler";
+		}
+		catch(Exception e){
+			result="Thread sleep interrupted."+e.toString();
+		}
+  	}
+  	return result;
+    
+    }
+    public String testActivityReport(){
+
+  	String result="";
+  	if (innerControl==null)
+  		result="inner control is NULL";
+  	else{
+  		innerControl.fireEvent("Activity","report");
+  		/*Wait for the events*/
+  		try{
+			Thread.currentThread().sleep(1000);
+			
+			if (innerControlEventHandlerReport.equals(EVENT_RECEIVED))
+				result="0";
+			else
+				result="Acivity.report not received by EventHandler";
+		}
+		catch(Exception e){
+			result="Thread sleep interrupted."+e.toString();		
+		}
+  	}
+  	return result;
+    
+    }
+    public String testActionShopping(){
+    
+  	String result="";
+  	if (innerControl==null)
+  		result="inner control is NULL";
+  	else{
+  		innerControl.fireEvent("Action","shopping");
+  		/*Wait for the events*/
+  		try{
+			Thread.currentThread().sleep(1000);
+			
+			if (innerControlEventHandlerShopping.equals(EVENT_RECEIVED))
+				result="0";
+			else
+				result="Action.shopping not received by EventHandler";
+		}
+		catch(Exception e){
+			result="Thread sleep interrupted."+e.toString();
+		}
+  	}
+  	return result;
+    
+    }
+    public String testActionDostuff(){
+
+  	String result="";
+  	if (innerControl==null)
+  		result="inner control is NULL";
+  	else{
+  		innerControl.fireEvent("Action","doStuff");
+  		/*Wait for the events*/
+  		try{
+			Thread.currentThread().sleep(1000);
+		
+			if (innerControlEventHandlerDoStuff.equals(EVENT_RECEIVED))
+				result="0";
+			else
+				result="Action.doStuff not received by EventHandler";
+		}
+		catch(Exception e){
+			result="Thread sleep interrupted."+e.toString();		
+		}
+  	}
+  	return result;
+    
+    }
+
+    /*Tests outer control receiving event from nested control using
+     * event listener. The nested control is instantiated programmatically
+     */
+    public String testEventListener(){
+
+	String result="init";
+	try{
+    	
+    	InnerControlBean nested=(InnerControlBean)java.beans.Beans.instantiate( 
+    		Thread.currentThread().getContextClassLoader() ,
+		"org.apache.beehive.controls.test.controls.composition.InnerControlBean");
+	if (nested==null)
+		result="Nested control instantiated programmatically is NULL.";
+	else{
+		//Create an Event Listener
+		InnerControlEventListener listener=new InnerControlEventListener();
+		nested.addActivityListener(listener);
+		nested.addActionListener(listener);
+		nested.fireAllEvents();
+		try{	
+			Thread.currentThread().sleep(1000);
+			result=listener.getFinalResult();
+		}
+		catch(Exception e){
+			result="Thread sleep interrupted."+e.toString();
+		}
+		
+		
+	}
+	}
+	catch(Exception e){
+		result="Exception caught:"+e.toString();
+	}
+	return result;
+    }
+
+    /*Tests outer control receiving event from nested control using
+     * event listener. The nested control is instantiated decalratively
+     */
+    public String testEventListenerByDeclare(){
+
+	String result="init";
+	
+ 	if (innerControl==null)
+		result="Nested control instantiated declaratively is NULL.";
+	else{
+		try{
+		//Create an Event Listener
+		InnerControlEventListener listener=new InnerControlEventListener();
+		innerControl.addActivityListener(listener);
+		innerControl.addActionListener(listener);
+		innerControl.fireAllEvents();
+
+			Thread.currentThread().sleep(1000);
+			result=listener.getFinalResult();
+		}
+		catch(Exception e){
+			result="Thread sleep interrupted."+e.toString();
+		}
+		
+		
+	}
+	return result;
+    
+    }
+
+    /*Tests outer control receiving event from nested control using
+     * inner class listener. The nested control is instantiated programmatically
+     */
+    public String testInnerClassListener(){
+    
+	String result="init";
+	try{
+    	InnerControlBean nested=(InnerControlBean)java.beans.Beans.instantiate( 
+    		Thread.currentThread().getContextClassLoader() ,
+		"org.apache.beehive.controls.test.controls.composition.InnerControlBean");
+	if (nested==null)
+		result="Nested control instantiated programmatically is NULL.";
+	else{
+		nested.addActivityListener(
+		    new InnerControl.Activity(){
+			
+			public void wakeup(){innerClassWakeUp=true;}
+			public int readMessage(String message){
+				innerClassReadMessage=true;
+				return 0;}
+        		public String report(){
+        			innerClassReport=true;
+        			return "event received.";	
+        			}
+		    }
+		);
+		nested.addActionListener(
+		    new InnerControl.Action(){
+			
+			public Object[] shopping (double credit){
+				innerClassShopping=true;
+				//return {"food","drinks","candies"};
+				return null;
+				}
+			public void doStuff(String value){
+				innerClassDoStuff=true;
+				}
+		    }		
+		);
+		nested.fireAllEvents();
+		try{
+			Thread.currentThread().sleep(1000);
+		}
+		catch(Exception e){}
+		
+		result=getInnerClassListenerResult();
+	}
+	}
+	catch(Exception e){
+		result="Exception caught:"+e.toString();
+	}
+	return result;
+    }
+
+    /*Tests outer control receiving event from nested control using
+     * inner class listener. The nested control is instantiated decalratively
+     */
+    public String testInnerClassListenerByDeclare(){
+
+	String result="init";
+	
+	if (innerControl==null)
+		result="Nested control instantiated declaratively is NULL.";
+	else{
+		try{
+		innerControl.addActivityListener(
+		    new InnerControl.Activity(){
+			
+			public void wakeup(){innerControlInnerClassWakeUp=true;}
+			public int readMessage(String message){
+				innerControlInnerClassReadMessage=true;
+				return 0;}
+        		public String report(){
+        			innerControlInnerClassReport=true;
+        			return "event received.";	
+        			}
+		    }
+		);
+		innerControl.addActionListener(
+		    new InnerControl.Action(){
+			
+			public Object[] shopping (double credit){
+				innerControlInnerClassShopping=true;
+				//return {"food","drinks","candies"};
+				return null;
+				}
+			public void doStuff(String value){
+				innerControlInnerClassDoStuff=true;
+				}
+		    }		
+		);
+		innerControl.fireAllEvents();
+
+			Thread.currentThread().sleep(1000);
+		}
+		catch(Exception e){}
+		
+		result=getInnerControlInnerClassListenerResult();
+	}
+	return result;
+    
+    }
+
+    private String getInnerClassListenerResult(){
+    	
+	String result="";
+
+	if (!innerClassWakeUp)
+		result="WakeUp not received.";
+	if (!innerClassReadMessage)
+		result=result+"readMessage not received.";
+	if (!innerClassReport)
+		result=result+"report not received.";
+	if (!innerClassShopping)
+		result=result+"shopping not received.";
+	if (!innerClassDoStuff)
+		result=result+"dostuff not received.";
+
+	if (result.length()==0)
+		result="0";
+
+	return result;    	
+    }
+
+    private String getInnerControlInnerClassListenerResult(){
+    	
+	String result="";
+
+	if (!innerControlInnerClassWakeUp)
+		result="WakeUp not received.";
+	if (!innerControlInnerClassReadMessage)
+		result=result+"readMessage not received.";
+	if (!innerControlInnerClassReport)
+		result=result+"report not received.";
+	if (!innerControlInnerClassShopping)
+		result=result+"shopping not received.";
+	if (!innerControlInnerClassDoStuff)
+		result=result+"dostuff not received.";
+
+	if (result.length()==0)
+		result="0";
+
+	return result;    	
+    }
+
+} 

Added: incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/composition/DeclarativeTest.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/composition/DeclarativeTest.java	Tue Aug 31 15:48:29 2004
@@ -0,0 +1,134 @@
+package org.apache.beehive.controls.test.java.composition;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import java.beans.Beans;
+import org.apache.beehive.controls.api.bean.Control;
+import org.apache.beehive.controls.api.bean.ControlBean;
+import org.apache.beehive.controls.test.controls.composition.OuterControlBean;
+import org.apache.beehive.controls.test.controls.composition.InnerControlBean;
+import org.apache.beehive.mantis.annotations.tch.Freq;
+import org.apache.beehive.mantis.annotations.tch.Status;
+
+/**
+ * A TeseCase that tests control composition.
+ * The outer control is instantiated declaratively, and the outer
+ * control instantiates the nested control declaratively
+ *
+ * Instantiating controls declaratively is not supported currently.
+ * All tests are deactivated until this is supported
+ *
+ */
+@Status("inactive")
+public class DeclarativeTest extends TestCase
+{
+
+    public DeclarativeTest(String name) throws Exception
+    {super(name);}
+
+    /**
+     * A control that contains a nested control
+     */
+    @Control
+    public OuterControlBean outerControl;
+
+    /**
+     * Tests outer control instantiats nested control by declaration
+     */
+    public void testInstantiate() throws Exception
+    {
+		Assert.assertNotNull(outerControl);
+		Assert.assertNotNull(outerControl.getDeclaredNestedControl());
+		Assert.assertNotNull(outerControl.getDeclaredNestedControl2());
+    }
+
+    /**
+     * Tests outer control getting inner control property from control context
+     */
+    public void testGetProppertyByContext() throws Exception
+    {
+		Assert.assertNotNull(outerControl);
+		InnerControlBean innercontrol=outerControl.getDeclaredNestedControl();
+		Assert.assertNotNull(innercontrol);
+		Assert.assertEquals("Bob",innercontrol.getNameFromContext());
+		Assert.assertNull(innercontrol.getJobFromContext());
+    }
+
+    /**
+     * Tests outer control getting inner control property by getter
+     *
+
+	commented out temporarily, getter/setter causes compile error
+
+    public void testGetProppertyByGetter() throws Exception
+    {
+		Assert.assertNotNull(outerControl);
+		InnerControlBean innercontrol=outerControl.getDeclaredNestedControl();
+		Assert.assertNotNull(innercontrol);
+		Assert.assertEquals("Bob",innercontrol.getIdentityname());
+		Assert.assertNull(innercontrol.getIdentityjob());
+    }
+
+    /**
+     * Tests outer control setting inner control property by setter
+     *
+    public void testSetProppertyBySetter() throws Exception
+    {
+		Assert.assertNotNull(outerControl);
+		InnerControlBean innercontrol=outerControl.getDeclaredNestedControl();
+		Assert.assertNotNull(innercontrol);
+		innercontrol.setIdentityname("new name declare");
+		innercontrol.setIdentityjob("new job declare");
+		Assert.assertEquals("new name declare",innercontrol.getNameFromContext());
+		Assert.assertEquals("new job declare",innercontrol.getJobFromContext());
+    }
+	*/
+    /**
+     * Tests reconfigured property.
+     * Outer control reconfigures the inner control's property when instantiating it
+     */
+    public void testReconfiguredProperty() throws Exception
+    {
+		Assert.assertNotNull(outerControl);
+		InnerControlBean innercontrol=outerControl.getDeclaredNestedControl2();
+		Assert.assertNotNull(innercontrol);
+		Assert.assertEquals("Bob",innercontrol.getNameFromContext());
+		Assert.assertEquals("farmer",innercontrol.getJobFromContext());
+    }
+
+    /**
+     * Tests outer control receiving events from nested control using
+     * EventHandler
+     */
+    public void testEventHandler() throws Exception
+    {
+		Assert.assertNotNull(outerControl);
+		Assert.assertEquals("0",outerControl.testActivityWakeup());
+		Assert.assertEquals("0",outerControl.testActivityReadMessage());
+		Assert.assertEquals("0",outerControl.testActivityReport());
+		Assert.assertEquals("0",outerControl.testActionShopping());
+		Assert.assertEquals("0",outerControl.testActionDostuff());
+    }
+
+    /**
+     * Tests outer control receiving events from nested control using
+     * inner class
+     */
+    public void testEventInnerClass() throws Exception
+    {
+		Assert.assertNotNull(outerControl);
+		Assert.assertEquals("0",outerControl.testInnerClassListenerByDeclare());
+    }
+
+    /**
+     * Tests outer control receiving events from nested control using
+     * event listener
+     */
+    public void testEventListener() throws Exception
+    {
+		Assert.assertNotNull(outerControl);
+		Assert.assertEquals("0",outerControl.testEventListenerByDeclare());
+    }
+
+}

Added: incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/composition/ProgrammaticTest.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/composition/ProgrammaticTest.java	Tue Aug 31 15:48:29 2004
@@ -0,0 +1,147 @@
+package org.apache.beehive.controls.test.java.composition;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import java.beans.Beans;
+import org.apache.beehive.controls.api.bean.Control;
+import org.apache.beehive.controls.api.bean.ControlBean;
+import org.apache.beehive.controls.test.controls.composition.OuterControlBean;
+import org.apache.beehive.controls.test.controls.composition.InnerControlBean;
+import org.apache.beehive.mantis.annotations.tch.Freq;
+import org.apache.beehive.mantis.annotations.tch.Status;
+
+/**
+ * A TeseCase that tests control composition.
+ * The outer control is instantiated programmatically, and the outer
+ * control instantiates the nested control programmatically
+ */
+public class ProgrammaticTest extends TestCase
+{
+
+    public ProgrammaticTest(String name) throws Exception
+    {super(name);}
+
+    /**
+     * A control that contains a nested control
+     */
+	private OuterControlBean outerControl;
+
+
+	/* Instantiate the outerControl once*/
+	protected void setUp() throws Exception {
+
+		outerControl=(OuterControlBean)java.beans.Beans.instantiate( Thread.currentThread().getContextClassLoader() ,
+		"org.apache.beehive.controls.test.controls.composition.OuterControlBean");
+	}
+
+    /**
+     * Tests outer control instantiats nested control by declaration
+     */
+    @Freq("checkin")
+    public void testInstantiate() throws Exception
+    {
+		Assert.assertNotNull(outerControl);
+		Assert.assertNotNull(outerControl.instantiateNestedControlProgrammatically());
+		/*
+		Commented out for CR190302
+		Assert.assertNotNull(outerControl.instantiateNestedControlWithProperty());
+		*/
+    }
+
+    /**
+     * Tests outer control getting inner control property from control context
+     */
+    @Freq("checkin")
+    public void testGetProppertyByContext() throws Exception
+    {
+		Assert.assertNotNull(outerControl);
+		InnerControlBean innercontrol=outerControl.instantiateNestedControlProgrammatically();
+		Assert.assertNotNull(innercontrol);
+		Assert.assertEquals("Bob",innercontrol.getNameFromContext());
+		Assert.assertNull(innercontrol.getJobFromContext());
+    }
+
+    /**
+     * Tests outer control getting inner control property by getter
+     *
+
+     commented out temporarily before getter/setter is fixed
+
+    public void testGetProppertyByGetter() throws Exception
+    {
+		Assert.assertNotNull(outerControl);
+		InnerControlBean innercontrol=outerControl.instantiateNestedControlProgrammatically();
+		Assert.assertNotNull(innercontrol);
+		Assert.assertEquals("Bob",innercontrol.getIdentityname());
+		Assert.assertNull(innercontrol.getIdentityjob());
+    }
+
+    /**
+     * Tests outer control setting inner control property by setter
+     *
+    public void testSetProppertyBySetter() throws Exception
+    {
+		Assert.assertNotNull(outerControl);
+		InnerControlBean innercontrol=outerControl.instantiateNestedControlProgrammatically();
+		Assert.assertNotNull(innercontrol);
+		innerControl.setIdentityname("new name");
+		innerControl.setIdentityjob("new job");
+		Assert.assertEquals("new name",innercontrol.getNameFromContext());
+		Assert.assertEquals("new job",innercontrol.getJobFromContext());
+    }
+	*/
+    /**
+     * Tests reconfigured property.
+     * Outer control reconfigures the inner control's property when instantiating it
+     */
+    @Freq("detailed")
+    public void testReconfiguredProperty() throws Exception
+    {
+		Assert.assertNotNull(outerControl);
+		InnerControlBean innercontrol=outerControl.instantiateNestedControlWithProperty();
+		Assert.assertNotNull(innercontrol);
+		Assert.assertEquals("Bob",innercontrol.getNameFromContext());
+		Assert.assertNull(innercontrol.getJobFromContext());
+    }
+
+    /**
+     * Tests outer control receiving events from nested control using
+     * EventHandler
+     */
+    @Freq("detailed")
+    public void testEventHandler() throws Exception
+    {
+		Assert.assertNotNull(outerControl);
+		Assert.assertEquals("0",outerControl.testActivityWakeup());
+		Assert.assertEquals("0",outerControl.testActivityReadMessage());
+		Assert.assertEquals("0",outerControl.testActivityReport());
+		Assert.assertEquals("0",outerControl.testActionShopping());
+		Assert.assertEquals("0",outerControl.testActionDostuff());
+
+    }
+
+    /**
+     * Tests outer control receiving events from nested control using
+     * inner class
+     */
+    @Freq("detailed")
+    public void testEventInnerClass() throws Exception
+    {
+		Assert.assertNotNull(outerControl);
+		Assert.assertEquals("0",outerControl.testInnerClassListener());
+    }
+
+    /**
+     * Tests outer control receiving events from nested control using
+     * event listener
+     */
+    @Freq("detailed")
+    public void testEventListener() throws Exception
+    {
+		Assert.assertNotNull(outerControl);
+		Assert.assertEquals("0",outerControl.testEventListener());
+    }
+
+
+}