Author: jsong
Date: Sat Jul 31 19:29:46 2004
New Revision: 31071
Added:
incubator/beehive/trunk/controls/test/tmp/
incubator/beehive/trunk/controls/test/tmp/controls/
incubator/beehive/trunk/controls/test/tmp/controls/composition/
incubator/beehive/trunk/controls/test/tmp/controls/composition/InnerControl.java
incubator/beehive/trunk/controls/test/tmp/controls/composition/InnerControlEventListener.java
incubator/beehive/trunk/controls/test/tmp/controls/composition/InnerControlImpl.jcs
incubator/beehive/trunk/controls/test/tmp/controls/composition/OuterControl.java
incubator/beehive/trunk/controls/test/tmp/controls/composition/OuterControlImpl.jcs
incubator/beehive/trunk/controls/test/tmp/controls/composition/simple/
incubator/beehive/trunk/controls/test/tmp/controls/composition/simple/OuterControl2.java
incubator/beehive/trunk/controls/test/tmp/controls/composition/simple/OuterControl2Impl.jcs
incubator/beehive/trunk/controls/test/tmp/controls/composition/simple/SimpleInnerControl.java
incubator/beehive/trunk/controls/test/tmp/controls/composition/simple/SimpleInnerControlImpl.jcs
incubator/beehive/trunk/controls/test/tmp/readme.txt
incubator/beehive/trunk/controls/test/tmp/units/
incubator/beehive/trunk/controls/test/tmp/units/java/
incubator/beehive/trunk/controls/test/tmp/units/java/composition/
incubator/beehive/trunk/controls/test/tmp/units/java/composition/DeclarativeTest.java
incubator/beehive/trunk/controls/test/tmp/units/java/composition/ProgrammaticTest.java
Modified:
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/ComposerImpl.jcs
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/extension/ExtensibleControl.java
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/extension/ExtensibleControlImpl.jcs
Log:
adding tests for control composition.
Modified:
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/ComposerImpl.jcs
==============================================================================
---
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/ComposerImpl.jcs
(original)
+++
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/composition/ComposerImpl.jcs
Sat Jul 31 19:29:46 2004
@@ -11,8 +11,8 @@
import org.apache.beehive.controls.api.events.EventHandler;
import org.apache.beehive.controls.api.properties.PropertySet;
-import org.apache.beehive.controls.test.controls.properties.Props;
-import org.apache.beehive.controls.test.controls.properties.PropsExtension;
+import org.apache.beehive.controls.test.controls.property.Props;
+import org.apache.beehive.controls.test.controls.property.PropsExtension;
@ControlImplementation
public class ComposerImpl implements Composer
Modified:
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/extension/ExtensibleControl.java
==============================================================================
---
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/extension/ExtensibleControl.java
(original)
+++
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/extension/ExtensibleControl.java
Sat Jul 31 19:29:46 2004
@@ -23,4 +23,6 @@
}
public String hello();
+
+ public String getLayerByContext();
}
Modified:
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/extension/ExtensibleControlImpl.jcs
==============================================================================
---
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/extension/ExtensibleControlImpl.jcs
(original)
+++
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/extension/ExtensibleControlImpl.jcs
Sat Jul 31 19:29:46 2004
@@ -1,6 +1,8 @@
package org.apache.beehive.controls.test.controls.extension;
import java.lang.reflect.Method;
+import org.apache.beehive.controls.api.context.Context;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
import org.apache.beehive.controls.api.bean.ControlImplementation;
import org.apache.beehive.controls.api.bean.Extensible;
@@ -12,10 +14,19 @@
@ControlImplementation
public class ExtensibleControlImpl implements ExtensibleControl, Extensible
{
+ @Context ControlBeanContext context;
public String hello()
{
return "Hello from super control";
+ }
+
+ public String getLayerByContext()
+ {
+ /**BUG: could not refer to Greeting directly*/
+ WhereAbout
whereabout=(WhereAbout)context.getControlPropertySet(WhereAbout.class);
+
+ return whereabout.Layer();
}
public Object invoke(Method m, Object[] args)throws Throwable
Added:
incubator/beehive/trunk/controls/test/tmp/controls/composition/InnerControl.java
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/test/tmp/controls/composition/InnerControl.java
Sat Jul 31 19:29:46 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
+ */
[EMAIL PROTECTED]
+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/tmp/controls/composition/InnerControlEventListener.java
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/test/tmp/controls/composition/InnerControlEventListener.java
Sat Jul 31 19:29:46 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;
+ }
+}
\ No newline at end of file
Added:
incubator/beehive/trunk/controls/test/tmp/controls/composition/InnerControlImpl.jcs
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/test/tmp/controls/composition/InnerControlImpl.jcs
Sat Jul 31 19:29:46 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;
+
[EMAIL PROTECTED]
+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/tmp/controls/composition/OuterControl.java
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/test/tmp/controls/composition/OuterControl.java
Sat Jul 31 19:29:46 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
+ */
[EMAIL PROTECTED]
+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/tmp/controls/composition/OuterControlImpl.jcs
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/test/tmp/controls/composition/OuterControlImpl.jcs
Sat Jul 31 19:29:46 2004
@@ -0,0 +1,401 @@
+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.
+ */
[EMAIL PROTECTED]
+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="innerControl", eventSet=InnerControl.Activity.class,
eventName="report")
+ public String innerControlreport() { 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(){
+ InnerControlBean inner=(InnerControlBean)java.beans.Beans.instantiate(
+ Thread.currentThread().getContextClassLoader() ,
+
"org.apache.beehive.controls.test.controls.composition.InnerControlBean");
+ return inner;
+ }
+
+ 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*/
+ Thread.currentThread().sleep(1000);
+
+ if (innerControlEventHandlerWakeUp.equals(EVENT_RECEIVED))
+ result="0";
+ else
+ result="Acivity.wakeup not received by EventHandler";
+ }
+ return result;
+ }
+ public String testActivityReadMessage(){
+
+ String result="";
+ if (innerControl==null)
+ result="inner control is NULL";
+ else{
+ innerControl.fireEvent("Activity","readMessage");
+ /*Wait for the events*/
+ Thread.currentThread().sleep(1000);
+
+ if (innerControlEventHandlerReadMessage.equals(EVENT_RECEIVED))
+ result="0";
+ else
+ result="Acivity.readMessage not received by
EventHandler";
+ }
+ return result;
+
+ }
+ public String testActivityReport(){
+
+ String result="";
+ if (innerControl==null)
+ result="inner control is NULL";
+ else{
+ innerControl.fireEvent("Activity","report");
+ /*Wait for the events*/
+ Thread.currentThread().sleep(1000);
+
+ if (innerControlEventHandlerReport.equals(EVENT_RECEIVED))
+ result="0";
+ else
+ result="Acivity.report not received by EventHandler";
+ }
+ return result;
+
+ }
+ public String testActionShopping(){
+
+ String result="";
+ if (innerControl==null)
+ result="inner control is NULL";
+ else{
+ innerControl.fireEvent("Action","shopping");
+ /*Wait for the events*/
+ Thread.currentThread().sleep(1000);
+
+ if (innerControlEventHandlerShopping.equals(EVENT_RECEIVED))
+ result="0";
+ else
+ result="Action.shopping not received by EventHandler";
+ }
+ return result;
+
+ }
+ public String testActionDostuff(){
+
+ String result="";
+ if (innerControl==null)
+ result="inner control is NULL";
+ else{
+ innerControl.fireEvent("Action","doStuff");
+ /*Wait for the events*/
+ Thread.currentThread().sleep(1000);
+
+ if (innerControlEventHandlerDoStuff.equals(EVENT_RECEIVED))
+ result="0";
+ else
+ result="Action.doStuff not received by EventHandler";
+ }
+ 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";
+
+ 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);
+ }
+ catch(Exception e){}
+
+ result=listener.getFinalResult();
+ }
+ 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{
+ //Create an Event Listener
+ InnerControlEventListener listener=new
InnerControlEventListener();
+ innerControl.addActivityListener(listener);
+ innerControl.addActionListener(listener);
+ innerControl.fireAllEvents();
+
+ try{
+ Thread.currentThread().sleep(1000);
+ }
+ catch(Exception e){}
+
+ result=listener.getFinalResult();
+ }
+ 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";
+
+ 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 int readMessage(String message){
+ innerClassDoStuff=true;
+ return 0;
+ }
+ }
+ );
+ nested.fireAllEvents();
+ try{
+ Thread.currentThread().sleep(1000);
+ }
+ catch(Exception e){}
+
+ result=getInnerClassListenerResult();
+ }
+ 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{
+ innerControl.addActivityListener(
+ new InnerControl.Activity(){
+
+ void wakeup(){innerControlInnerClassWakeUp=true;}
+ int readMessage(String message){
+ innerControlInnerClassReadMessage=true;
+ return 0;}
+ 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 int readMessage(String message){
+ innerControlInnerClassDoStuff=true;
+ return 0;
+ }
+ }
+ );
+ nested.fireAllEvents();
+ try{
+ 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/tmp/controls/composition/simple/OuterControl2.java
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/test/tmp/controls/composition/simple/OuterControl2.java
Sat Jul 31 19:29:46 2004
@@ -0,0 +1,16 @@
+package org.apache.beehive.controls.test.controls.composition;
+
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+
+/**
+ * A control interface designed to test control composition
+ *
+ * Referring to a simple inner control that does not have any property or
devent declared
+ */
[EMAIL PROTECTED]
+public interface OuterControl2
+{
+ public SimpleInnerControlBean getDeclaredNestedControl();
+
+}
Added:
incubator/beehive/trunk/controls/test/tmp/controls/composition/simple/OuterControl2Impl.jcs
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/test/tmp/controls/composition/simple/OuterControl2Impl.jcs
Sat Jul 31 19:29:46 2004
@@ -0,0 +1,24 @@
+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.test.controls.composition.SimpleInnerControlBean;
+
+/**
+ * A control implementation designed to test control composition
+ * This control implementation make two instances of nested control
+ * be declaration.
+ */
[EMAIL PROTECTED]
+public class OuterControl2Impl implements OuterControl2
+{
+
+ @Control
+ SimpleInnerControlBean innerControl;
+
+ public SimpleInnerControlBean getDeclaredNestedControl(){
+ return innerControl;
+ }
+
+}
Added:
incubator/beehive/trunk/controls/test/tmp/controls/composition/simple/SimpleInnerControl.java
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/test/tmp/controls/composition/simple/SimpleInnerControl.java
Sat Jul 31 19:29:46 2004
@@ -0,0 +1,17 @@
+package org.apache.beehive.controls.test.controls.composition;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+/**
+ * A simple control interface designed to test control composition
+ *
+ * This interface does not have any property or event declared
+ */
[EMAIL PROTECTED]
+public interface SimpleInnerControl
+{
+
+ public void fireAllEvents();
+ public void fireEvent(String eventSet, String eventName);
+ public String getNameFromContext();
+ public String getJobFromContext();
+}
Added:
incubator/beehive/trunk/controls/test/tmp/controls/composition/simple/SimpleInnerControlImpl.jcs
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/test/tmp/controls/composition/simple/SimpleInnerControlImpl.jcs
Sat Jul 31 19:29:46 2004
@@ -0,0 +1,28 @@
+package org.apache.beehive.controls.test.controls.composition;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+
+/*
+ * A simple control implementation without any property or event implemented
+ */
+
[EMAIL PROTECTED]
+public class SimpleInnerControlImpl implements SimpleInnerControl
+{
+
+ public String getNameFromContext(){
+ return "0";
+ }
+ public String getJobFromContext(){
+ return "0";
+ }
+
+ public void fireEvent(String eventSet, String eventName){
+ //do nothing
+ }
+
+ public void fireAllEvents(){
+ //do nothing
+ }
+
+}
Added: incubator/beehive/trunk/controls/test/tmp/readme.txt
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/tmp/readme.txt Sat Jul 31
19:29:46 2004
@@ -0,0 +1,5 @@
+These tests causes compile errors because of an exiting bug.
+
+CR190512.
+
+They need to be moved out of the test/src temporarily and should be moved back
when the bug is fixed.
\ No newline at end of file
Added:
incubator/beehive/trunk/controls/test/tmp/units/java/composition/DeclarativeTest.java
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/test/tmp/units/java/composition/DeclarativeTest.java
Sat Jul 31 19:29:46 2004
@@ -0,0 +1,124 @@
+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
+
+/**
+ * A TeseCase that tests control composition.
+ * The outer control is instantiated declaratively, and the outer
+ * control instantiates the nested control declaratively
+ */
+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
+ */
+ 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());
+ }
+
+}
\ No newline at end of file
Added:
incubator/beehive/trunk/controls/test/tmp/units/java/composition/ProgrammaticTest.java
==============================================================================
--- (empty file)
+++
incubator/beehive/trunk/controls/test/tmp/units/java/composition/ProgrammaticTest.java
Sat Jul 31 19:29:46 2004
@@ -0,0 +1,132 @@
+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;
+
+/**
+ * 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(){
+
+ 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
+ */
+ public void testInstantiate() throws Exception
+ {
+ Assert.assertNoNull(outerControl);
+
Assert.assertNoNull(outerControl.instantiateNestedControlProgrammatically());
+
Assert.assertNoNull(outerControl.instantiateNestedControlWithProperty());
+ }
+
+ /**
+ * Tests outer control getting inner control property from control context
+ */
+ 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
+ */
+ 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
+ */
+ 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
+ */
+ 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.testInnerClassListener());
+ }
+
+ /**
+ * Tests outer control receiving events from nested control using
+ * event listener
+ */
+ public void testEventListener() throws Exception
+ {
+ Assert.assertNotNull(outerControl);
+ Assert.assertEquals("0",outerControl.testEventListener());
+ }
+
+
+}
\ No newline at end of file