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 2006/05/13 15:14:56 UTC

svn commit: r406090 [4/10] - in /beehive/trunk: ./ ant/ controls/ controls/src/ controls/src/api/org/apache/beehive/controls/api/context/ controls/src/api/org/apache/beehive/controls/api/events/ controls/src/api/org/apache/beehive/controls/api/packagin...

Modified: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/composition/OuterControlImpl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/composition/OuterControlImpl.java?rev=406090&r1=406089&r2=406090&view=diff
==============================================================================
--- beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/composition/OuterControlImpl.java (original)
+++ beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/composition/OuterControlImpl.java Sat May 13 06:14:42 2006
@@ -1,501 +1,501 @@
-/*
- * 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.composition;
-
-import org.apache.beehive.controls.api.bean.ControlImplementation;
-import org.apache.beehive.controls.api.bean.Control;
-import org.apache.beehive.controls.api.events.Client;
-import org.apache.beehive.controls.api.events.EventHandler;
-import org.apache.beehive.controls.api.properties.BeanPropertyMap;
-
-/**
- * A control implementation to test control composition.  Makes two instances of nested control be declaration.
- */
-@ControlImplementation
-public class OuterControlImpl
-    implements OuterControl, java.io.Serializable {
-
-    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;
-
-    @Client
-    transient OuterEvents outerEvents;
-
-    /*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) {
-        innerControlEventHandlerDoStuff = EVENT_RECEIVED;
-    }
-
-    @EventHandler(field = "innerControl2", eventSet = InnerControl.Activity.class, eventName = "wakeup")
-    public void innerControl2wakeup() {
-    }
-
-    @EventHandler(field = "innerControl2", eventSet = InnerControl.Activity.class, eventName = "readMessage")
-    public int innerControl2readMessage(String message) {
-        return 0;
-    }
-
-    @EventHandler(field = "innerControl2", eventSet = InnerControl.Activity.class, eventName = "report")
-    public String innerControl2report() {
-        return "a report";
-    }
-
-    @EventHandler(field = "innerControl2", eventSet = InnerControl.Action.class, eventName = "shopping")
-    public Object [] innerControl2shopping(double credit) {
-        return null;
-    }
-
-    @EventHandler(field = "innerControl2", eventSet = InnerControl.Action.class, eventName = "doStuff")
-    public void innerControl2doStuff(String vakue) {
-    }
-
-    public void fireOuterEvents(String message) {
-        outerEvents.report(message);
-    }
-
-    public InnerControlBean getDeclaredNestedControl() {
-        return innerControl;
-    }
-
-    public InnerControlBean getDeclaredNestedControl2() {
-        return innerControl2;
-    }
-
-    public InnerControlBean instantiateNestedControlProgrammatically() {
-        try {
-            InnerControlBean inner =
-                (InnerControlBean) java.beans.Beans.instantiate(Thread.currentThread().getContextClassLoader(),
-                    "org.apache.beehive.controls.test.controls.composition.InnerControlBean");
-            return inner;
-        }
-        catch (Exception e) {
-            return null;
-        }
-    }
-
-    public InnerControlBean instantiateNestedControlWithProperty() {
-        try {
-            BeanPropertyMap props = new BeanPropertyMap(InnerControl.Identity.class);
-            props.setProperty(InnerControlBean.NameKey, "ken");
-            props.setProperty(InnerControlBean.JobKey, "engineer");
-            props.setProperty(InnerControlBean.RankKey, new Integer(2));
-            InnerControlBean inner = (InnerControlBean) org.apache.beehive.controls.api.bean.Controls.instantiate(
-                Thread.currentThread().getContextClassLoader(),
-                "org.apache.beehive.controls.test.controls.composition.InnerControlBean", props);
-            return inner;
-        }
-        catch (Exception e) {
-            throw new RuntimeException("Failed to instantiate nested control", e);
-        }
-    }
-
-    public String testActivityWakeup() {
-
-        String result = "";
-        if (innerControl == null)
-            result = "inner control is NULL";
-        else {
-            innerControl.fireEvent("Activity", "wakeup");
-            /*Wait for the events*/
-            try {
-                Thread.sleep(1000);
-                if (innerControlEventHandlerWakeUp.equals(EVENT_RECEIVED))
-                    result = "0";
-                else
-                    result = "Acivity.wakeup not received by EventHandler";
-            }
-            catch (Exception e) {
-                result = "Thread sleep interrupted." + e.toString();
-            }
-        }
-        return result;
-    }
-
-    public String testActivityReadMessage() {
-
-        String result = "";
-        if (innerControl == null)
-            result = "inner control is NULL";
-        else {
-            innerControl.fireEvent("Activity", "readMessage");
-            /*Wait for the events*/
-            try {
-                Thread.sleep(1000);
-
-                if (innerControlEventHandlerReadMessage.equals(EVENT_RECEIVED))
-                    result = "0";
-                else
-                    result = "Acivity.readMessage not received by EventHandler";
-            }
-            catch (Exception e) {
-                result = "Thread sleep interrupted." + e.toString();
-            }
-        }
-        return result;
-
-    }
-
-    public String testActivityReport() {
-
-        String result = "";
-        if (innerControl == null)
-            result = "inner control is NULL";
-        else {
-            innerControl.fireEvent("Activity", "report");
-            /*Wait for the events*/
-            try {
-                Thread.sleep(1000);
-
-                if (innerControlEventHandlerReport.equals(EVENT_RECEIVED))
-                    result = "0";
-                else
-                    result = "Acivity.report not received by EventHandler";
-            }
-            catch (Exception e) {
-                result = "Thread sleep interrupted." + e.toString();
-            }
-        }
-        return result;
-
-    }
-
-    public String testActionShopping() {
-
-        String result = "";
-        if (innerControl == null)
-            result = "inner control is NULL";
-        else {
-            innerControl.fireEvent("Action", "shopping");
-            /*Wait for the events*/
-            try {
-                Thread.sleep(1000);
-
-                if (innerControlEventHandlerShopping.equals(EVENT_RECEIVED))
-                    result = "0";
-                else
-                    result = "Action.shopping not received by EventHandler";
-            }
-            catch (Exception e) {
-                result = "Thread sleep interrupted." + e.toString();
-            }
-        }
-        return result;
-
-    }
-
-    public String testActionDostuff() {
-
-        String result = "";
-        if (innerControl == null)
-            result = "inner control is NULL";
-        else {
-            innerControl.fireEvent("Action", "doStuff");
-            /*Wait for the events*/
-            try {
-                Thread.sleep(1000);
-
-                if (innerControlEventHandlerDoStuff.equals(EVENT_RECEIVED))
-                    result = "0";
-                else
-                    result = "Action.doStuff not received by EventHandler";
-            }
-            catch (Exception e) {
-                result = "Thread sleep interrupted." + e.toString();
-            }
-        }
-        return result;
-
-    }
-
-    /*Tests outer control receiving event from nested control using
-     * event listener. The nested control is instantiated programmatically
-     */
-    public String testEventListener() {
-
-        String result = "init";
-        try {
-
-            InnerControlBean nested = (InnerControlBean) java.beans.Beans.instantiate(
-                Thread.currentThread().getContextClassLoader(),
-                "org.apache.beehive.controls.test.controls.composition.InnerControlBean");
-            if (nested == null)
-                result = "Nested control instantiated programmatically is NULL.";
-            else {
-                //Create an Event Listener
-                InnerControlEventListener listener = new InnerControlEventListener();
-                nested.addActivityListener(listener);
-                nested.addActionListener(listener);
-                nested.fireAllEvents();
-                try {
-                    Thread.sleep(1000);
-                    result = listener.getFinalResult();
-                }
-                catch (Exception e) {
-                    result = "Thread sleep interrupted." + e.toString();
-                }
-
-
-            }
-        }
-        catch (Exception e) {
-            result = "Exception caught:" + e.toString();
-        }
-        return result;
-    }
-
-    /*Tests outer control receiving event from nested control using
-     * event listener. The nested control is instantiated decalratively
-     */
-    public String testEventListenerByDeclare() {
-
-        String result = "init";
-
-        if (innerControl == null)
-            result = "Nested control instantiated declaratively is NULL.";
-        else {
-            try {
-                //Create an Event Listener
-                InnerControlEventListener listener = new InnerControlEventListener();
-                innerControl.addActivityListener(listener);
-                innerControl.addActionListener(listener);
-                innerControl.fireAllEvents();
-
-                Thread.sleep(1000);
-                result = listener.getFinalResult();
-            }
-            catch (Exception e) {
-                result = "Thread sleep interrupted." + e.toString();
-            }
-
-
-        }
-        return result;
-
-    }
-
-    /*Tests outer control receiving event from nested control using
-     * inner class listener. The nested control is instantiated programmatically
-     */
-    public String testInnerClassListener() {
-
-        String result = "init";
-        try {
-            InnerControlBean nested = (InnerControlBean) java.beans.Beans.instantiate(
-                Thread.currentThread().getContextClassLoader(),
-                "org.apache.beehive.controls.test.controls.composition.InnerControlBean");
-            if (nested == null)
-                result = "Nested control instantiated programmatically is NULL.";
-            else {
-                nested.addActivityListener(
-                    new InnerControl.Activity() {
-
-                        public void wakeup() {
-                            innerClassWakeUp = true;
-                        }
-
-                        public int readMessage(String message) {
-                            innerClassReadMessage = true;
-                            return 0;
-                        }
-
-                        public String report() {
-                            innerClassReport = true;
-                            return "event received.";
-                        }
-                    }
-                );
-                nested.addActionListener(
-                    new InnerControl.Action() {
-
-                        public Object[] shopping(double credit) {
-                            innerClassShopping = true;
-                            //return {"food","drinks","candies"};
-                            return null;
-                        }
-
-                        public void doStuff(String value) {
-                            innerClassDoStuff = true;
-                        }
-                    }
-                );
-                nested.fireAllEvents();
-                try {
-                    Thread.sleep(1000);
-                }
-                catch (Exception e) {
-                    /* ignore */
-                }
-
-                result = getInnerClassListenerResult();
-            }
-        }
-        catch (Exception e) {
-            result = "Exception caught:" + e.toString();
-        }
-        return result;
-    }
-
-    /*Tests outer control receiving event from nested control using
-     * inner class listener. The nested control is instantiated decalratively
-     */
-    public String testInnerClassListenerByDeclare() {
-
-        String result = "init";
-
-        if (innerControl == null)
-            result = "Nested control instantiated declaratively is NULL.";
-        else {
-            try {
-                innerControl.addActivityListener(
-                    new InnerControl.Activity() {
-                        public void wakeup() {
-                            innerControlInnerClassWakeUp = true;
-                        }
-
-                        public int readMessage(String message) {
-                            innerControlInnerClassReadMessage = true;
-                            return 0;
-                        }
-
-                        public String report() {
-                            innerControlInnerClassReport = true;
-                            return "event received.";
-                        }
-                    }
-                );
-                innerControl.addActionListener(
-                    new InnerControl.Action() {
-
-                        public Object[] shopping(double credit) {
-                            innerControlInnerClassShopping = true;
-                            //return {"food","drinks","candies"};
-                            return null;
-                        }
-
-                        public void doStuff(String value) {
-                            innerControlInnerClassDoStuff = true;
-                        }
-                    }
-                );
-                innerControl.fireAllEvents();
-
-                Thread.currentThread().sleep(1000);
-            }
-            catch (Exception e) {
-            }
-
-            result = getInnerControlInnerClassListenerResult();
-        }
-        return result;
-
-    }
-
-    private String getInnerClassListenerResult() {
-
-        String result = "";
-
-        if (!innerClassWakeUp)
-            result = "WakeUp not received.";
-        if (!innerClassReadMessage)
-            result = result + "readMessage not received.";
-        if (!innerClassReport)
-            result = result + "report not received.";
-        if (!innerClassShopping)
-            result = result + "shopping not received.";
-        if (!innerClassDoStuff)
-            result = result + "dostuff not received.";
-
-        if (result.length() == 0)
-            result = "0";
-
-        return result;
-    }
-
-    private String getInnerControlInnerClassListenerResult() {
-
-        String result = "";
-
-        if (!innerControlInnerClassWakeUp)
-            result = "WakeUp not received.";
-        if (!innerControlInnerClassReadMessage)
-            result = result + "readMessage not received.";
-        if (!innerControlInnerClassReport)
-            result = result + "report not received.";
-        if (!innerControlInnerClassShopping)
-            result = result + "shopping not received.";
-        if (!innerControlInnerClassDoStuff)
-            result = result + "dostuff not received.";
-
-        if (result.length() == 0)
-            result = "0";
-
-        return result;
-    }
-}
+/*
+ * 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.composition;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.bean.Control;
+import org.apache.beehive.controls.api.events.Client;
+import org.apache.beehive.controls.api.events.EventHandler;
+import org.apache.beehive.controls.api.properties.BeanPropertyMap;
+
+/**
+ * A control implementation to test control composition.  Makes two instances of nested control be declaration.
+ */
+@ControlImplementation
+public class OuterControlImpl
+    implements OuterControl, java.io.Serializable {
+
+    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;
+
+    @Client
+    transient OuterEvents outerEvents;
+
+    /*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) {
+        innerControlEventHandlerDoStuff = EVENT_RECEIVED;
+    }
+
+    @EventHandler(field = "innerControl2", eventSet = InnerControl.Activity.class, eventName = "wakeup")
+    public void innerControl2wakeup() {
+    }
+
+    @EventHandler(field = "innerControl2", eventSet = InnerControl.Activity.class, eventName = "readMessage")
+    public int innerControl2readMessage(String message) {
+        return 0;
+    }
+
+    @EventHandler(field = "innerControl2", eventSet = InnerControl.Activity.class, eventName = "report")
+    public String innerControl2report() {
+        return "a report";
+    }
+
+    @EventHandler(field = "innerControl2", eventSet = InnerControl.Action.class, eventName = "shopping")
+    public Object [] innerControl2shopping(double credit) {
+        return null;
+    }
+
+    @EventHandler(field = "innerControl2", eventSet = InnerControl.Action.class, eventName = "doStuff")
+    public void innerControl2doStuff(String vakue) {
+    }
+
+    public void fireOuterEvents(String message) {
+        outerEvents.report(message);
+    }
+
+    public InnerControlBean getDeclaredNestedControl() {
+        return innerControl;
+    }
+
+    public InnerControlBean getDeclaredNestedControl2() {
+        return innerControl2;
+    }
+
+    public InnerControlBean instantiateNestedControlProgrammatically() {
+        try {
+            InnerControlBean inner =
+                (InnerControlBean) java.beans.Beans.instantiate(Thread.currentThread().getContextClassLoader(),
+                    "org.apache.beehive.controls.test.controls.composition.InnerControlBean");
+            return inner;
+        }
+        catch (Exception e) {
+            return null;
+        }
+    }
+
+    public InnerControlBean instantiateNestedControlWithProperty() {
+        try {
+            BeanPropertyMap props = new BeanPropertyMap(InnerControl.Identity.class);
+            props.setProperty(InnerControlBean.NameKey, "ken");
+            props.setProperty(InnerControlBean.JobKey, "engineer");
+            props.setProperty(InnerControlBean.RankKey, new Integer(2));
+            InnerControlBean inner = (InnerControlBean) org.apache.beehive.controls.api.bean.Controls.instantiate(
+                Thread.currentThread().getContextClassLoader(),
+                "org.apache.beehive.controls.test.controls.composition.InnerControlBean", props);
+            return inner;
+        }
+        catch (Exception e) {
+            throw new RuntimeException("Failed to instantiate nested control", e);
+        }
+    }
+
+    public String testActivityWakeup() {
+
+        String result = "";
+        if (innerControl == null)
+            result = "inner control is NULL";
+        else {
+            innerControl.fireEvent("Activity", "wakeup");
+            /*Wait for the events*/
+            try {
+                Thread.sleep(1000);
+                if (innerControlEventHandlerWakeUp.equals(EVENT_RECEIVED))
+                    result = "0";
+                else
+                    result = "Acivity.wakeup not received by EventHandler";
+            }
+            catch (Exception e) {
+                result = "Thread sleep interrupted." + e.toString();
+            }
+        }
+        return result;
+    }
+
+    public String testActivityReadMessage() {
+
+        String result = "";
+        if (innerControl == null)
+            result = "inner control is NULL";
+        else {
+            innerControl.fireEvent("Activity", "readMessage");
+            /*Wait for the events*/
+            try {
+                Thread.sleep(1000);
+
+                if (innerControlEventHandlerReadMessage.equals(EVENT_RECEIVED))
+                    result = "0";
+                else
+                    result = "Acivity.readMessage not received by EventHandler";
+            }
+            catch (Exception e) {
+                result = "Thread sleep interrupted." + e.toString();
+            }
+        }
+        return result;
+
+    }
+
+    public String testActivityReport() {
+
+        String result = "";
+        if (innerControl == null)
+            result = "inner control is NULL";
+        else {
+            innerControl.fireEvent("Activity", "report");
+            /*Wait for the events*/
+            try {
+                Thread.sleep(1000);
+
+                if (innerControlEventHandlerReport.equals(EVENT_RECEIVED))
+                    result = "0";
+                else
+                    result = "Acivity.report not received by EventHandler";
+            }
+            catch (Exception e) {
+                result = "Thread sleep interrupted." + e.toString();
+            }
+        }
+        return result;
+
+    }
+
+    public String testActionShopping() {
+
+        String result = "";
+        if (innerControl == null)
+            result = "inner control is NULL";
+        else {
+            innerControl.fireEvent("Action", "shopping");
+            /*Wait for the events*/
+            try {
+                Thread.sleep(1000);
+
+                if (innerControlEventHandlerShopping.equals(EVENT_RECEIVED))
+                    result = "0";
+                else
+                    result = "Action.shopping not received by EventHandler";
+            }
+            catch (Exception e) {
+                result = "Thread sleep interrupted." + e.toString();
+            }
+        }
+        return result;
+
+    }
+
+    public String testActionDostuff() {
+
+        String result = "";
+        if (innerControl == null)
+            result = "inner control is NULL";
+        else {
+            innerControl.fireEvent("Action", "doStuff");
+            /*Wait for the events*/
+            try {
+                Thread.sleep(1000);
+
+                if (innerControlEventHandlerDoStuff.equals(EVENT_RECEIVED))
+                    result = "0";
+                else
+                    result = "Action.doStuff not received by EventHandler";
+            }
+            catch (Exception e) {
+                result = "Thread sleep interrupted." + e.toString();
+            }
+        }
+        return result;
+
+    }
+
+    /*Tests outer control receiving event from nested control using
+     * event listener. The nested control is instantiated programmatically
+     */
+    public String testEventListener() {
+
+        String result = "init";
+        try {
+
+            InnerControlBean nested = (InnerControlBean) java.beans.Beans.instantiate(
+                Thread.currentThread().getContextClassLoader(),
+                "org.apache.beehive.controls.test.controls.composition.InnerControlBean");
+            if (nested == null)
+                result = "Nested control instantiated programmatically is NULL.";
+            else {
+                //Create an Event Listener
+                InnerControlEventListener listener = new InnerControlEventListener();
+                nested.addActivityListener(listener);
+                nested.addActionListener(listener);
+                nested.fireAllEvents();
+                try {
+                    Thread.sleep(1000);
+                    result = listener.getFinalResult();
+                }
+                catch (Exception e) {
+                    result = "Thread sleep interrupted." + e.toString();
+                }
+
+
+            }
+        }
+        catch (Exception e) {
+            result = "Exception caught:" + e.toString();
+        }
+        return result;
+    }
+
+    /*Tests outer control receiving event from nested control using
+     * event listener. The nested control is instantiated decalratively
+     */
+    public String testEventListenerByDeclare() {
+
+        String result = "init";
+
+        if (innerControl == null)
+            result = "Nested control instantiated declaratively is NULL.";
+        else {
+            try {
+                //Create an Event Listener
+                InnerControlEventListener listener = new InnerControlEventListener();
+                innerControl.addActivityListener(listener);
+                innerControl.addActionListener(listener);
+                innerControl.fireAllEvents();
+
+                Thread.sleep(1000);
+                result = listener.getFinalResult();
+            }
+            catch (Exception e) {
+                result = "Thread sleep interrupted." + e.toString();
+            }
+
+
+        }
+        return result;
+
+    }
+
+    /*Tests outer control receiving event from nested control using
+     * inner class listener. The nested control is instantiated programmatically
+     */
+    public String testInnerClassListener() {
+
+        String result = "init";
+        try {
+            InnerControlBean nested = (InnerControlBean) java.beans.Beans.instantiate(
+                Thread.currentThread().getContextClassLoader(),
+                "org.apache.beehive.controls.test.controls.composition.InnerControlBean");
+            if (nested == null)
+                result = "Nested control instantiated programmatically is NULL.";
+            else {
+                nested.addActivityListener(
+                    new InnerControl.Activity() {
+
+                        public void wakeup() {
+                            innerClassWakeUp = true;
+                        }
+
+                        public int readMessage(String message) {
+                            innerClassReadMessage = true;
+                            return 0;
+                        }
+
+                        public String report() {
+                            innerClassReport = true;
+                            return "event received.";
+                        }
+                    }
+                );
+                nested.addActionListener(
+                    new InnerControl.Action() {
+
+                        public Object[] shopping(double credit) {
+                            innerClassShopping = true;
+                            //return {"food","drinks","candies"};
+                            return null;
+                        }
+
+                        public void doStuff(String value) {
+                            innerClassDoStuff = true;
+                        }
+                    }
+                );
+                nested.fireAllEvents();
+                try {
+                    Thread.sleep(1000);
+                }
+                catch (Exception e) {
+                    /* ignore */
+                }
+
+                result = getInnerClassListenerResult();
+            }
+        }
+        catch (Exception e) {
+            result = "Exception caught:" + e.toString();
+        }
+        return result;
+    }
+
+    /*Tests outer control receiving event from nested control using
+     * inner class listener. The nested control is instantiated decalratively
+     */
+    public String testInnerClassListenerByDeclare() {
+
+        String result = "init";
+
+        if (innerControl == null)
+            result = "Nested control instantiated declaratively is NULL.";
+        else {
+            try {
+                innerControl.addActivityListener(
+                    new InnerControl.Activity() {
+                        public void wakeup() {
+                            innerControlInnerClassWakeUp = true;
+                        }
+
+                        public int readMessage(String message) {
+                            innerControlInnerClassReadMessage = true;
+                            return 0;
+                        }
+
+                        public String report() {
+                            innerControlInnerClassReport = true;
+                            return "event received.";
+                        }
+                    }
+                );
+                innerControl.addActionListener(
+                    new InnerControl.Action() {
+
+                        public Object[] shopping(double credit) {
+                            innerControlInnerClassShopping = true;
+                            //return {"food","drinks","candies"};
+                            return null;
+                        }
+
+                        public void doStuff(String value) {
+                            innerControlInnerClassDoStuff = true;
+                        }
+                    }
+                );
+                innerControl.fireAllEvents();
+
+                Thread.currentThread().sleep(1000);
+            }
+            catch (Exception e) {
+            }
+
+            result = getInnerControlInnerClassListenerResult();
+        }
+        return result;
+
+    }
+
+    private String getInnerClassListenerResult() {
+
+        String result = "";
+
+        if (!innerClassWakeUp)
+            result = "WakeUp not received.";
+        if (!innerClassReadMessage)
+            result = result + "readMessage not received.";
+        if (!innerClassReport)
+            result = result + "report not received.";
+        if (!innerClassShopping)
+            result = result + "shopping not received.";
+        if (!innerClassDoStuff)
+            result = result + "dostuff not received.";
+
+        if (result.length() == 0)
+            result = "0";
+
+        return result;
+    }
+
+    private String getInnerControlInnerClassListenerResult() {
+
+        String result = "";
+
+        if (!innerControlInnerClassWakeUp)
+            result = "WakeUp not received.";
+        if (!innerControlInnerClassReadMessage)
+            result = result + "readMessage not received.";
+        if (!innerControlInnerClassReport)
+            result = result + "report not received.";
+        if (!innerControlInnerClassShopping)
+            result = result + "shopping not received.";
+        if (!innerControlInnerClassDoStuff)
+            result = result + "dostuff not received.";
+
+        if (result.length() == 0)
+            result = "0";
+
+        return result;
+    }
+}

Propchange: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/composition/OuterControlImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/simple/SimpleStatefulControl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/simple/SimpleStatefulControl.java?rev=406090&r1=406089&r2=406090&view=diff
==============================================================================
--- beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/simple/SimpleStatefulControl.java (original)
+++ beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/simple/SimpleStatefulControl.java Sat May 13 06:14:42 2006
@@ -1,19 +1,19 @@
-/**
- * Created by IntelliJ IDEA.
- * User: ekoneil
- * Date: Apr 27, 2006
- * Time: 12:47:00 PM
- * To change this template use File | Settings | File Templates.
- */
-package org.apache.beehive.controls.test.controls.simple;
-
-import org.apache.beehive.controls.api.bean.ControlInterface;
-
-@ControlInterface
-public interface SimpleStatefulControl {
-
-    public int getValue();
-
-    public void setValue(int value);
-}
+/**
+ * Created by IntelliJ IDEA.
+ * User: ekoneil
+ * Date: Apr 27, 2006
+ * Time: 12:47:00 PM
+ * To change this template use File | Settings | File Templates.
+ */
+package org.apache.beehive.controls.test.controls.simple;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+
+@ControlInterface
+public interface SimpleStatefulControl {
+
+    public int getValue();
+
+    public void setValue(int value);
+}
  

Propchange: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/simple/SimpleStatefulControl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/simple/SimpleStatefulControlImpl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/simple/SimpleStatefulControlImpl.java?rev=406090&r1=406089&r2=406090&view=diff
==============================================================================
--- beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/simple/SimpleStatefulControlImpl.java (original)
+++ beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/simple/SimpleStatefulControlImpl.java Sat May 13 06:14:42 2006
@@ -1,30 +1,30 @@
-/**
- * Created by IntelliJ IDEA.
- * User: ekoneil
- * Date: Apr 27, 2006
- * Time: 12:47:32 PM
- * To change this template use File | Settings | File Templates.
- */
-package org.apache.beehive.controls.test.controls.simple;
-
-import org.apache.beehive.controls.api.bean.ControlImplementation;
-import org.apache.beehive.controls.api.context.Context;
-import org.apache.beehive.controls.api.context.ControlBeanContext;
-
-@ControlImplementation(isTransient = true)
-public class SimpleStatefulControlImpl
-    implements SimpleStatefulControl {
-
-    @Context
-    private ControlBeanContext _context;
-
-    private int _value;
-
-    public int getValue() {
-        return _value;
-    }
-
-    public void setValue(int value) {
-        _value = value;
-    }
-}
+/**
+ * Created by IntelliJ IDEA.
+ * User: ekoneil
+ * Date: Apr 27, 2006
+ * Time: 12:47:32 PM
+ * To change this template use File | Settings | File Templates.
+ */
+package org.apache.beehive.controls.test.controls.simple;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.context.Context;
+import org.apache.beehive.controls.api.context.ControlBeanContext;
+
+@ControlImplementation(isTransient = true)
+public class SimpleStatefulControlImpl
+    implements SimpleStatefulControl {
+
+    @Context
+    private ControlBeanContext _context;
+
+    private int _value;
+
+    public int getValue() {
+        return _value;
+    }
+
+    public void setValue(int value) {
+        _value = value;
+    }
+}

Propchange: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/simple/SimpleStatefulControlImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/DeclarativeTest.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/DeclarativeTest.java?rev=406090&r1=406089&r2=406090&view=diff
==============================================================================
--- beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/DeclarativeTest.java (original)
+++ beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/DeclarativeTest.java Sat May 13 06:14:42 2006
@@ -1,132 +1,132 @@
-/*
- * 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.junit;
-
-import java.io.ByteArrayOutputStream;
-
-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.junit.utils.ControlTestUtils;
-
-/**
- * A TestCase that tests control composition.
- * The outer control is instantiated declaratively, and the outer
- * control instantiates the nested control declaratively
- *
- * Instantiating controls declaratively is not supported currently.
- * All tests are deactivated until this is supported
- */
-public class DeclarativeTest
-    extends ControlTestCase
-    implements java.io.Serializable {
-
-    @Control
-    private OuterControlBean _outerControl;
-
-    private String _onReportMessage;
-
-    @EventHandler(field="_outerControl", eventSet=OuterControl.OuterEvents.class, eventName="report")
-    public int onReport( String msg ) {
-        _onReportMessage = msg;
-        return 0;
-    }
-
-    /**
-     * Tests outer control instantiats nested control by declaration
-     */
-    public void testInstantiation()
-        throws Exception {
-        assertNotNull(_outerControl);
-        assertNotNull(_outerControl.getDeclaredNestedControl());
-        assertNotNull(_outerControl.getDeclaredNestedControl2());
-    }
-
-    /**
-     * Tests outer control getting inner control property from control context
-     */
-    public void testGetPropertyByContext() {
-        assertNotNull(_outerControl);
-
-        InnerControlBean innercontrol=_outerControl.getDeclaredNestedControl();
-        assertNotNull(innercontrol);
-        assertEquals("Bob",innercontrol.getNameFromContext());
-        assertNull(innercontrol.getJobFromContext());
-    }
-
-    /**
-     * Tests reconfigured property.
-     * Outer control reconfigures the inner control's property when instantiating it
-     */
-    public void testReconfiguredProperty() {
-        assertNotNull(_outerControl);
-        InnerControlBean innercontrol=_outerControl.getDeclaredNestedControl2();
-        assertNotNull(innercontrol);
-        assertEquals("Bob",innercontrol.getNameFromContext());
-        assertEquals("farmer",innercontrol.getJobFromContext());
-    }
-
-    /**
-     * Tests outer control receiving events from nested control using
-     * EventHandler
-     */
-    public void testEventHandler() {
-        assertNotNull(_outerControl);
-        assertEquals("0",_outerControl.testActivityWakeup());
-        assertEquals("0",_outerControl.testActivityReadMessage());
-        assertEquals("0",_outerControl.testActivityReport());
-        assertEquals("0",_outerControl.testActionShopping());
-        assertEquals("0",_outerControl.testActionDostuff());
-    }
-
-    /**
-     * Tests outer control firing events to us
-     */
-    public void testOuterEvents() {
-        System.out.println( "_onReportMessage=" + _onReportMessage );
-
-        assertNotNull(_outerControl);
-
-        _outerControl.fireOuterEvents("this is the reported msg");
-        assertEquals("this is the reported msg", _onReportMessage );
-        System.out.println( "_onReportMessage=" + _onReportMessage );
-    }
-
-    /**
-     * Test to ensure that control identifiers and relationships are maintained correctly after
-     * serializing and deserializing a control tree.
-     */
-    public void testControlIDs()
-        throws Exception {
-
-        assertEquals("_outerControl", _outerControl.getControlID());
-        assertEquals("_outerControl/innerControl", _outerControl.getDeclaredNestedControl().getControlID());
-
-        ByteArrayOutputStream baos = ControlTestUtils.serialize(_outerControl);
-
-        Object object = ControlTestUtils.deserialize(baos);
-        assertTrue(object instanceof OuterControlBean);
-        OuterControlBean outerControlCopy = (OuterControlBean)object;
-
-        assertFalse(outerControlCopy == _outerControl);
-        assertEquals("_outerControl", outerControlCopy.getControlID());
-        assertEquals("_outerControl/innerControl", outerControlCopy.getDeclaredNestedControl().getControlID());
-    }
-}
+/*
+ * 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.junit;
+
+import java.io.ByteArrayOutputStream;
+
+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.junit.utils.ControlTestUtils;
+
+/**
+ * A TestCase that tests control composition.
+ * The outer control is instantiated declaratively, and the outer
+ * control instantiates the nested control declaratively
+ *
+ * Instantiating controls declaratively is not supported currently.
+ * All tests are deactivated until this is supported
+ */
+public class DeclarativeTest
+    extends ControlTestCase
+    implements java.io.Serializable {
+
+    @Control
+    private OuterControlBean _outerControl;
+
+    private String _onReportMessage;
+
+    @EventHandler(field="_outerControl", eventSet=OuterControl.OuterEvents.class, eventName="report")
+    public int onReport( String msg ) {
+        _onReportMessage = msg;
+        return 0;
+    }
+
+    /**
+     * Tests outer control instantiats nested control by declaration
+     */
+    public void testInstantiation()
+        throws Exception {
+        assertNotNull(_outerControl);
+        assertNotNull(_outerControl.getDeclaredNestedControl());
+        assertNotNull(_outerControl.getDeclaredNestedControl2());
+    }
+
+    /**
+     * Tests outer control getting inner control property from control context
+     */
+    public void testGetPropertyByContext() {
+        assertNotNull(_outerControl);
+
+        InnerControlBean innercontrol=_outerControl.getDeclaredNestedControl();
+        assertNotNull(innercontrol);
+        assertEquals("Bob",innercontrol.getNameFromContext());
+        assertNull(innercontrol.getJobFromContext());
+    }
+
+    /**
+     * Tests reconfigured property.
+     * Outer control reconfigures the inner control's property when instantiating it
+     */
+    public void testReconfiguredProperty() {
+        assertNotNull(_outerControl);
+        InnerControlBean innercontrol=_outerControl.getDeclaredNestedControl2();
+        assertNotNull(innercontrol);
+        assertEquals("Bob",innercontrol.getNameFromContext());
+        assertEquals("farmer",innercontrol.getJobFromContext());
+    }
+
+    /**
+     * Tests outer control receiving events from nested control using
+     * EventHandler
+     */
+    public void testEventHandler() {
+        assertNotNull(_outerControl);
+        assertEquals("0",_outerControl.testActivityWakeup());
+        assertEquals("0",_outerControl.testActivityReadMessage());
+        assertEquals("0",_outerControl.testActivityReport());
+        assertEquals("0",_outerControl.testActionShopping());
+        assertEquals("0",_outerControl.testActionDostuff());
+    }
+
+    /**
+     * Tests outer control firing events to us
+     */
+    public void testOuterEvents() {
+        System.out.println( "_onReportMessage=" + _onReportMessage );
+
+        assertNotNull(_outerControl);
+
+        _outerControl.fireOuterEvents("this is the reported msg");
+        assertEquals("this is the reported msg", _onReportMessage );
+        System.out.println( "_onReportMessage=" + _onReportMessage );
+    }
+
+    /**
+     * Test to ensure that control identifiers and relationships are maintained correctly after
+     * serializing and deserializing a control tree.
+     */
+    public void testControlIDs()
+        throws Exception {
+
+        assertEquals("_outerControl", _outerControl.getControlID());
+        assertEquals("_outerControl/innerControl", _outerControl.getDeclaredNestedControl().getControlID());
+
+        ByteArrayOutputStream baos = ControlTestUtils.serialize(_outerControl);
+
+        Object object = ControlTestUtils.deserialize(baos);
+        assertTrue(object instanceof OuterControlBean);
+        OuterControlBean outerControlCopy = (OuterControlBean)object;
+
+        assertFalse(outerControlCopy == _outerControl);
+        assertEquals("_outerControl", outerControlCopy.getControlID());
+        assertEquals("_outerControl/innerControl", outerControlCopy.getDeclaredNestedControl().getControlID());
+    }
+}

Propchange: beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/DeclarativeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/utils/ControlTestUtils.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/utils/ControlTestUtils.java?rev=406090&r1=406089&r2=406090&view=diff
==============================================================================
--- beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/utils/ControlTestUtils.java (original)
+++ beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/utils/ControlTestUtils.java Sat May 13 06:14:42 2006
@@ -1,72 +1,72 @@
-/*
- * 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.junit.utils;
-
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectOutputStream;
-import java.io.IOException;
-import java.io.ByteArrayInputStream;
-import java.io.ObjectInputStream;
-
-import org.apache.beehive.controls.test.controls.composition.OuterControlBean;
-
-public final class ControlTestUtils {
-
-    public static ByteArrayOutputStream serialize(Object object)
-        throws IOException {
-        // Test the relationships and identifiers are preserved across serialization and deserialization
-        ByteArrayOutputStream baos = null;
-        ObjectOutputStream oos = null;
-        try {
-            baos = new ByteArrayOutputStream();
-            oos = new ObjectOutputStream(baos);
-
-            oos.writeObject(object);
-            oos.close();
-        }
-        finally {
-            if(oos != null)
-                oos.close();
-            if(baos != null)
-                baos.close();
-        }
-        return baos;
-    }
-
-    public static Object deserialize(ByteArrayOutputStream baos)
-        throws IOException, ClassNotFoundException {
-
-        Object object = null;
-
-        ByteArrayInputStream bais = null;
-        ObjectInputStream ois = null;
-        try {
-            bais = new ByteArrayInputStream(baos.toByteArray());
-            ois = new ObjectInputStream(bais);
-            object = ois.readObject();
-        }
-        finally {
-            if(ois != null)
-                ois.close();
-            if(bais != null)
-                bais.close();
-        }
-
-        return object;
-    }
-}
+/*
+ * 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.junit.utils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+
+import org.apache.beehive.controls.test.controls.composition.OuterControlBean;
+
+public final class ControlTestUtils {
+
+    public static ByteArrayOutputStream serialize(Object object)
+        throws IOException {
+        // Test the relationships and identifiers are preserved across serialization and deserialization
+        ByteArrayOutputStream baos = null;
+        ObjectOutputStream oos = null;
+        try {
+            baos = new ByteArrayOutputStream();
+            oos = new ObjectOutputStream(baos);
+
+            oos.writeObject(object);
+            oos.close();
+        }
+        finally {
+            if(oos != null)
+                oos.close();
+            if(baos != null)
+                baos.close();
+        }
+        return baos;
+    }
+
+    public static Object deserialize(ByteArrayOutputStream baos)
+        throws IOException, ClassNotFoundException {
+
+        Object object = null;
+
+        ByteArrayInputStream bais = null;
+        ObjectInputStream ois = null;
+        try {
+            bais = new ByteArrayInputStream(baos.toByteArray());
+            ois = new ObjectInputStream(bais);
+            object = ois.readObject();
+        }
+        finally {
+            if(ois != null)
+                ois.close();
+            if(bais != null)
+                bais.close();
+        }
+
+        return object;
+    }
+}

Propchange: beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/utils/ControlTestUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/ControlIntrospector.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/ControlIntrospector.java?rev=406090&r1=406089&r2=406090&view=diff
==============================================================================
--- beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/ControlIntrospector.java (original)
+++ beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/ControlIntrospector.java Sat May 13 06:14:42 2006
@@ -1,389 +1,389 @@
-/*
- * 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.util;
-
-import java.beans.Introspector;
-import java.beans.IntrospectionException;
-import java.beans.BeanInfo;
-import java.beans.PropertyDescriptor;
-import java.beans.EventSetDescriptor;
-import java.beans.MethodDescriptor;
-import java.beans.BeanDescriptor;
-import java.beans.FeatureDescriptor;
-import java.beans.ParameterDescriptor;
-import java.io.PrintWriter;
-import java.io.OutputStream;
-import java.io.InputStream;
-import java.io.PrintStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.SortedSet;
-import java.util.Enumeration;
-import java.util.TreeSet;
-import java.util.Set;
-import java.util.Comparator;
-import java.lang.reflect.Method;
-
-/**
- * A utility class for introspecting Control beans
- */
-public final class ControlIntrospector {
-
-    private Class _beanClass;
-    private int _indentLevel = 0;
-    private PrintWriter _pw;
-
-    public ControlIntrospector(Class beanClass, OutputStream output) {
-        _beanClass = beanClass;
-        _pw = new PrintWriter(output);
-    }
-
-    private void indent() {
-        _indentLevel++;
-    }
-
-    private void unindent() {
-        _indentLevel--;
-    }
-
-    private void printf(String format, Object ...args) {
-        for(int i = 0; i < _indentLevel; i++)
-            _pw.append("    ");
-        _pw.printf(format, args);
-        _pw.println();
-    }
-
-    private void printElement(String name, String value) {
-        printf("<%s>",name);
-        indent();
-        printf("%s", value);
-        unindent();
-        printf("</%s>",name);
-    }
-
-    /**
-     * Introspects the target class and writes the formatted results from introspection to
-     * the provided output stream
-     */
-    public void introspect(int flags)
-        throws IntrospectionException {
-
-        BeanInfo beanInfo = Introspector.getBeanInfo(_beanClass, flags);
-        if (beanInfo == null)
-            throw new IntrospectionException("No BeanInfo for " + _beanClass);
-
-        introspectBeanInfo(beanInfo);
-
-        _pw.flush();
-    }
-
-    public void introspect()
-        throws IntrospectionException {
-        introspect(Introspector.USE_ALL_BEANINFO);
-    }
-
-    private void introspectBeanInfo(BeanInfo beanInfo) {
-        printf("<bean-info name=\"%s\">", beanInfo.getBeanDescriptor().getBeanClass().getName());
-        indent();
-        {
-            introspectBeanDescriptor(beanInfo.getBeanDescriptor());
-
-            MethodDescriptor [] methodDescs = beanInfo.getMethodDescriptors();
-            if (methodDescs != null && methodDescs.length != 0) {
-                printf("<method-descriptors>");
-                indent();
-                introspectMethodDescriptors(methodDescs);
-                unindent();
-                printf("</method-descriptors>");
-            }
-            else printf("<method-descriptors/>");
-
-            PropertyDescriptor [] propDescs = beanInfo.getPropertyDescriptors();
-            if (propDescs != null && propDescs.length != 0) {
-                printf("<property-descriptors default-index=%d>", beanInfo.getDefaultPropertyIndex());
-                indent();
-                for (int i = 0; i < propDescs.length; i++)
-                    introspectPropertyDescriptor(propDescs[i],
-                                                 i == beanInfo.getDefaultPropertyIndex());
-                unindent();
-                printf("</property-descriptors>");
-            }
-            else printf("<property-descriptors/>");
-
-            EventSetDescriptor [] eventSetDescs = beanInfo.getEventSetDescriptors();
-            if (eventSetDescs != null && eventSetDescs.length != 0) {
-                printf("<event-set-descriptors default-index=%d>",
-                       beanInfo.getDefaultEventIndex());
-                indent();
-                for (int i = 0; i < eventSetDescs.length; i++)
-                    introspectEventSetDescriptor(eventSetDescs[i],
-                                                 i == beanInfo.getDefaultEventIndex());
-                unindent();
-                printf("</event-set-descriptors>");
-            }
-            else printf("<event-set-descriptors/>");
-
-            BeanInfo [] additionalBeanInfo = beanInfo.getAdditionalBeanInfo();
-            if (additionalBeanInfo != null && additionalBeanInfo.length != 0) {
-                printf("<additional-bean-info>");
-                indent();
-                {
-                    for (int i = 0; i < additionalBeanInfo.length; i++)
-                        introspectBeanInfo(additionalBeanInfo[i]);
-                }
-                unindent();
-                printf("</additional-bean-info>");
-            }
-            else printf("<additional-bean-info/>");
-        }
-        unindent();
-        printf("</bean-info>");
-    }
-
-    private void introspectBeanDescriptor(BeanDescriptor beanDesc) {
-        printf("<bean-descriptor name=\"%s\">", beanDesc.getDisplayName());
-        indent();
-        {
-            introspectFeatureDescriptor(beanDesc);;
-            printElement("bean-class", beanDesc.getBeanClass().getName());
-            Class customizerClass = beanDesc.getCustomizerClass();
-            if (customizerClass != null)
-                printElement("customizer-class", customizerClass.getName());
-        }
-        unindent();
-        printf("</bean-descriptor>");
-    }
-
-    private void introspectFeatureDescriptor(FeatureDescriptor featureDesc) {
-        printf("<feature-descriptor name=\"%s\"", featureDesc.getDisplayName());
-        indent();
-        {
-            printf("full-name=\"%s\"", featureDesc.getName());
-            printf("is-expert=%b", featureDesc.isExpert());
-            printf("is-hidden=%b", featureDesc.isHidden());
-            printf("is-preferred=%b>", featureDesc.isPreferred());
-
-            printElement("short-description", featureDesc.getShortDescription());
-
-            Enumeration<String> attrNames = featureDesc.attributeNames();
-            if (attrNames != null && attrNames.hasMoreElements()) {
-                SortedSet<String> sortedNames = new TreeSet<String>();
-                while (attrNames.hasMoreElements())
-                    sortedNames.add(attrNames.nextElement());
-                printf("<attributes>");
-                indent();
-                {
-                    for (String attrName: sortedNames) {
-                        // Convert the attribute value to a String, but drop any object ID
-                        // that is going to fail an equivalence comparison
-                        String attrValue = featureDesc.getValue(attrName).toString();
-                        int atIndex = attrValue.indexOf('@');
-                        if (atIndex > 0)
-                            attrValue = attrValue.substring(0, atIndex+1);
-
-                        printf("<attribute name=\"%s\" value=\"%s\">",
-                               attrName, attrValue);
-                    }
-                }
-                unindent();
-                printf("</attributes>");
-            }
-        }
-        unindent();
-        printf("</feature-descriptor>", featureDesc.getDisplayName());
-    }
-
-    /** * Provides a predictable ordering of method descriptors, based upon the underlying
-     * java.lang.reflect.Method attributes.  Uses the following tests:
-     *  - compare method names.  If equal, then:
-     *  - compare parameter list lengths.  If equals, then:
-     *  - compare parameter type names, in order, until they are unequal
-     */
-    static private class MethodDescriptorComparator
-        implements Comparator<MethodDescriptor> {
-
-        public int compare(MethodDescriptor md1, MethodDescriptor md2) {
-            Method m1 = md1.getMethod();
-            Method m2 = md2.getMethod();
-            int retval = m1.getName().compareTo(m2.getName());
-            if (retval == 0) {
-                Class [] parms1 = m1.getParameterTypes();
-                Class [] parms2 = m1.getParameterTypes();
-                if (parms1.length < parms2.length)
-                    retval = -1;
-                else if (parms1.length > parms2.length)
-                    retval = 1;
-                else {
-                    for (int i = 0; i < parms1.length; i++)
-                    {
-                        retval = parms1[i].getName().compareTo(parms2[i].getName());
-                        if (retval != 0)
-                            break;
-                    }
-                }
-            }
-            return retval;
-        }
-
-        public boolean equals(Object o) {
-            return o != null && o instanceof MethodDescriptorComparator;
-        }
-    }
-
-    /** Sorts an input array of MethodDescriptors */
-    private Set<MethodDescriptor> sortMethodDescriptors(MethodDescriptor [] methodDescs) {
-        Set<MethodDescriptor> sortedMethodDescs =
-            new TreeSet<MethodDescriptor>(new MethodDescriptorComparator());
-        for (int i = 0; i < methodDescs.length; i++)
-            sortedMethodDescs.add(methodDescs[i]);
-        return sortedMethodDescs;
-    }
-
-    private void introspectMethodDescriptors(MethodDescriptor [] methodDescs) {
-        Set<MethodDescriptor> sortedMethodDescs = sortMethodDescriptors(methodDescs);
-        for (MethodDescriptor methodDesc: sortedMethodDescs)
-            introspectMethodDescriptor(methodDesc);
-    }
-
-    private void introspectMethodDescriptor(MethodDescriptor methodDesc) {
-        printf("<method-descriptor name=\"%s\"", methodDesc.getDisplayName());
-        indent();
-        {
-            printElement("method", methodDesc.getMethod().toGenericString());
-            ParameterDescriptor [] paramDescs = methodDesc.getParameterDescriptors();
-            if (paramDescs != null && paramDescs.length != 0) {
-                printf("<parameter-descriptors>");
-                indent();
-                for (int i = 0; i < paramDescs.length; i++)
-                    introspectParameterDescriptor(paramDescs[i]);
-                unindent();
-                printf("</parameter-descriptors>");
-            }
-            else
-                printf("<param-descriptors/>");
-            introspectFeatureDescriptor(methodDesc);
-        }
-        unindent();
-        printf("</method-descriptor>");
-    }
-
-    private void introspectParameterDescriptor(ParameterDescriptor paramDesc) {
-        printf("<parameter-descriptor name=\"%s\">", paramDesc.getDisplayName());
-        indent();
-        introspectFeatureDescriptor(paramDesc);
-        unindent();
-        printf("</parameter-descriptor>", paramDesc.getDisplayName());
-    }
-
-    private void introspectPropertyDescriptor(PropertyDescriptor propDesc, boolean isDefault) {
-        printf("<property-descriptor name=\"%s\">", propDesc.getDisplayName());
-        indent();
-        {
-            printf("type=\"%s\"", propDesc.getPropertyType().getName());
-            printf("isBound=%b", propDesc.isBound());
-            printf("isConstrained=%b", propDesc.isConstrained());
-            printf("isDefault=%b>", isDefault);
-
-            Method readMethod = propDesc.getReadMethod();
-            if (readMethod != null)
-                printElement("read-method", readMethod.toGenericString());
-
-            Method writeMethod = propDesc.getWriteMethod();
-            if (writeMethod != null)
-                printElement("write-method", writeMethod.toGenericString());
-
-            Class propertyEditorClass = propDesc.getPropertyEditorClass();
-            if (propertyEditorClass != null)
-                printElement("property-editor-class", propertyEditorClass.getName());
-            introspectFeatureDescriptor(propDesc);
-        }
-        unindent();
-        printf("</property-descriptor>", propDesc.getDisplayName());
-    }
-
-    private void introspectEventSetDescriptor(EventSetDescriptor eventDesc, boolean isDefault) {
-        printf("<event-descriptor name=\"%s\"", eventDesc.getDisplayName());
-        indent();
-        {
-            printf("is-unicast=%b", eventDesc.isUnicast());
-            printf("is-in-default=%b", eventDesc.isInDefaultEventSet());
-            printf("is-default=%b>", isDefault);
-            printElement("listener-type", eventDesc.getListenerType().getName());
-
-            Method meth = eventDesc.getAddListenerMethod();
-            if (meth != null)
-                printElement("add-listener-method", meth.toGenericString());
-
-            meth = eventDesc.getRemoveListenerMethod();
-            if (meth != null)
-                printElement("remove-listener-method", meth.toGenericString());
-
-            meth = eventDesc.getGetListenerMethod();
-            if (meth != null)
-                printElement("get-listener-method", meth.toGenericString());
-
-            MethodDescriptor [] methodDescs = eventDesc.getListenerMethodDescriptors();
-            if (methodDescs != null && methodDescs.length != 0) {
-                printf("<listener-method-descriptors>");
-                indent();
-                introspectMethodDescriptors(methodDescs);
-                unindent();
-                printf("</listener-method-descriptors>");
-            }
-            else printf("<listener-method-descriptors/>");
-            introspectFeatureDescriptor(eventDesc);
-        }
-        unindent();
-    }
-
-    public static void main(String[] args)
-        throws Exception {
-
-        if (args.length < 1)
-            System.err.println("Usage: java org.apache.beehive.controls.test.controls.util.ControlIntrospector [-path <path>] beanClass");
-
-        String className = null;
-        String outputPath = null;
-        for(int i = 0; i < args.length; i++) {
-            if(args[i].equals("-outputPath")) {
-                if(i+1 < args.length)
-                    outputPath = args[i+1];
-                else throw new RuntimeException("Invalid command line; unable to find value for \"-outputPath\"");
-            }
-        }
-
-        className = args[args.length-1];
-        System.out.println("Create .beaninfo for class \"" + className + "\"");
-        if(outputPath != null)
-            System.out.println("Write .beaninfo to file \"" + outputPath + "\"");
-
-        Class beanClass = Class.forName(className);
-        PrintStream ps = System.out;
-        try {
-            if(outputPath != null)
-                ps = new PrintStream(new FileOutputStream(new File(outputPath)));
-
-            ControlIntrospector ci = new ControlIntrospector(beanClass, ps);
-            ci.introspect();
-        }
-        finally {
-            if(ps != null && ps != System.out)
-                ps.close();
-        }
-    }
-}
+/*
+ * 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.util;
+
+import java.beans.Introspector;
+import java.beans.IntrospectionException;
+import java.beans.BeanInfo;
+import java.beans.PropertyDescriptor;
+import java.beans.EventSetDescriptor;
+import java.beans.MethodDescriptor;
+import java.beans.BeanDescriptor;
+import java.beans.FeatureDescriptor;
+import java.beans.ParameterDescriptor;
+import java.io.PrintWriter;
+import java.io.OutputStream;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.SortedSet;
+import java.util.Enumeration;
+import java.util.TreeSet;
+import java.util.Set;
+import java.util.Comparator;
+import java.lang.reflect.Method;
+
+/**
+ * A utility class for introspecting Control beans
+ */
+public final class ControlIntrospector {
+
+    private Class _beanClass;
+    private int _indentLevel = 0;
+    private PrintWriter _pw;
+
+    public ControlIntrospector(Class beanClass, OutputStream output) {
+        _beanClass = beanClass;
+        _pw = new PrintWriter(output);
+    }
+
+    private void indent() {
+        _indentLevel++;
+    }
+
+    private void unindent() {
+        _indentLevel--;
+    }
+
+    private void printf(String format, Object ...args) {
+        for(int i = 0; i < _indentLevel; i++)
+            _pw.append("    ");
+        _pw.printf(format, args);
+        _pw.println();
+    }
+
+    private void printElement(String name, String value) {
+        printf("<%s>",name);
+        indent();
+        printf("%s", value);
+        unindent();
+        printf("</%s>",name);
+    }
+
+    /**
+     * Introspects the target class and writes the formatted results from introspection to
+     * the provided output stream
+     */
+    public void introspect(int flags)
+        throws IntrospectionException {
+
+        BeanInfo beanInfo = Introspector.getBeanInfo(_beanClass, flags);
+        if (beanInfo == null)
+            throw new IntrospectionException("No BeanInfo for " + _beanClass);
+
+        introspectBeanInfo(beanInfo);
+
+        _pw.flush();
+    }
+
+    public void introspect()
+        throws IntrospectionException {
+        introspect(Introspector.USE_ALL_BEANINFO);
+    }
+
+    private void introspectBeanInfo(BeanInfo beanInfo) {
+        printf("<bean-info name=\"%s\">", beanInfo.getBeanDescriptor().getBeanClass().getName());
+        indent();
+        {
+            introspectBeanDescriptor(beanInfo.getBeanDescriptor());
+
+            MethodDescriptor [] methodDescs = beanInfo.getMethodDescriptors();
+            if (methodDescs != null && methodDescs.length != 0) {
+                printf("<method-descriptors>");
+                indent();
+                introspectMethodDescriptors(methodDescs);
+                unindent();
+                printf("</method-descriptors>");
+            }
+            else printf("<method-descriptors/>");
+
+            PropertyDescriptor [] propDescs = beanInfo.getPropertyDescriptors();
+            if (propDescs != null && propDescs.length != 0) {
+                printf("<property-descriptors default-index=%d>", beanInfo.getDefaultPropertyIndex());
+                indent();
+                for (int i = 0; i < propDescs.length; i++)
+                    introspectPropertyDescriptor(propDescs[i],
+                                                 i == beanInfo.getDefaultPropertyIndex());
+                unindent();
+                printf("</property-descriptors>");
+            }
+            else printf("<property-descriptors/>");
+
+            EventSetDescriptor [] eventSetDescs = beanInfo.getEventSetDescriptors();
+            if (eventSetDescs != null && eventSetDescs.length != 0) {
+                printf("<event-set-descriptors default-index=%d>",
+                       beanInfo.getDefaultEventIndex());
+                indent();
+                for (int i = 0; i < eventSetDescs.length; i++)
+                    introspectEventSetDescriptor(eventSetDescs[i],
+                                                 i == beanInfo.getDefaultEventIndex());
+                unindent();
+                printf("</event-set-descriptors>");
+            }
+            else printf("<event-set-descriptors/>");
+
+            BeanInfo [] additionalBeanInfo = beanInfo.getAdditionalBeanInfo();
+            if (additionalBeanInfo != null && additionalBeanInfo.length != 0) {
+                printf("<additional-bean-info>");
+                indent();
+                {
+                    for (int i = 0; i < additionalBeanInfo.length; i++)
+                        introspectBeanInfo(additionalBeanInfo[i]);
+                }
+                unindent();
+                printf("</additional-bean-info>");
+            }
+            else printf("<additional-bean-info/>");
+        }
+        unindent();
+        printf("</bean-info>");
+    }
+
+    private void introspectBeanDescriptor(BeanDescriptor beanDesc) {
+        printf("<bean-descriptor name=\"%s\">", beanDesc.getDisplayName());
+        indent();
+        {
+            introspectFeatureDescriptor(beanDesc);;
+            printElement("bean-class", beanDesc.getBeanClass().getName());
+            Class customizerClass = beanDesc.getCustomizerClass();
+            if (customizerClass != null)
+                printElement("customizer-class", customizerClass.getName());
+        }
+        unindent();
+        printf("</bean-descriptor>");
+    }
+
+    private void introspectFeatureDescriptor(FeatureDescriptor featureDesc) {
+        printf("<feature-descriptor name=\"%s\"", featureDesc.getDisplayName());
+        indent();
+        {
+            printf("full-name=\"%s\"", featureDesc.getName());
+            printf("is-expert=%b", featureDesc.isExpert());
+            printf("is-hidden=%b", featureDesc.isHidden());
+            printf("is-preferred=%b>", featureDesc.isPreferred());
+
+            printElement("short-description", featureDesc.getShortDescription());
+
+            Enumeration<String> attrNames = featureDesc.attributeNames();
+            if (attrNames != null && attrNames.hasMoreElements()) {
+                SortedSet<String> sortedNames = new TreeSet<String>();
+                while (attrNames.hasMoreElements())
+                    sortedNames.add(attrNames.nextElement());
+                printf("<attributes>");
+                indent();
+                {
+                    for (String attrName: sortedNames) {
+                        // Convert the attribute value to a String, but drop any object ID
+                        // that is going to fail an equivalence comparison
+                        String attrValue = featureDesc.getValue(attrName).toString();
+                        int atIndex = attrValue.indexOf('@');
+                        if (atIndex > 0)
+                            attrValue = attrValue.substring(0, atIndex+1);
+
+                        printf("<attribute name=\"%s\" value=\"%s\">",
+                               attrName, attrValue);
+                    }
+                }
+                unindent();
+                printf("</attributes>");
+            }
+        }
+        unindent();
+        printf("</feature-descriptor>", featureDesc.getDisplayName());
+    }
+
+    /** * Provides a predictable ordering of method descriptors, based upon the underlying
+     * java.lang.reflect.Method attributes.  Uses the following tests:
+     *  - compare method names.  If equal, then:
+     *  - compare parameter list lengths.  If equals, then:
+     *  - compare parameter type names, in order, until they are unequal
+     */
+    static private class MethodDescriptorComparator
+        implements Comparator<MethodDescriptor> {
+
+        public int compare(MethodDescriptor md1, MethodDescriptor md2) {
+            Method m1 = md1.getMethod();
+            Method m2 = md2.getMethod();
+            int retval = m1.getName().compareTo(m2.getName());
+            if (retval == 0) {
+                Class [] parms1 = m1.getParameterTypes();
+                Class [] parms2 = m1.getParameterTypes();
+                if (parms1.length < parms2.length)
+                    retval = -1;
+                else if (parms1.length > parms2.length)
+                    retval = 1;
+                else {
+                    for (int i = 0; i < parms1.length; i++)
+                    {
+                        retval = parms1[i].getName().compareTo(parms2[i].getName());
+                        if (retval != 0)
+                            break;
+                    }
+                }
+            }
+            return retval;
+        }
+
+        public boolean equals(Object o) {
+            return o != null && o instanceof MethodDescriptorComparator;
+        }
+    }
+
+    /** Sorts an input array of MethodDescriptors */
+    private Set<MethodDescriptor> sortMethodDescriptors(MethodDescriptor [] methodDescs) {
+        Set<MethodDescriptor> sortedMethodDescs =
+            new TreeSet<MethodDescriptor>(new MethodDescriptorComparator());
+        for (int i = 0; i < methodDescs.length; i++)
+            sortedMethodDescs.add(methodDescs[i]);
+        return sortedMethodDescs;
+    }
+
+    private void introspectMethodDescriptors(MethodDescriptor [] methodDescs) {
+        Set<MethodDescriptor> sortedMethodDescs = sortMethodDescriptors(methodDescs);
+        for (MethodDescriptor methodDesc: sortedMethodDescs)
+            introspectMethodDescriptor(methodDesc);
+    }
+
+    private void introspectMethodDescriptor(MethodDescriptor methodDesc) {
+        printf("<method-descriptor name=\"%s\"", methodDesc.getDisplayName());
+        indent();
+        {
+            printElement("method", methodDesc.getMethod().toGenericString());
+            ParameterDescriptor [] paramDescs = methodDesc.getParameterDescriptors();
+            if (paramDescs != null && paramDescs.length != 0) {
+                printf("<parameter-descriptors>");
+                indent();
+                for (int i = 0; i < paramDescs.length; i++)
+                    introspectParameterDescriptor(paramDescs[i]);
+                unindent();
+                printf("</parameter-descriptors>");
+            }
+            else
+                printf("<param-descriptors/>");
+            introspectFeatureDescriptor(methodDesc);
+        }
+        unindent();
+        printf("</method-descriptor>");
+    }
+
+    private void introspectParameterDescriptor(ParameterDescriptor paramDesc) {
+        printf("<parameter-descriptor name=\"%s\">", paramDesc.getDisplayName());
+        indent();
+        introspectFeatureDescriptor(paramDesc);
+        unindent();
+        printf("</parameter-descriptor>", paramDesc.getDisplayName());
+    }
+
+    private void introspectPropertyDescriptor(PropertyDescriptor propDesc, boolean isDefault) {
+        printf("<property-descriptor name=\"%s\">", propDesc.getDisplayName());
+        indent();
+        {
+            printf("type=\"%s\"", propDesc.getPropertyType().getName());
+            printf("isBound=%b", propDesc.isBound());
+            printf("isConstrained=%b", propDesc.isConstrained());
+            printf("isDefault=%b>", isDefault);
+
+            Method readMethod = propDesc.getReadMethod();
+            if (readMethod != null)
+                printElement("read-method", readMethod.toGenericString());
+
+            Method writeMethod = propDesc.getWriteMethod();
+            if (writeMethod != null)
+                printElement("write-method", writeMethod.toGenericString());
+
+            Class propertyEditorClass = propDesc.getPropertyEditorClass();
+            if (propertyEditorClass != null)
+                printElement("property-editor-class", propertyEditorClass.getName());
+            introspectFeatureDescriptor(propDesc);
+        }
+        unindent();
+        printf("</property-descriptor>", propDesc.getDisplayName());
+    }
+
+    private void introspectEventSetDescriptor(EventSetDescriptor eventDesc, boolean isDefault) {
+        printf("<event-descriptor name=\"%s\"", eventDesc.getDisplayName());
+        indent();
+        {
+            printf("is-unicast=%b", eventDesc.isUnicast());
+            printf("is-in-default=%b", eventDesc.isInDefaultEventSet());
+            printf("is-default=%b>", isDefault);
+            printElement("listener-type", eventDesc.getListenerType().getName());
+
+            Method meth = eventDesc.getAddListenerMethod();
+            if (meth != null)
+                printElement("add-listener-method", meth.toGenericString());
+
+            meth = eventDesc.getRemoveListenerMethod();
+            if (meth != null)
+                printElement("remove-listener-method", meth.toGenericString());
+
+            meth = eventDesc.getGetListenerMethod();
+            if (meth != null)
+                printElement("get-listener-method", meth.toGenericString());
+
+            MethodDescriptor [] methodDescs = eventDesc.getListenerMethodDescriptors();
+            if (methodDescs != null && methodDescs.length != 0) {
+                printf("<listener-method-descriptors>");
+                indent();
+                introspectMethodDescriptors(methodDescs);
+                unindent();
+                printf("</listener-method-descriptors>");
+            }
+            else printf("<listener-method-descriptors/>");
+            introspectFeatureDescriptor(eventDesc);
+        }
+        unindent();
+    }
+
+    public static void main(String[] args)
+        throws Exception {
+
+        if (args.length < 1)
+            System.err.println("Usage: java org.apache.beehive.controls.test.controls.util.ControlIntrospector [-path <path>] beanClass");
+
+        String className = null;
+        String outputPath = null;
+        for(int i = 0; i < args.length; i++) {
+            if(args[i].equals("-outputPath")) {
+                if(i+1 < args.length)
+                    outputPath = args[i+1];
+                else throw new RuntimeException("Invalid command line; unable to find value for \"-outputPath\"");
+            }
+        }
+
+        className = args[args.length-1];
+        System.out.println("Create .beaninfo for class \"" + className + "\"");
+        if(outputPath != null)
+            System.out.println("Write .beaninfo to file \"" + outputPath + "\"");
+
+        Class beanClass = Class.forName(className);
+        PrintStream ps = System.out;
+        try {
+            if(outputPath != null)
+                ps = new PrintStream(new FileOutputStream(new File(outputPath)));
+
+            ControlIntrospector ci = new ControlIntrospector(beanClass, ps);
+            ci.introspect();
+        }
+        finally {
+            if(ps != null && ps != System.out)
+                ps.close();
+        }
+    }
+}