shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdem...@apache.org
Subject [02/13] shiro git commit: SHIRO-395: added initial implementation - all org.apache.shiro.event.** additions are at 100% test coverage.
Date Mon, 11 Jul 2016 21:04:29 GMT
http://git-wip-us.apache.org/repos/asf/shiro/blob/bbc8efac/core/src/test/groovy/org/apache/shiro/event/bus/TestSubscriber.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/groovy/org/apache/shiro/event/bus/TestSubscriber.groovy b/core/src/test/groovy/org/apache/shiro/event/bus/TestSubscriber.groovy
new file mode 100644
index 0000000..3de5488
--- /dev/null
+++ b/core/src/test/groovy/org/apache/shiro/event/bus/TestSubscriber.groovy
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.shiro.event.bus
+
+import org.apache.shiro.event.Subscribe
+
+/**
+ * @since 1.3
+ */
+class TestSubscriber {
+
+    int fooCount, barCount
+    Object lastEvent;
+
+    TestSubscriber() {
+        fooCount = barCount = 0
+    }
+
+    @Subscribe
+    void onFooEvent(FooEvent event) {
+        fooCount++
+        lastEvent = event;
+    }
+
+    @Subscribe
+    void onBarEvent(BarEvent event) {
+        barCount++
+        lastEvent = event;
+    }
+
+    int getCount() {
+        return fooCount + barCount
+    }
+}


Mime
View raw message