You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2005/08/16 05:53:32 UTC
svn commit: r232928 - in /beehive/trunk/controls/test: ./
src/controls/org/apache/beehive/controls/test/controls/util/
src/units/org/apache/beehive/controls/test/java/composition/
src/units/org/apache/beehive/controls/test/java/context/ src/units/org/a...
Author: ekoneil
Date: Mon Aug 15 20:53:22 2005
New Revision: 232928
URL: http://svn.apache.org/viewcvs?rev=232928&view=rev
Log:
More cleanup in the controls tests.
- fix additional InputStreams leaked when tests fail
- remove .ser files created during object serialization tests
- fix usage targets in build.xml to not repeat target descriptions
BB: self
DRT: Controls checkin / detailed pass
Modified:
beehive/trunk/controls/test/build.xml
beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/util/ControlIntrospector.java
beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/util/SerializeUtils.java
beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/composition/DeclarativeTest.java
beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/context/ContextTest.java
beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/encoding/EncodingTest.java
beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/s13n/DeclarativeTest.java
beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/s13n/Test.java
beehive/trunk/controls/test/webapps/controlsWeb/binding/BindingTests.jpf
beehive/trunk/controls/test/webapps/controlsWeb/composition/Controller.jpf
beehive/trunk/controls/test/webapps/controlsWeb/context/getotherservice/Controller.jpf
beehive/trunk/controls/test/webapps/controlsWeb/context/getotherservice2/Controller.jpf
beehive/trunk/controls/test/webapps/controlsWeb/contextevent/beanrecord/Controller.jpf
beehive/trunk/controls/test/webapps/controlsWeb/contextevent/implrecord/Controller.jpf
beehive/trunk/controls/test/webapps/controlsWeb/contextevent/implrecord2/Controller.jpf
beehive/trunk/controls/test/webapps/controlsWeb/event/listener/Controller.jpf
beehive/trunk/controls/test/webapps/controlsWeb/instantiate/programwithproperty/Controller.jpf
Modified: beehive/trunk/controls/test/build.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/build.xml?rev=232928&r1=232927&r2=232928&view=diff
==============================================================================
--- beehive/trunk/controls/test/build.xml (original)
+++ beehive/trunk/controls/test/build.xml Mon Aug 15 20:53:22 2005
@@ -126,31 +126,6 @@
<!-- the following are needed for axis clients -->
<path refid="webservice.classpath"/>
</path>
-
- <!-- ==================================================================== -->
- <!-- -->
- <!-- -->
- <!-- Usage -->
- <!-- -->
- <!-- -->
- <!-- ==================================================================== -->
-
- <target name="usage">
- <echo message=""/>
- <echo message=""/>
- <echo message="Controls Test Build File"/>
- <echo message="================================================================"/>
- <echo message="| Usage |"/>
- <echo message="================================================================"/>
- <echo message="----------------------------------------------------------------"/>
- <echo message="| Standard Targets |"/>
- <echo message="----------------------------------------------------------------"/>
- <echo message="clean - Delete the junit classes."/>
- <echo message="build - build controls,test drivers and java tests."/>
- <echo message="checkin.tests - run checkin tests, both java and jpf tests."/>
- <echo message="detailed.tests - run detailed tests, both java and jpf tests."/>
- <echo message="----------------------------------------------------------------"/>
- </target>
<!-- ==================================================================== -->
<!-- -->
@@ -160,7 +135,7 @@
<!-- -->
<!-- ==================================================================== -->
- <target name="build" depends="dirs">
+ <target name="build" depends="dirs" description="Build the test controls, drivers, and unit tests">
<antcall target="build-test-auxilaries"/>
<antcall target="build-test-beans"/>
<antcall target="mantis.milton"/>
@@ -169,7 +144,7 @@
<antcall target="mantis.tch"/>
</target>
- <target name="clean">
+ <target name="clean" description="Clean the control tests">
<delete dir="${build.dir}"/>
<delete dir="${mantis.tch.log.dir}"/>
<delete dir="${mantis.tch.cases.dir}"/>
@@ -354,7 +329,9 @@
<target name="drt" depends="checkin.tests"/>
- <target name="checkin.tests">
+ <target name="bvt" depends="detailed.tests"/>
+
+ <target name="checkin.tests" description="Run the Controls checkin tests (DRTs)">
<antcall target="clean"/>
<antcall target="build"/>
<antcall target="run"/>
@@ -365,7 +342,7 @@
<antcall target="run.test"/>
</target>
- <target name="detailed.tests">
+ <target name="detailed.tests" description="Run the Controls detailed tests (BVTs)">
<antcall target="clean"/>
<antcall target="build"/>
Modified: beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/util/ControlIntrospector.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/util/ControlIntrospector.java?rev=232928&r1=232927&r2=232928&view=diff
==============================================================================
--- beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/util/ControlIntrospector.java (original)
+++ beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/util/ControlIntrospector.java Mon Aug 15 20:53:22 2005
@@ -42,7 +42,8 @@
/**
* A utility class for introspecting Control beans
*/
-public class ControlIntrospector {
+public final class ControlIntrospector {
+
private Class _beanClass;
private int _indentLevel = 0;
private PrintWriter _pw;
Modified: beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/util/SerializeUtils.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/util/SerializeUtils.java?rev=232928&r1=232927&r2=232928&view=diff
==============================================================================
--- beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/util/SerializeUtils.java (original)
+++ beehive/trunk/controls/test/src/controls/org/apache/beehive/controls/test/controls/util/SerializeUtils.java Mon Aug 15 20:53:22 2005
@@ -22,13 +22,11 @@
import java.io.ObjectOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
-import java.io.InputStream;
/**
* Utility code for testing serialization behavior
*/
-public class SerializeUtils
-{
+public final class SerializeUtils {
/**
* Serializes an object into a byte array, then deserializes it from the array and returns
* the deserialized object.
Modified: beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/composition/DeclarativeTest.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/composition/DeclarativeTest.java?rev=232928&r1=232927&r2=232928&view=diff
==============================================================================
--- beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/composition/DeclarativeTest.java (original)
+++ beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/composition/DeclarativeTest.java Mon Aug 15 20:53:22 2005
@@ -18,20 +18,21 @@
package org.apache.beehive.controls.test.java.composition;
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
import org.apache.beehive.controls.api.bean.Control;
import org.apache.beehive.controls.api.events.EventHandler;
import org.apache.beehive.controls.test.controls.composition.OuterControl;
import org.apache.beehive.controls.test.controls.composition.OuterControlBean;
import org.apache.beehive.controls.test.controls.composition.InnerControlBean;
import org.apache.beehive.controls.test.controls.util.TestBeanContext;
+
import org.apache.beehive.test.tools.mantis.annotations.tch.Freq;
/**
@@ -43,32 +44,44 @@
* All tests are deactivated until this is supported
*/
@Freq("checkin")
-public class DeclarativeTest extends TestCase implements java.io.Serializable
-{
+public class DeclarativeTest
+ extends TestCase
+ implements java.io.Serializable {
+
+ /**
+ * A control that contains a nested control
+ */
+ @Control
+ private OuterControlBean outerControl;
+
+ private TestBeanContext _testContext;
+
+ private String _reportMsg;
+
// initialize declared controls once
- public DeclarativeTest(String name) throws Exception
- {
+ public DeclarativeTest(String name)
+ throws Exception {
super(name);
}
// begin and end control bean context for each test
- public void setUp() throws Exception
- {
+ public void setUp()
+ throws Exception {
_testContext = createTestBeanContext();
org.apache.beehive.controls.api.bean.Controls.initializeClient( null, this, _testContext );
_testContext.beginContext();
}
- public void tearDown() throws Exception
- {
+ public void tearDown()
+ throws Exception {
_testContext.endContext();
}
/**
* Tests outer control instantiats nested control by declaration
*/
- public void testInstantiation() throws Exception
- {
+ public void testInstantiation()
+ throws Exception {
Assert.assertNotNull(outerControl);
Assert.assertNotNull(outerControl.getDeclaredNestedControl());
Assert.assertNotNull(outerControl.getDeclaredNestedControl2());
@@ -77,8 +90,8 @@
/**
* Tests outer control getting inner control property from control context
*/
- public void testGetPropertyByContext() throws Exception
- {
+ public void testGetPropertyByContext()
+ throws Exception {
Assert.assertNotNull(outerControl);
InnerControlBean innercontrol=outerControl.getDeclaredNestedControl();
Assert.assertNotNull(innercontrol);
@@ -90,8 +103,8 @@
* Tests reconfigured property.
* Outer control reconfigures the inner control's property when instantiating it
*/
- public void testReconfiguredProperty() throws Exception
- {
+ public void testReconfiguredProperty()
+ throws Exception {
Assert.assertNotNull(outerControl);
InnerControlBean innercontrol=outerControl.getDeclaredNestedControl2();
Assert.assertNotNull(innercontrol);
@@ -103,8 +116,8 @@
* Tests outer control receiving events from nested control using
* EventHandler
*/
- public void testEventHandler() throws Exception
- {
+ public void testEventHandler()
+ throws Exception {
Assert.assertNotNull(outerControl);
Assert.assertEquals("0",outerControl.testActivityWakeup());
Assert.assertEquals("0",outerControl.testActivityReadMessage());
@@ -116,8 +129,8 @@
/**
* Tests outer control firing events to us
*/
- public void testOuterEvents() throws Exception
- {
+ public void testOuterEvents()
+ throws Exception {
System.out.println( "_reportMsg=" + _reportMsg );
Assert.assertNotNull(outerControl);
outerControl.fireOuterEvents("this is the reported msg");
@@ -128,50 +141,63 @@
/**
* Tests that control IDS properly represent the composition relationship
*/
- public void testControlIDs() throws Exception
- {
+ public void testControlIDs()
+ throws Exception {
Assert.assertEquals("outerControl", outerControl.getControlID());
Assert.assertEquals("outerControl/innerControl",
outerControl.getDeclaredNestedControl().getControlID());
// Test the relationships and identifiers are preserved across serialization and
// deserialization
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(outerControl);
- oos.close();
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bais);
- OuterControlBean outerCopy = (OuterControlBean)ois.readObject();
+
+ ByteArrayOutputStream baos = null;
+ ObjectOutputStream oos = null;
+ try {
+ baos = new ByteArrayOutputStream();
+ oos = new ObjectOutputStream(baos);
+
+ oos.writeObject(outerControl);
+ oos.close();
+ }
+ finally {
+ if(oos != null)
+ oos.close();
+ if(baos != null)
+ baos.close();
+ }
+
+ ByteArrayInputStream bais = null;
+ ObjectInputStream ois = null;
+ OuterControlBean outerCopy = null;
+ try {
+ bais = new ByteArrayInputStream(baos.toByteArray());
+ ois = new ObjectInputStream(bais);
+ outerCopy = (OuterControlBean)ois.readObject();
+ }
+ finally {
+ if(ois != null)
+ ois.close();
+ if(bais != null)
+ bais.close();
+ }
+
ois.close();
Assert.assertEquals("outerControl", outerCopy.getControlID());
- Assert.assertEquals("outerControl/innerControl",
- outerCopy.getDeclaredNestedControl().getControlID());
+ Assert.assertEquals("outerControl/innerControl", outerCopy.getDeclaredNestedControl().getControlID());
}
- /**
- * A control that contains a nested control
- */
- @Control
- public OuterControlBean outerControl;
-
@EventHandler(field="outerControl", eventSet=OuterControl.OuterEvents.class, eventName="report")
- public int onReport( String msg )
- {
+ public int onReport( String msg ) {
_reportMsg = msg;
return 0;
}
- private String _reportMsg;
-
/**
* Returns a new TestBeanContext to act as a container for control testing.
*/
- private TestBeanContext createTestBeanContext() throws Exception
- {
+ private TestBeanContext createTestBeanContext()
+ throws Exception {
return new TestBeanContext();
}
-
- private TestBeanContext _testContext;
}
Modified: beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/context/ContextTest.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/context/ContextTest.java?rev=232928&r1=232927&r2=232928&view=diff
==============================================================================
--- beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/context/ContextTest.java (original)
+++ beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/context/ContextTest.java Mon Aug 15 20:53:22 2005
@@ -18,15 +18,14 @@
package org.apache.beehive.controls.test.java.context;
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
import java.beans.Beans;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import junit.framework.TestCase;
+
import org.apache.beehive.controls.api.bean.ControlBean;
import org.apache.beehive.controls.test.controls.context.BaseContextBean;
import org.apache.beehive.controls.test.driver.context.BaseContextBeanDriver;
@@ -38,20 +37,19 @@
* A TestCase that tests controls context services
*/
@Freq("checkin")
-public class ContextTest extends TestCase
-{
- public ContextTest( String s ) { super( s ); }
-
- public void setUp() { }
+public class ContextTest
+ extends TestCase {
+ public ContextTest( String s ) {
+ super( s );
+ }
/**
* Creates a new ControlBean instance based upon the specified class name
*/
- private ControlBean createTestBean(String beanClassName) throws Exception
- {
- return (ControlBean)Beans.instantiate(Thread.currentThread().getContextClassLoader(),
- beanClassName);
+ private ControlBean createTestBean(String beanClassName)
+ throws Exception {
+ return (ControlBean)Beans.instantiate(Thread.currentThread().getContextClassLoader(), beanClassName);
}
/**
@@ -59,8 +57,8 @@
*/
public void testContextEventSingle() throws Exception
{
- BaseContextBean contextBean = (BaseContextBean)createTestBean(
- "org.apache.beehive.controls.test.controls.context.BaseContextBean");
+ BaseContextBean contextBean =
+ (BaseContextBean)createTestBean("org.apache.beehive.controls.test.controls.context.BaseContextBean");
BaseContextBeanDriver driver=new BaseContextBeanDriver();
Report report=driver.testSingleBean(contextBean, true);
@@ -78,8 +76,8 @@
*/
public void testContextEventMultiple() throws Exception
{
- BaseContextBean contextBean = (BaseContextBean)createTestBean(
- "org.apache.beehive.controls.test.controls.context.BaseContextBean");
+ BaseContextBean contextBean =
+ (BaseContextBean)createTestBean("org.apache.beehive.controls.test.controls.context.BaseContextBean");
BaseContextBeanDriver driver=new BaseContextBeanDriver();
Report report=driver.testMultipleEvents(contextBean);
@@ -97,10 +95,10 @@
*/
public void testContextEventParallel() throws Exception
{
- BaseContextBean contextBean1 = (BaseContextBean)createTestBean(
- "org.apache.beehive.controls.test.controls.context.BaseContextBean");
- BaseContextBean contextBean2 = (BaseContextBean)createTestBean(
- "org.apache.beehive.controls.test.controls.context.BaseContextBean");
+ BaseContextBean contextBean1 =
+ (BaseContextBean)createTestBean("org.apache.beehive.controls.test.controls.context.BaseContextBean");
+ BaseContextBean contextBean2 =
+ (BaseContextBean)createTestBean("org.apache.beehive.controls.test.controls.context.BaseContextBean");
BaseContextBeanDriver driver=new BaseContextBeanDriver();
Report report=driver.testParallelEvents(contextBean1,contextBean2);
@@ -117,8 +115,8 @@
*/
public void testContextSerialization() throws Exception
{
- BaseContextBean contextBean = (BaseContextBean)createTestBean(
- "org.apache.beehive.controls.test.controls.context.BaseContextBean");
+ BaseContextBean contextBean =
+ (BaseContextBean)createTestBean("org.apache.beehive.controls.test.controls.context.BaseContextBean");
//
// Run the original testContextEventSingle test
@@ -136,20 +134,39 @@
//
// Serialize the test bean into a byte array
//
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(contextBean);
- oos.flush();
- byte [] byteData = baos.toByteArray();
- baos.close();
+ ByteArrayOutputStream baos = null;
+ ObjectOutputStream oos = null;
+ byte[] byteData = null;
+ try {
+ baos = new ByteArrayOutputStream();
+ oos = new ObjectOutputStream(baos);
+ oos.writeObject(contextBean);
+ oos.flush();
+ byteData = baos.toByteArray();
+ }
+ finally {
+ if(baos != null)
+ baos.close();
+ if(oos != null)
+ oos.close();
+ }
//
// Deserialize the test bean from the byte array
//
- ByteArrayInputStream bais = new ByteArrayInputStream(byteData);
- ObjectInputStream ois = new ObjectInputStream(bais);
- contextBean = (BaseContextBean)ois.readObject();
- bais.close();
+ ByteArrayInputStream bais = null;
+ ObjectInputStream ois = null;
+ try {
+ bais = new ByteArrayInputStream(byteData);
+ ois = new ObjectInputStream(bais);
+ contextBean = (BaseContextBean)ois.readObject();
+ }
+ finally {
+ if(bais != null)
+ bais.close();
+ if(ois != null)
+ ois.close();
+ }
//
// Repeat the test again on the deserialized bean. In this instance, the
Modified: beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/encoding/EncodingTest.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/encoding/EncodingTest.java?rev=232928&r1=232927&r2=232928&view=diff
==============================================================================
--- beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/encoding/EncodingTest.java (original)
+++ beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/encoding/EncodingTest.java Mon Aug 15 20:53:22 2005
@@ -36,23 +36,23 @@
* A TestCase that tests encoding/decoding control state to/from XML.
*/
@Freq("checkin")
-public class EncodingTest extends TestCase
-{
+public class EncodingTest
+ extends TestCase {
+
// Set this to true, and the encoding stream will be dumped to System.out as the test
// is run.
- public EncodingTest(String s) { super(s); }
-
- public void setUp() { }
+ public EncodingTest(String s) {
+ super(s);
+ }
/**
* An Exception listener class that will catch encoding/decoding exceptions, dump the
* failure stack, and then flag a test failure.
*/
- private class ExceptionDump implements java.beans.ExceptionListener
- {
- public void exceptionThrown(Exception e)
- {
+ private class ExceptionDump
+ implements java.beans.ExceptionListener {
+ public void exceptionThrown(Exception e) {
e.printStackTrace();
fail();
}
@@ -62,22 +62,43 @@
* Helper method that will take a given object, encode it using XMLEncoder, then decode
* it using XmLMDecoder.
*/
- private <T> T encodeDecode(T obj) throws Exception
- {
+ private <T> T encodeDecode(T obj)
+ throws Exception {
//
// Validate decode ability by running through a decoder
//
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLEncoder encoder = new XMLEncoder(baos);
- encoder.setExceptionListener(new ExceptionDump());
- encoder.writeObject(obj);
- encoder.close();
- baos.flush();
+ ByteArrayOutputStream baos = null;
+ XMLEncoder encoder = null;
+ try {
+ baos = new ByteArrayOutputStream();
+ encoder = new XMLEncoder(baos);
+ encoder.setExceptionListener(new ExceptionDump());
+ encoder.writeObject(obj);
+ baos.flush();
+ }
+ finally {
+ if(encoder != null)
+ encoder.close();
+ if(baos != null)
+ baos.close();
+ }
+
+ ByteArrayInputStream bais = null;
+ XMLDecoder decoder = null;
+ T returnObj = null;
+ try {
+ bais = new ByteArrayInputStream(baos.toByteArray());
+ decoder = new XMLDecoder(bais);
+ decoder.setExceptionListener(new ExceptionDump());
+ returnObj = (T)decoder.readObject();
+ }
+ finally {
+ if(decoder != null)
+ decoder.close();
+ if(bais != null)
+ bais.close();
+ }
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- XMLDecoder decoder = new XMLDecoder(bais);
- decoder.setExceptionListener(new ExceptionDump());
- T returnObj = (T)decoder.readObject();
bais.close();
return returnObj;
}
Modified: beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/s13n/DeclarativeTest.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/s13n/DeclarativeTest.java?rev=232928&r1=232927&r2=232928&view=diff
==============================================================================
--- beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/s13n/DeclarativeTest.java (original)
+++ beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/s13n/DeclarativeTest.java Mon Aug 15 20:53:22 2005
@@ -18,58 +18,58 @@
package org.apache.beehive.controls.test.java.s13n;
-import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.FileInputStream;
+import java.io.File;
+
import junit.framework.Assert;
import junit.framework.TestCase;
+
import org.apache.beehive.controls.api.bean.Control;
-import org.apache.beehive.controls.test.controls.serialization.HelloControl;
import org.apache.beehive.controls.test.controls.serialization.HelloControlBean;
+import org.apache.beehive.controls.test.controls.util.TestBeanContext;
import org.apache.beehive.test.tools.mantis.annotations.tch.Freq;
-import org.apache.beehive.controls.test.controls.util.TestBeanContext;
-
/**
* Test serialization of a controls instantiated declaratively
*/
@Freq("detailed")
-public class DeclarativeTest extends TestCase
-{
+public class DeclarativeTest
+ extends TestCase {
+
+ private static final String FILE_NAME_SERIALIZED = "objects2.ser";
private TestBeanContext _testContext;
- /**
- * A simple control with one method, no property declared
- */
+ /** A simple control with one method, no property declared */
@Control
private HelloControlBean myHelloBean;
- public DeclarativeTest(String name) throws Exception
- {
+ public DeclarativeTest(String name)
+ throws Exception {
super(name);
_testContext = new TestBeanContext();
org.apache.beehive.controls.api.bean.Controls.initializeClient( null, this, _testContext );
}
- public void setUp() throws Exception
- {
+ public void setUp()
+ throws Exception {
_testContext.beginContext();
}
- public void tearDown() throws Exception
- {
+ public void tearDown()
+ throws Exception {
_testContext.endContext();
}
//End of unique client programming to instantiate controls declaratively in java container
-
- public void testWriteRead() throws Exception
- {
+ public void testWriteRead()
+ throws Exception {
myHelloBean.setQuantity(100);
myHelloBean.setName("TheName");
myHelloBean.changeTransient("A different value");
@@ -77,7 +77,7 @@
FileOutputStream fos=null;
ObjectOutputStream oos =null;
try{
- fos = new FileOutputStream("objects2.ser");
+ fos = new FileOutputStream(FILE_NAME_SERIALIZED);
oos = new ObjectOutputStream( fos );
oos.writeObject(myHelloBean);
}
@@ -93,9 +93,8 @@
//To read them back in, reverse the process with:
FileInputStream fis =null;
ObjectInputStream ois =null;
-
try{
- fis = new FileInputStream( "objects2.ser");
+ fis = new FileInputStream(FILE_NAME_SERIALIZED);
ois = new ObjectInputStream( fis );
HelloControlBean hc2 = (HelloControlBean)ois.readObject();
@@ -106,7 +105,6 @@
Assert.assertEquals(100,qty);
Assert.assertEquals("TheName",name);
Assert.assertEquals(null,theTransient);
-
}
catch(IOException e){
e.printStackTrace();
@@ -116,5 +114,10 @@
if(ois != null) ois.close();
if(fis != null) fis.close();
}
+
+ /* remove temporary file */
+ /* todo: this should be written into the java.io.temp directory */
+ File deleteMe = new File(FILE_NAME_SERIALIZED);
+ deleteMe.delete();
}
}
Modified: beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/s13n/Test.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/s13n/Test.java?rev=232928&r1=232927&r2=232928&view=diff
==============================================================================
--- beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/s13n/Test.java (original)
+++ beehive/trunk/controls/test/src/units/org/apache/beehive/controls/test/java/s13n/Test.java Mon Aug 15 20:53:22 2005
@@ -15,18 +15,18 @@
*
* $Header:$
*/
-
package org.apache.beehive.controls.test.java.s13n;
-import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.ObjectInputStream;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.File;
+
import junit.framework.Assert;
import junit.framework.TestCase;
-import org.apache.beehive.controls.api.bean.Control;
-import org.apache.beehive.controls.test.controls.serialization.HelloControl;
+
import org.apache.beehive.controls.test.controls.serialization.HelloControlBean;
import org.apache.beehive.test.tools.mantis.annotations.tch.Freq;
@@ -34,28 +34,32 @@
* Test serialization of a control instantiated programmatically.
*/
@Freq("detailed")
-public class Test extends TestCase
-{
+public class Test
+ extends TestCase {
+
+ private static final String FILE_NAME_SERIALIZED = "objects.ser";
+
// initialize declared controls once
- public Test(String name) throws Exception
- {
+ public Test(String name)
+ throws Exception {
super(name);
}
- public void testWriteRead() throws Exception
- {
- HelloControlBean hc=(HelloControlBean)java.beans.Beans.instantiate(
- Thread.currentThread().getContextClassLoader() ,
- "org.apache.beehive.controls.test.controls.serialization.HelloControlBean");
-
- hc.setQuantity(100);
- hc.setName("TheName");
- hc.changeTransient("A different value");
+ public void testWriteRead()
+ throws Exception {
- FileOutputStream fos = null;
+ HelloControlBean hc=(HelloControlBean)java.beans.Beans.instantiate(
+ Thread.currentThread().getContextClassLoader() ,
+ "org.apache.beehive.controls.test.controls.serialization.HelloControlBean");
+
+ hc.setQuantity(100);
+ hc.setName("TheName");
+ hc.changeTransient("A different value");
+
+ FileOutputStream fos = null;
ObjectOutputStream oos = null;
try{
- fos = new FileOutputStream("objects.ser");
+ fos = new FileOutputStream(FILE_NAME_SERIALIZED);
oos = new ObjectOutputStream( fos );
oos.writeObject(hc);
}
@@ -72,7 +76,7 @@
ObjectInputStream ois = null;
try {
//To read them back in, reverse the process with:
- fis = new FileInputStream( "objects.ser");
+ fis = new FileInputStream(FILE_NAME_SERIALIZED);
ois = new ObjectInputStream( fis );
HelloControlBean hc2 = (HelloControlBean)ois.readObject();
@@ -92,5 +96,8 @@
if(ois != null) ois.close();
if(fis != null) fis.close();
}
+
+ File deleteMe = new File(FILE_NAME_SERIALIZED);
+ deleteMe.delete();
}
}
Modified: beehive/trunk/controls/test/webapps/controlsWeb/binding/BindingTests.jpf
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/webapps/controlsWeb/binding/BindingTests.jpf?rev=232928&r1=232927&r2=232928&view=diff
==============================================================================
--- beehive/trunk/controls/test/webapps/controlsWeb/binding/BindingTests.jpf (original)
+++ beehive/trunk/controls/test/webapps/controlsWeb/binding/BindingTests.jpf Mon Aug 15 20:53:22 2005
@@ -23,9 +23,7 @@
import org.apache.beehive.netui.pageflow.annotations.Jpf;
import org.apache.beehive.controls.api.bean.Control;
-import org.apache.beehive.controls.api.bean.ControlBean;
import org.apache.beehive.controls.api.properties.BaseProperties;
-
import org.apache.beehive.controls.test.controls.binding.BindingTestControl;
import org.apache.beehive.controls.test.controls.binding.DefaultBindingTestControl;
import org.apache.beehive.controls.test.controls.binding.ExternalBindingTestControl;
@@ -37,8 +35,8 @@
@Jpf.Forward(name=Report.RESULTS,path = Report.RESULTSJSP)
}
)
-public class BindingTests extends PageFlowController
-{
+public class BindingTests
+ extends PageFlowController {
@Control
@BaseProperties( controlImplementation="org.apache.beehive.controls.test.controls.binding.BindingTestControlOverrideImpl" )
@@ -51,30 +49,25 @@
public ExternalBindingTestControl ebtc;
@Jpf.Action
- protected Forward begin()
- {
- return new Forward(Report.RESULTS, Report.KEY, new
- Report(Report.ABORT,"begin() is not a test method!"));
+ protected Forward begin() {
+ return new Forward(Report.RESULTS, Report.KEY, new Report(Report.ABORT,"begin() is not a test method!"));
}
@Jpf.Action
- protected Forward testBindingOverride()
- {
- return new Forward(Report.RESULTS, Report.KEY, new
- Report(btc.getStatus()));
+ protected Forward testBindingOverride() {
+ return new Forward(Report.RESULTS, Report.KEY, new
+ Report(btc.getStatus()));
}
@Jpf.Action
- protected Forward testDefaultBinding()
- {
- return new Forward(Report.RESULTS, Report.KEY, new
- Report(dbtc.getStatus()));
+ protected Forward testDefaultBinding() {
+ return new Forward(Report.RESULTS, Report.KEY, new
+ Report(dbtc.getStatus()));
}
@Jpf.Action
- protected Forward testExternalBinding()
- {
- return new Forward(Report.RESULTS, Report.KEY, new
- Report(ebtc.getStatus()));
+ protected Forward testExternalBinding() {
+ return new Forward(Report.RESULTS, Report.KEY, new
+ Report(ebtc.getStatus()));
}
}
Modified: beehive/trunk/controls/test/webapps/controlsWeb/composition/Controller.jpf
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/webapps/controlsWeb/composition/Controller.jpf?rev=232928&r1=232927&r2=232928&view=diff
==============================================================================
--- beehive/trunk/controls/test/webapps/controlsWeb/composition/Controller.jpf (original)
+++ beehive/trunk/controls/test/webapps/controlsWeb/composition/Controller.jpf Mon Aug 15 20:53:22 2005
@@ -23,7 +23,6 @@
import org.apache.beehive.netui.pageflow.annotations.Jpf;
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.driver.composition.DriveOuterControl;
import org.apache.beehive.test.tools.milton.common.Report;
@@ -34,36 +33,31 @@
forwards = {
@Jpf.Forward(name=Report.RESULTS,path = Report.RESULTSJSP)
})
-public class Controller extends PageFlowController
-{
+public class Controller
+ extends PageFlowController {
@Control
public OuterControlBean outercontrol;
- @Jpf.Action(
- )
- protected Forward begin(){
-
- Report report =new Report();
- report.setStatus(Report.PASS);
- report.setMessage("This is a bogus test.");
-
+ @Jpf.Action()
+ protected Forward begin() {
+ Report report =new Report();
+ report.setStatus(Report.PASS);
+ report.setMessage("This is a bogus test.");
+
return new Forward(Report.RESULTS, Report.KEY, report);
}
/*
- * Verifies the instantiation of nested controls.
- * The outer control is instantiated declaratively.
- */
- @Jpf.Action(
- )
+ * Verifies the instantiation of nested controls.
+ * The outer control is instantiated declaratively.
+ */
+ @Jpf.Action()
protected Forward testInstantiation(){
-
- DriveOuterControl driver=new DriveOuterControl();
- driver.setControl(outercontrol);
- Report report=driver.doTestInstantiate();
-
+ DriveOuterControl driver=new DriveOuterControl();
+ driver.setControl(outercontrol);
+ Report report=driver.doTestInstantiate();
return new Forward(Report.RESULTS, Report.KEY, report);
}
@@ -71,27 +65,25 @@
* Verifies the instantiation of nested controls.
* The outer control is instantiated programmatically.
*/
- @Jpf.Action(
- )
+ @Jpf.Action()
protected Forward testInstantiationP(){
+ DriveOuterControl driver=new DriveOuterControl();
- DriveOuterControl driver=new DriveOuterControl();
-
- Report report=new Report();
- try{
- OuterControlBean outerbean=(OuterControlBean)java.beans.Beans.instantiate(
- Thread.currentThread().getContextClassLoader() ,
- "org.apache.beehive.controls.test.controls.composition.OuterControlBean");
- driver.setControl(outerbean);
- report=driver.doTestInstantiate();
+ Report report=new Report();
+ try{
+ OuterControlBean outerbean=(OuterControlBean)java.beans.Beans.instantiate(
+ Thread.currentThread().getContextClassLoader() ,
+ "org.apache.beehive.controls.test.controls.composition.OuterControlBean");
+ driver.setControl(outerbean);
+ report=driver.doTestInstantiate();
}
catch(Exception e){
-
- report.setStatus(Report.FAIL);
- report.setExceptionStack(e);
+
+ report.setStatus(Report.FAIL);
+ report.setExceptionStack(e);
}
-
+
return new Forward(Report.RESULTS, Report.KEY, report);
}
Modified: beehive/trunk/controls/test/webapps/controlsWeb/context/getotherservice/Controller.jpf
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/webapps/controlsWeb/context/getotherservice/Controller.jpf?rev=232928&r1=232927&r2=232928&view=diff
==============================================================================
--- beehive/trunk/controls/test/webapps/controlsWeb/context/getotherservice/Controller.jpf (original)
+++ beehive/trunk/controls/test/webapps/controlsWeb/context/getotherservice/Controller.jpf Mon Aug 15 20:53:22 2005
@@ -23,7 +23,6 @@
import org.apache.beehive.netui.pageflow.annotations.Jpf;
import org.apache.beehive.controls.api.bean.Control;
-import org.apache.beehive.controls.api.bean.ControlBean;
import org.apache.beehive.controls.test.controls.context.ServiceGetterBean;
import org.apache.beehive.controls.test.driver.context.DriveServiceGetter;
import org.apache.beehive.test.tools.milton.common.Report;
@@ -36,24 +35,19 @@
forwards = {
@Jpf.Forward(name=Report.RESULTS,path = Report.RESULTSJSP)
})
-public class Controller extends PageFlowController
-{
-
+public class Controller
+ extends PageFlowController {
@Control
public ServiceGetterBean serviceGetter;
- /**
- * @jpf:action
- */
- @Jpf.Action(
- )
+ @Jpf.Action()
protected Forward begin(){
- DriveServiceGetter driver=new DriveServiceGetter();
- driver.setControl(serviceGetter);
- driver.setTestEnv(true,true,false);
- Report report=driver.doTest();
-
+ DriveServiceGetter driver=new DriveServiceGetter();
+ driver.setControl(serviceGetter);
+ driver.setTestEnv(true,true,false);
+ Report report=driver.doTest();
+
return new Forward(Report.RESULTS, Report.KEY, report);
}
Modified: beehive/trunk/controls/test/webapps/controlsWeb/context/getotherservice2/Controller.jpf
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/webapps/controlsWeb/context/getotherservice2/Controller.jpf?rev=232928&r1=232927&r2=232928&view=diff
==============================================================================
--- beehive/trunk/controls/test/webapps/controlsWeb/context/getotherservice2/Controller.jpf (original)
+++ beehive/trunk/controls/test/webapps/controlsWeb/context/getotherservice2/Controller.jpf Mon Aug 15 20:53:22 2005
@@ -36,14 +36,10 @@
forwards = {
@Jpf.Forward(name=Report.RESULTS,path = Report.RESULTSJSP)
})
-public class Controller extends PageFlowController
-{
+public class Controller
+ extends PageFlowController {
- /**
- * @jpf:action
- */
- @Jpf.Action(
- )
+ @Jpf.Action()
protected Forward begin(){
Report report=new Report();
@@ -62,9 +58,7 @@
report.setExceptionStack(e);
}
return new Forward(Report.RESULTS, Report.KEY, report);
-
}
-
}
Modified: beehive/trunk/controls/test/webapps/controlsWeb/contextevent/beanrecord/Controller.jpf
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/webapps/controlsWeb/contextevent/beanrecord/Controller.jpf?rev=232928&r1=232927&r2=232928&view=diff
==============================================================================
--- beehive/trunk/controls/test/webapps/controlsWeb/contextevent/beanrecord/Controller.jpf (original)
+++ beehive/trunk/controls/test/webapps/controlsWeb/contextevent/beanrecord/Controller.jpf Mon Aug 15 20:53:22 2005
@@ -37,17 +37,13 @@
forwards = {
@Jpf.Forward(name=Report.RESULTS,path = Report.RESULTSJSP)
})
-public class Controller extends PageFlowController
-{
+public class Controller
+ extends PageFlowController {
@Control
public RecorderBean recorder;
-
- /**
- * @jpf:action
- */
- @Jpf.Action(
- )
+
+ @Jpf.Action()
protected Forward begin(){
DriveBeanRecorder driver=new DriveBeanRecorder();
@@ -66,7 +62,6 @@
return new Forward(Report.RESULTS, Report.KEY, report);
}
-
}
Modified: beehive/trunk/controls/test/webapps/controlsWeb/contextevent/implrecord/Controller.jpf
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/webapps/controlsWeb/contextevent/implrecord/Controller.jpf?rev=232928&r1=232927&r2=232928&view=diff
==============================================================================
--- beehive/trunk/controls/test/webapps/controlsWeb/contextevent/implrecord/Controller.jpf (original)
+++ beehive/trunk/controls/test/webapps/controlsWeb/contextevent/implrecord/Controller.jpf Mon Aug 15 20:53:22 2005
@@ -37,23 +37,18 @@
forwards = {
@Jpf.Forward(name=Report.RESULTS,path = Report.RESULTSJSP)
})
-public class Controller extends PageFlowController
-{
+public class Controller
+ extends PageFlowController {
@Control
public RecorderBean recorder;
-
- /**
- * @jpf:action
- */
- @Jpf.Action(
- )
+
+ @Jpf.Action()
protected Forward begin(){
-
- DriveRecorder driver=new DriveRecorder();
- driver.setControl(recorder);
- Report report=driver.doTest();
-
+ DriveRecorder driver=new DriveRecorder();
+ driver.setControl(recorder);
+ Report report=driver.doTest();
+
return new Forward(Report.RESULTS, Report.KEY, report);
}
Modified: beehive/trunk/controls/test/webapps/controlsWeb/contextevent/implrecord2/Controller.jpf
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/webapps/controlsWeb/contextevent/implrecord2/Controller.jpf?rev=232928&r1=232927&r2=232928&view=diff
==============================================================================
--- beehive/trunk/controls/test/webapps/controlsWeb/contextevent/implrecord2/Controller.jpf (original)
+++ beehive/trunk/controls/test/webapps/controlsWeb/contextevent/implrecord2/Controller.jpf Mon Aug 15 20:53:22 2005
@@ -37,33 +37,26 @@
forwards = {
@Jpf.Forward(name=Report.RESULTS,path = Report.RESULTSJSP)
})
-public class Controller extends PageFlowController
-{
-
- /**
- * @jpf:action
- */
- @Jpf.Action(
- )
+public class Controller
+ extends PageFlowController {
+ @Jpf.Action()
protected Forward begin(){
- Report report =new Report();
- DriveRecorder driver=new DriveRecorder();
+ Report report =new Report();
+ DriveRecorder driver=new DriveRecorder();
- try{
- RecorderBean recorder=(RecorderBean)java.beans.Beans.instantiate(
- Thread.currentThread().getContextClassLoader() ,
- "org.apache.beehive.controls.test.controls.contextevent.RecorderBean");
- driver.setControl(recorder);
- report=driver.doTest();
- }
- catch(Exception e){
-
- report.setStatus(Report.FAIL);
- report.setExceptionStack(e);
- }
- return new Forward(Report.RESULTS, Report.KEY, report);
-
+ try{
+ RecorderBean recorder=(RecorderBean)java.beans.Beans.instantiate(
+ Thread.currentThread().getContextClassLoader() ,
+ "org.apache.beehive.controls.test.controls.contextevent.RecorderBean");
+ driver.setControl(recorder);
+ report=driver.doTest();
+ }
+ catch(Exception e){
+ report.setStatus(Report.FAIL);
+ report.setExceptionStack(e);
+ }
+ return new Forward(Report.RESULTS, Report.KEY, report);
}
}
Modified: beehive/trunk/controls/test/webapps/controlsWeb/event/listener/Controller.jpf
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/webapps/controlsWeb/event/listener/Controller.jpf?rev=232928&r1=232927&r2=232928&view=diff
==============================================================================
--- beehive/trunk/controls/test/webapps/controlsWeb/event/listener/Controller.jpf (original)
+++ beehive/trunk/controls/test/webapps/controlsWeb/event/listener/Controller.jpf Mon Aug 15 20:53:22 2005
@@ -23,7 +23,6 @@
import org.apache.beehive.netui.pageflow.annotations.Jpf;
import org.apache.beehive.controls.api.bean.Control;
-import org.apache.beehive.controls.api.bean.ControlBean;
import org.apache.beehive.controls.test.controls.event.HelloBean;
import org.apache.beehive.controls.test.driver.event.DriveListener;
import org.apache.beehive.test.tools.milton.common.Report;
@@ -36,17 +35,13 @@
forwards = {
@Jpf.Forward(name=Report.RESULTS,path = Report.RESULTSJSP)
})
-public class Controller extends PageFlowController
-{
+public class Controller
+ extends PageFlowController {
@Control
public HelloBean hello;
- /**
- * @jpf:action
- */
- @Jpf.Action(
- )
+ @Jpf.Action()
protected Forward begin(){
DriveListener driver=new DriveListener();
Modified: beehive/trunk/controls/test/webapps/controlsWeb/instantiate/programwithproperty/Controller.jpf
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/webapps/controlsWeb/instantiate/programwithproperty/Controller.jpf?rev=232928&r1=232927&r2=232928&view=diff
==============================================================================
--- beehive/trunk/controls/test/webapps/controlsWeb/instantiate/programwithproperty/Controller.jpf (original)
+++ beehive/trunk/controls/test/webapps/controlsWeb/instantiate/programwithproperty/Controller.jpf Mon Aug 15 20:53:22 2005
@@ -22,13 +22,12 @@
import org.apache.beehive.netui.pageflow.FormData;
import org.apache.beehive.netui.pageflow.annotations.Jpf;
-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.api.properties.BeanPropertyMap;
import org.apache.beehive.controls.test.controls.property.SingleProperty;
import org.apache.beehive.controls.test.controls.property.SinglePropertyBean;
import org.apache.beehive.controls.test.driver.instantiate.DriveSingleProperty;
+
import org.apache.beehive.test.tools.milton.common.Report;
/* Instantiate a custom control programmatically with property*/
@@ -37,36 +36,31 @@
forwards = {
@Jpf.Forward(name=Report.RESULTS,path = Report.RESULTSJSP)
})
-public class Controller extends PageFlowController
-{
-
- /**
- * @jpf:action
- */
- @Jpf.Action(
- )
+public class Controller
+ extends PageFlowController {
+
+ @Jpf.Action()
protected Forward begin(){
- Report report=new Report();
- try{
- BeanPropertyMap greetAttr = new BeanPropertyMap(SingleProperty.Greeting.class);
- greetAttr.setProperty(SinglePropertyBean.GreetWordKey,"Good afternoon!");
- SinglePropertyBean spbean = (SinglePropertyBean)Controls.instantiate(
- Thread.currentThread().getContextClassLoader(),
- "org.apache.beehive.controls.test.controls.property.SinglePropertyBean",
- greetAttr);
+ Report report=new Report();
+ try{
+ BeanPropertyMap greetAttr = new BeanPropertyMap(SingleProperty.Greeting.class);
+ greetAttr.setProperty(SinglePropertyBean.GreetWordKey,"Good afternoon!");
+ SinglePropertyBean spbean = (SinglePropertyBean)Controls.instantiate(
+ Thread.currentThread().getContextClassLoader(),
+ "org.apache.beehive.controls.test.controls.property.SinglePropertyBean",
+ greetAttr);
- DriveSingleProperty driver=new DriveSingleProperty();
- driver.setControl(spbean);
- report=driver.doTestReconfiguredProperty("Good afternoon!");
- }
- catch(Exception e){
- report.setStatus(Report.FAIL);
- report.setExceptionStack(e);
- }
+ DriveSingleProperty driver=new DriveSingleProperty();
+ driver.setControl(spbean);
+ report=driver.doTestReconfiguredProperty("Good afternoon!");
+ }
+ catch(Exception e){
+ report.setStatus(Report.FAIL);
+ report.setExceptionStack(e);
+ }
return new Forward(Report.RESULTS, Report.KEY, report);
}
-
}