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/05/22 22:15:24 UTC

svn commit: r408746 - in /beehive/trunk/controls: src/runtime/org/apache/beehive/controls/runtime/generator/ test/src/junit-controls/org/apache/beehive/controls/test/controls/emptyeventset/ test/src/junit-tests/org/apache/beehive/controls/test/junit/

Author: cschoett
Date: Mon May 22 13:15:24 2006
New Revision: 408746

URL: http://svn.apache.org/viewvc?rev=408746&view=rev
Log:
Fix for BEEHIVE-1113, updated ControlMacros velocity template to not cause a compilation error
for empty event sets.  Added new junit test for this case.


Added:
    beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/emptyeventset/
    beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/emptyeventset/EmptyEvent.java   (with props)
    beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/emptyeventset/EmptyEventImpl.java   (with props)
Modified:
    beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlMacros.vm
    beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/EventsetAptTest.java

Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlMacros.vm
URL: http://svn.apache.org/viewvc/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlMacros.vm?rev=408746&r1=408745&r2=408746&view=diff
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlMacros.vm (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlMacros.vm Mon May 22 13:15:24 2006
@@ -61,6 +61,16 @@
 ## are associated with declared operations
 ##
 #macro (initMethodStatics)
+
+  ## First verify that if an eventSet was defined it is not empty.
+  #set($eCount=0)
+  #foreach($eventSet in $intf.eventSets)
+      #foreach($event in $eventSet.events)
+          #set($eCount=$eCount+1)
+      #end
+  #end
+
+  #if ($intf.operations.size() > 0 || $eCount > 0)
     try
     {
         #foreach ($operation in $intf.operations)
@@ -78,4 +88,5 @@
     {
         throw new ExceptionInInitializerError(__bc_nsme);
     }
+  #end
 #end

Added: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/emptyeventset/EmptyEvent.java
URL: http://svn.apache.org/viewvc/beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/emptyeventset/EmptyEvent.java?rev=408746&view=auto
==============================================================================
--- beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/emptyeventset/EmptyEvent.java (added)
+++ beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/emptyeventset/EmptyEvent.java Mon May 22 13:15:24 2006
@@ -0,0 +1,31 @@
+/*
+   Copyright 2004-2005 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.emptyeventset;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+import org.apache.beehive.controls.api.events.EventSet;
+
+@ControlInterface
+public interface EmptyEvent {
+
+    @EventSet()
+    public interface Callback {
+    }
+}
+
+

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

Added: beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/emptyeventset/EmptyEventImpl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/emptyeventset/EmptyEventImpl.java?rev=408746&view=auto
==============================================================================
--- beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/emptyeventset/EmptyEventImpl.java (added)
+++ beehive/trunk/controls/test/src/junit-controls/org/apache/beehive/controls/test/controls/emptyeventset/EmptyEventImpl.java Mon May 22 13:15:24 2006
@@ -0,0 +1,36 @@
+/*
+   Copyright 2004-2005 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.emptyeventset;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+import org.apache.beehive.controls.api.bean.Extensible;
+import java.lang.reflect.Method;
+
+@ControlImplementation(isTransient=true)
+public class EmptyEventImpl implements EmptyEvent, Extensible {
+
+    public String hello() {
+        return "Hello!";
+    }
+
+    public Object invoke(Method m, Object[] args) throws Throwable
+    {
+	System.out.println("Invoked!");
+	return "Hello";
+    }
+}

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

Modified: beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/EventsetAptTest.java
URL: http://svn.apache.org/viewvc/beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/EventsetAptTest.java?rev=408746&r1=408745&r2=408746&view=diff
==============================================================================
--- beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/EventsetAptTest.java (original)
+++ beehive/trunk/controls/test/src/junit-tests/org/apache/beehive/controls/test/junit/EventsetAptTest.java Mon May 22 13:15:24 2006
@@ -22,6 +22,7 @@
 import org.apache.beehive.controls.test.controls.eventsetApt.UnicastExt;
 import org.apache.beehive.controls.test.controls.eventsetApt.NoMethodsExt;
 import org.apache.beehive.controls.test.controls.eventsetControlExt.EventExt;
+import org.apache.beehive.controls.test.controls.emptyeventset.EmptyEvent;
 
 /**
  * Junit tests for making sure that APT can generate controls with eventsets when
@@ -43,12 +44,21 @@
     private NoMethodsExt _noMethods;
 
     @Control
+    private EmptyEvent _emptyEvent;
+
+    @Control
     private EventExt _eventExt;
 
+    /**
+     * Test multicast event set.
+     */
     public void testMulticastEvtApt() {
         assertNotNull(_multicastEvts);
     }
 
+    /**
+     * Test unicast event set.
+     */
     public void testUnicastEvtApt() {
         assertNotNull(_unicastEvts);
     }
@@ -68,5 +78,12 @@
      */
     public void testNoMethodsEvtSet() {
         assertNotNull(_noMethods);
+    }
+
+    /**
+     * Test compilation of an event set with no methods.
+     */
+    public void testEmptyEventSet() {
+        assertNotNull(_emptyEvent);
     }
 }