Author: jsong
Date: Thu Jan 27 09:30:42 2005
New Revision: 126629

URL: http://svn.apache.org/viewcvs?view=rev&rev=126629
Log:
Add tests on controls binding.

Added:
   
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SubControl.java
   
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SubControlImpl.jcs
   
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SubControlImpl2.jcs
   
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SuperControl.java
   
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SuperControlImpl.jcs
   
incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/binding/
   
incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/binding/DriveSubControl.java
   
incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/jws/binding/
   
incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/jws/binding/TestBinding.java
Modified:
   
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/extension/SubControl.java

Added: 
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SubControl.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SubControl.java?view=auto&rev=126629
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SubControl.java
        Thu Jan 27 09:30:42 2005
@@ -0,0 +1,46 @@
+package org.apache.beehive.controls.test.controls.binding;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import org.apache.beehive.controls.api.bean.ControlExtension;
+import org.apache.beehive.controls.api.bean.ControlInterface;
+import org.apache.beehive.controls.api.properties.PropertySet;
+import org.apache.beehive.controls.api.properties.BaseProperties;
+import org.apache.beehive.controls.api.events.EventSet;
+
+/**
+ * A sub control extending SuperControl.
+ *
+ * This control interface specifies the implementation by BasePropery 
annotation
+ *
+ * This control declares one new method and one new propertySet.
+ * It also resets the value of the propertySet inherited from SuperControl.
+ */
+//@ControlExtension ::JIRA-118 and JIRA-197
[EMAIL PROTECTED]
[EMAIL PROTECTED](Layer="On_SubControl_Interface_Layer")
[EMAIL 
PROTECTED](controlImplementation="org.apache.beehive.controls.test.controls.binding.SubControlImpl2")
+public interface SubControl extends SuperControl
+{
+
+    static final String A_MESSAGE = "New Property Declared by Sub Control";
+
+       @PropertySet
+       @Retention(RetentionPolicy.RUNTIME)
+       public @interface NewProperty
+       {
+               String Message() default A_MESSAGE;
+    }
+
+    @EventSet
+    public interface SubClassEvent
+    {
+        public void method1();
+    }
+
+    public String hello2();
+    public String accessInheritedProperty();
+    public String getExtendedPropertyByContext();
+    public int invokeInheritedEventFromSubControl();
+    public int invokeExtendedEventFromSubControl();
+}

Added: 
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SubControlImpl.jcs
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SubControlImpl.jcs?view=auto&rev=126629
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SubControlImpl.jcs
     Thu Jan 27 09:30:42 2005
@@ -0,0 +1,53 @@
+package org.apache.beehive.controls.test.controls.binding;
+
+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.events.Client;
+
+/**
+ * A control impl of a SubControl and extending ExtensibleControlImpl.
+ * It accesses the propertySets inherited from ExtensibleControl, and extended 
by
+ * its own interface.
+ */
[EMAIL PROTECTED] 
+public class SubControlImpl extends SuperControlImpl implements SubControl
+{
+    @Context ControlBeanContext context;
+
+    @Client SubControl.SuperClassEvent superevent;
+    @Client SubControl.SubClassEvent subevent;
+
+    public String hello2()
+    {
+       return "Hello from subcontrolimpl";
+    }
+    
+    /*Accessing the propertySet inherited from ExtensibleControl*/
+    public String accessInheritedProperty()
+    {
+        /**Bug: could not refer to WhereAbout directly*/
+        SuperControl.WhereAbout 
where=(SuperControl.WhereAbout)context.getControlPropertySet(SuperControl.WhereAbout.class);
+        
+        return where.Position();    
+    }
+
+    public String getExtendedPropertyByContext(){
+
+        SubControl.NewProperty 
newproperty=(SubControl.NewProperty)context.getControlPropertySet(SubControl.NewProperty.class);
+        
+        return newproperty.Message();    
+    }
+
+    public int invokeInheritedEventFromSubControl(){
+    
+       superevent.method1();
+       return 0;
+    }
+    public int invokeExtendedEventFromSubControl(){
+
+       subevent.method1();
+       return 0;
+    }
+    
+}

Added: 
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SubControlImpl2.jcs
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SubControlImpl2.jcs?view=auto&rev=126629
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SubControlImpl2.jcs
    Thu Jan 27 09:30:42 2005
@@ -0,0 +1,52 @@
+package org.apache.beehive.controls.test.controls.binding;
+
+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.events.Client;
+
+/**
+ * A control impl of a SubControl and extending ExtensibleControlImpl.
+ * It accesses the propertySets inherited from ExtensibleControl, and extended 
by
+ * its own interface.
+ */
[EMAIL PROTECTED] 
+public class SubControlImpl2 extends SuperControlImpl implements SubControl
+{
+    @Context ControlBeanContext context;
+
+    @Client SubControl.SuperClassEvent superevent;
+    @Client SubControl.SubClassEvent subevent;
+
+    public String hello2()
+    {
+       return "Hello from subcontrolimpl2";
+    }
+    /*Accessing the propertySet inherited from ExtensibleControl*/
+    public String accessInheritedProperty()
+    {
+        /**Bug: could not refer to WhereAbout directly*/
+        SuperControl.WhereAbout 
where=(SuperControl.WhereAbout)context.getControlPropertySet(SuperControl.WhereAbout.class);
+        
+        return where.Position();    
+    }
+
+    public String getExtendedPropertyByContext(){
+
+        SubControl.NewProperty 
newproperty=(SubControl.NewProperty)context.getControlPropertySet(SubControl.NewProperty.class);
+        
+        return newproperty.Message();    
+    }
+
+    public int invokeInheritedEventFromSubControl(){
+    
+       superevent.method1();
+       return 0;
+    }
+    public int invokeExtendedEventFromSubControl(){
+
+       subevent.method1();
+       return 0;
+    }
+    
+}

Added: 
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SuperControl.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SuperControl.java?view=auto&rev=126629
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SuperControl.java
      Thu Jan 27 09:30:42 2005
@@ -0,0 +1,38 @@
+package org.apache.beehive.controls.test.controls.binding;
+
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import org.apache.beehive.controls.api.bean.ControlInterface;
+import org.apache.beehive.controls.api.properties.PropertySet;
+import org.apache.beehive.controls.api.events.EventSet;
+
+
+/**
+ * A control interface with one method and one propertySet
+ */
[EMAIL PROTECTED]
+public interface SuperControl
+{
+       static final String CURRENT_POSITION = "In_ExtensibleControl_Interface";
+       static final String CURRENT_LAYER = "On_ExtensibleControl_Layer";
+
+       @PropertySet
+       @Retention(RetentionPolicy.RUNTIME)
+       public @interface WhereAbout
+       {
+               String Position() default CURRENT_POSITION;
+               String Layer() default CURRENT_LAYER;
+    }
+
+    @EventSet
+    public interface SuperClassEvent
+    {
+        public void method1();
+    }
+
+    //@TestInterceptor()
+    public String hello();
+
+    public String getLayerByContext();
+}

Added: 
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SuperControlImpl.jcs
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SuperControlImpl.jcs?view=auto&rev=126629
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/binding/SuperControlImpl.jcs
   Thu Jan 27 09:30:42 2005
@@ -0,0 +1,37 @@
+package org.apache.beehive.controls.test.controls.binding;
+
+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;
+
+/**
+ * A control impl.
+ * By implementing Extensible, this impl makes itself extensible
+ */
+
[EMAIL PROTECTED] 
+public class SuperControlImpl implements SuperControl, Extensible
+{
+    @Context ControlBeanContext context;
+
+    public String hello()
+    {
+       return "Hello from super control impl";
+    }
+    
+    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
+    {
+       return null;
+    }
+    
+}

Modified: 
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/extension/SubControl.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/extension/SubControl.java?view=diff&rev=126629&p1=incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/extension/SubControl.java&r1=126628&p2=incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/extension/SubControl.java&r2=126629
==============================================================================
--- 
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/extension/SubControl.java
      (original)
+++ 
incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/extension/SubControl.java
      Thu Jan 27 09:30:42 2005
@@ -2,7 +2,7 @@
 
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
-//import org.apache.beehive.controls.api.bean.ControlExtension;
+import org.apache.beehive.controls.api.bean.ControlExtension;
 import org.apache.beehive.controls.api.bean.ControlInterface;
 import org.apache.beehive.controls.api.properties.PropertySet;
 import org.apache.beehive.controls.api.events.EventSet;
@@ -12,6 +12,7 @@
  * This control declares one new method and one new propertySet.
  * It also resets the value of the propertySet inherited from 
ExtensibleControl.
  */
+//@ControlExtension ::JIRA-118 and JIRA-197
 @ControlInterface
 @ExtensibleControl.WhereAbout(Layer="On_SubControl_Interface_Layer")
 public interface SubControl extends ExtensibleControl

Added: 
incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/binding/DriveSubControl.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/binding/DriveSubControl.java?view=auto&rev=126629
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/src/drivers/org/apache/beehive/controls/test/driver/binding/DriveSubControl.java
      Thu Jan 27 09:30:42 2005
@@ -0,0 +1,87 @@
+package org.apache.beehive.controls.test.driver.binding;
+
+import org.apache.beehive.test.tools.milton.common.Report;
+import org.apache.beehive.controls.test.controls.binding.SubControl;
+
+/*
+ * Tests specifying control binding on an extended control interface
+ */
+public class DriveSubControl
+{
+       private SubControl myControl1;
+       private SubControl myControl2;
+
+       public void setControl1(SubControl aControl){
+
+               myControl1=aControl;
+       }
+
+       public void setControl2(SubControl aControl){
+
+               myControl2=aControl;
+       }
+
+
+    /**
+     * The subcontrol interface has specified an impl other than the defaul 
impl.
+     * we want to see which impl is instantiated.
+     */
+       public Report doTestBasePropertyOnSubControl(){
+
+               Report report=new Report();
+
+               if (myControl1==null){
+                       report.setStatus(Report.FAIL);
+                       report.setMessage("the control is NULL");
+               }
+               else
+               {
+                       String result=myControl1.hello2();
+
+                       if (result==null){
+                               report.setStatus(Report.FAIL);
+                               report.setMessage("method returns NULL");
+                       }
+                       else if(result.equals("Hello from subcontrolimpl2")){
+                               report.setStatus(Report.PASS);
+                       }
+                       else{
+                               report.setStatus(Report.FAIL);
+                               report.setMessage("The method returns an 
unexected value:"+result);
+                       }
+               }
+               return report;
+       }
+
+
+    /**
+     * Test overwriting the impl specified by SubControl interface
+     */
+       public Report doTestOverwriteByDeclare(){
+
+               Report report=new Report();
+
+               if (myControl2==null){
+                       report.setStatus(Report.FAIL);
+                       report.setMessage("the control is NULL");
+               }
+               else
+               {
+                       String result=myControl2.hello2();
+
+                       if (result==null){
+                               report.setStatus(Report.FAIL);
+                               report.setMessage("method returns NULL");
+                       }
+                       else if(result.equals("Hello from subcontrolimpl")){
+                               report.setStatus(Report.PASS);
+                       }
+                       else{
+                               report.setStatus(Report.FAIL);
+                               report.setMessage("The method returns an 
unexected value:"+result);
+                       }
+               }
+               return report;
+       }
+
+}

Added: 
incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/jws/binding/TestBinding.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/jws/binding/TestBinding.java?view=auto&rev=126629
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/jws/binding/TestBinding.java
       Thu Jan 27 09:30:42 2005
@@ -0,0 +1,34 @@
+package org.apache.beehive.controls.test.jws.binding;
+
+import org.apache.beehive.test.tools.milton.junit.SOAPReportTestCase;
+import org.apache.beehive.test.tools.mantis.annotations.tch.Freq;
+import org.apache.beehive.test.tools.mantis.annotations.tch.Status;
+
+
+
+/**
+ * Tests controls binding on a web app deployed on a Tomcat server
+ */
+public class TestBinding extends SOAPReportTestCase
+{
+       public TestBinding(String s){super(s);}
+
+    /**
+     * Tests an extended control specifying binding
+     */
+       @Freq("detailed")
+    public void testBasePropertyOnSubControl() throws Exception
+    {
+               
assertReport("http://localhost:8080/controlsWeb/jws/Binding.jws","testBasePropertyOnSubControl";);
+    }
+
+    /**
+     * Tests overwriting the impl specified by an extended control interface
+     */
+       @Freq("detailed")
+    public void testOverwriteByDeclare() throws Exception
+    {
+               
assertReport("http://localhost:8080/controlsWeb/jws/Binding.jws","testOverwriteByDeclare";);
+    }
+
+}

Reply via email to