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 2005/05/25 23:29:42 UTC

svn commit: r178535 - in /incubator/beehive/trunk/controls/test/src: controls/org/apache/beehive/controls/test/controls/overload/ units/org/apache/beehive/controls/test/java/overload/

Author: jsong
Date: Wed May 25 14:29:41 2005
New Revision: 178535

URL: http://svn.apache.org/viewcvs?rev=178535&view=rev
Log:
Add a detailed test to test invoking overloaded methods on controls.
beehive drt passed.


Added:
    incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/overload/
    incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/overload/HelloControl.java
    incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/overload/HelloControlImpl.jcs
    incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/overload/
    incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/overload/TestHello.java

Added: incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/overload/HelloControl.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/overload/HelloControl.java?rev=178535&view=auto
==============================================================================
--- incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/overload/HelloControl.java (added)
+++ incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/overload/HelloControl.java Wed May 25 14:29:41 2005
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+
+package org.apache.beehive.controls.test.controls.overload;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+
+/**
+ * A control interface with overloaded methods.
+ */
+
+@ControlInterface
+public interface HelloControl
+{
+    public String hello(String input);
+    public String hello(int i);
+    public String hello(boolean[] booleans);
+}

Added: incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/overload/HelloControlImpl.jcs
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/overload/HelloControlImpl.jcs?rev=178535&view=auto
==============================================================================
--- incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/overload/HelloControlImpl.jcs (added)
+++ incubator/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/overload/HelloControlImpl.jcs Wed May 25 14:29:41 2005
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+ 
+package org.apache.beehive.controls.test.controls.overload;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+
+/**
+ * A control impl with overloaded methods
+ */
+@ControlImplementation(isTransient=true)
+public class HelloControlImpl implements HelloControl
+{
+    public String hello(String input)
+    {
+		return input;
+    }
+
+    public String hello(int i)
+    {
+		return String.valueOf(i);
+    }
+
+    public String hello(boolean[] booleans)
+    {
+    	String result=null;
+    	if (booleans.length>0){
+    		result="";
+    		for(int i=0;i<booleans.length;i++){
+    			result=result+String.valueOf(booleans[i]);
+    		}
+    	}
+		return result;
+    }
+    
+}

Added: incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/overload/TestHello.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/overload/TestHello.java?rev=178535&view=auto
==============================================================================
--- incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/overload/TestHello.java (added)
+++ incubator/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/overload/TestHello.java Wed May 25 14:29:41 2005
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.controls.test.java.overload;
+
+import junit.framework.TestCase;
+import java.beans.Beans;
+import java.lang.Integer;
+import org.apache.beehive.controls.api.bean.Control;
+import org.apache.beehive.controls.api.bean.Controls;
+import org.apache.beehive.controls.api.bean.ControlBean;
+import org.apache.beehive.controls.test.controls.overload.HelloControlBean;
+import org.apache.beehive.test.tools.mantis.annotations.tch.Freq;
+import org.apache.beehive.test.tools.mantis.annotations.tch.Status;
+import org.apache.beehive.test.tools.milton.common.Report;
+
+import org.apache.beehive.controls.test.controls.util.TestBeanContext;
+
+
+/**
+ * Test invoking overloaded methods on controls
+ */
+public class TestHello extends TestCase
+{
+
+    //Start of unique client programming to instantiate controls declaratively in java container
+    private TestBeanContext _testContext;
+
+    public TestHello(String s)throws Exception {
+
+		super(s);
+    	_testContext = new TestBeanContext();
+        org.apache.beehive.controls.api.bean.Controls.initializeClient( null, this, _testContext );
+
+	}
+
+    public void setUp() throws Exception
+    {
+        _testContext.beginContext();
+    }
+
+    public void tearDown() throws Exception
+    {
+        _testContext.endContext();
+    }
+	//End of unique client programming to instantiate controls declaratively in java container
+
+
+	/**
+	 * A control with overloaded methods
+	 */
+    @Control
+    private HelloControlBean myHelloBean;
+
+    /**
+     * Tests invoking overloaded methods on a control
+     */
+	@Freq("detailed")
+    public void testOverload() throws Exception
+    {
+		String strResult=myHelloBean.hello("Good moring");
+		if (!strResult.equals("Good moring"))
+			fail("Inocking first method fails. returned value:"+strResult);
+		String strResult2=myHelloBean.hello(99);
+		if (!strResult2.equals(String.valueOf(99)))
+			fail("Inocking second method fails. returned value:"+strResult2);
+		boolean bytes[]={true,false,true,false};
+		String strResult3=myHelloBean.hello(bytes);
+		if (!strResult3.equals("truefalsetruefalse"))
+			fail("Inocking third method fails. returned value:"+strResult3);
+    }
+}