1 /* 2 * Copyright (C) 2012 The Guava Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.common.eventbus.outside; 18 19 import static com.google.common.truth.Truth.assertThat; 20 21 import com.google.common.collect.Lists; 22 import com.google.common.eventbus.Subscribe; 23 import com.google.common.eventbus.outside.AnnotatedAndAbstractInSuperclassTest.SubClass; 24 import java.util.List; 25 26 public class AnnotatedAndAbstractInSuperclassTest extends AbstractEventBusTest<SubClass> { 27 abstract static class SuperClass { 28 @Subscribe overriddenAndAnnotatedInSubclass(Object o)29 public abstract void overriddenAndAnnotatedInSubclass(Object o); 30 31 @Subscribe overriddenInSubclass(Object o)32 public abstract void overriddenInSubclass(Object o); 33 } 34 35 static class SubClass extends SuperClass { 36 final List<Object> overriddenAndAnnotatedInSubclassEvents = Lists.newArrayList(); 37 final List<Object> overriddenInSubclassEvents = Lists.newArrayList(); 38 39 @Subscribe 40 @Override overriddenAndAnnotatedInSubclass(Object o)41 public void overriddenAndAnnotatedInSubclass(Object o) { 42 overriddenAndAnnotatedInSubclassEvents.add(o); 43 } 44 45 @Override overriddenInSubclass(Object o)46 public void overriddenInSubclass(Object o) { 47 overriddenInSubclassEvents.add(o); 48 } 49 } 50 testOverriddenAndAnnotatedInSubclass()51 public void testOverriddenAndAnnotatedInSubclass() { 52 assertThat(getSubscriber().overriddenAndAnnotatedInSubclassEvents).contains(EVENT); 53 } 54 testOverriddenNotAnnotatedInSubclass()55 public void testOverriddenNotAnnotatedInSubclass() { 56 assertThat(getSubscriber().overriddenInSubclassEvents).contains(EVENT); 57 } 58 59 @Override createSubscriber()60 SubClass createSubscriber() { 61 return new SubClass(); 62 } 63 } 64