You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by cs...@apache.org on 2006/06/28 22:28:26 UTC

svn commit: r417867 - in /beehive/trunk/controls: src/runtime/org/apache/beehive/controls/runtime/generator/ test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/ test/src/junit-tests/org/apache/beehive/controls/test/ju...

Author: cschoett
Date: Wed Jun 28 13:28:25 2006
New Revision: 417867

URL: http://svn.apache.org/viewvc?rev=417867&view=rev
Log:
Fix for BEEHIVE-998, Compilation error for generated client initializer due to generated eventAdaptor not implementing methods in super intf of EventSet intf

The fix consisted of the modification of the ClientInitializer velocity template to add eventset superclass methods to the generated event adapter inner class of a client initializer.  Also added a new test for this case.

DRTs: controls, passed


Added:
    beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/
    beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/BaseEventSet.java   (with props)
    beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/CtrlBase.java   (with props)
    beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/CtrlBaseImpl.java   (with props)
    beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/CtrlExt.java   (with props)
    beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/EventSetInheritanceTest.java   (with props)
Modified:
    beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ClientInitializer.vm

Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ClientInitializer.vm
URL: http://svn.apache.org/viewvc/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ClientInitializer.vm?rev=417867&r1=417866&r2=417867&view=diff
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ClientInitializer.vm (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ClientInitializer.vm Wed Jun 28 13:28:25 2006
@@ -79,6 +79,17 @@
             #end
             }
         #end
+
+        #foreach ($superEvent in $eventSet.superEventSet.events)
+            public ${superEvent.getReturnType($binding)} ${superEvent.name}(${superEvent.getArgDecl($binding)}) $superEvent.throwsClause
+            {
+            #if ($adaptor.hasHandler($superEvent))
+                #if ($superEvent.returnType != "void") return #end __bc_client.${adaptor.getHandler($superEvent).name}(${superEvent.argList});
+            #elseif ($superEvent.returnType != "void")
+                return $superEvent.getDefaultReturnValue($binding);
+            #end
+            }
+        #end
     }
 
 #end

Added: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/BaseEventSet.java
URL: http://svn.apache.org/viewvc/beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/BaseEventSet.java?rev=417867&view=auto
==============================================================================
--- beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/BaseEventSet.java (added)
+++ beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/BaseEventSet.java Wed Jun 28 13:28:25 2006
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2006 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.eventsetInheritance;
+
+import org.apache.beehive.controls.api.events.EventSet;
+
+/**
+ * Declares an EventSet.
+ */
+@EventSet()
+public interface BaseEventSet {
+      void baseEventSetMethod();
+}

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

Added: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/CtrlBase.java
URL: http://svn.apache.org/viewvc/beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/CtrlBase.java?rev=417867&view=auto
==============================================================================
--- beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/CtrlBase.java (added)
+++ beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/CtrlBase.java Wed Jun 28 13:28:25 2006
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2006 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.eventsetInheritance;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+import org.apache.beehive.controls.api.events.EventSet;
+
+/**
+ * Control for testing apt compilation of control extensions whose base
+ * class implement an EventSet.
+ */
+@ControlInterface
+public interface CtrlBase {
+
+    @EventSet()
+    public static interface CtrlBaseCallback extends BaseEventSet {
+        void method1();
+    }
+}

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

Added: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/CtrlBaseImpl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/CtrlBaseImpl.java?rev=417867&view=auto
==============================================================================
--- beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/CtrlBaseImpl.java (added)
+++ beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/CtrlBaseImpl.java Wed Jun 28 13:28:25 2006
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2006 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.eventsetInheritance;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.bean.Extensible;
+import org.apache.beehive.controls.api.events.Client;
+
+import java.lang.reflect.Method;
+
+/**
+ * Control for testing apt compilation of control extensions whose base
+ * class implement an EventSet.
+ */
+@ControlImplementation(isTransient=true)
+public class CtrlBaseImpl implements CtrlBase, Extensible {
+
+    @Client CtrlExt.CtrlExtCallback client;
+
+    public Object invoke(Method m, Object[] args) throws Throwable
+    {
+        client.baseEventSetMethod();
+        return null;
+    }
+}

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

Added: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/CtrlExt.java
URL: http://svn.apache.org/viewvc/beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/CtrlExt.java?rev=417867&view=auto
==============================================================================
--- beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/CtrlExt.java (added)
+++ beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/eventsetInheritance/CtrlExt.java Wed Jun 28 13:28:25 2006
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2006 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.eventsetInheritance;
+
+import org.apache.beehive.controls.api.bean.ControlExtension;
+import org.apache.beehive.controls.api.events.EventSet;
+
+/**
+ * Control extension which defines an event set which extends the
+ * eventset defined in CtrlBase.
+ */
+@ControlExtension
+public interface CtrlExt extends CtrlBase
+{
+    public void runTest();
+
+    @EventSet
+    public interface CtrlExtCallback extends CtrlBase.CtrlBaseCallback {
+        public void  method11();
+    }
+
+}

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

Added: beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/EventSetInheritanceTest.java
URL: http://svn.apache.org/viewvc/beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/EventSetInheritanceTest.java?rev=417867&view=auto
==============================================================================
--- beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/EventSetInheritanceTest.java (added)
+++ beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/EventSetInheritanceTest.java Wed Jun 28 13:28:25 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 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 org.apache.beehive.controls.api.bean.Control;
+import org.apache.beehive.controls.api.events.EventHandler;
+import org.apache.beehive.controls.test.controls.eventsetInheritance.CtrlExt;
+
+/**
+ * Junit test to verify that eventset inheritance is working correctly at both compile time and run time.
+ */
+public class EventSetInheritanceTest
+    extends ControlTestCase {
+
+    @Control
+    private CtrlExt _ctrlExt;
+
+    private boolean _handlerInvoked;
+
+    public void setUp() throws Exception {
+        super.setUp();
+        _handlerInvoked = false;
+    }
+
+    /**
+     * Test event set inheritance.
+     */
+    public void testEventSetInheritance() {
+        assertNotNull(_ctrlExt);
+        _ctrlExt.runTest();
+        assertTrue(_handlerInvoked);
+    }
+
+    @EventHandler(field="_ctrlExt", eventSet=CtrlExt.CtrlExtCallback.class, eventName="baseEventSetMethod")
+    public void myHandler() {
+        _handlerInvoked = true;
+    }
+}

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