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 com.google.common.eventbus.EventBus; 20 import junit.framework.TestCase; 21 22 /** 23 * Abstract base class for tests that EventBus finds the correct subscribers. 24 * 25 * <p>The actual tests are distributed among the other classes in this package based on whether they 26 * are annotated or abstract in the superclass. 27 * 28 * <p>This test must be outside the c.g.c.eventbus package to test correctly. 29 * 30 * @author Louis Wasserman 31 */ 32 abstract class AbstractEventBusTest<H> extends TestCase { 33 static final Object EVENT = new Object(); 34 createSubscriber()35 abstract H createSubscriber(); 36 37 private H subscriber; 38 getSubscriber()39 H getSubscriber() { 40 return subscriber; 41 } 42 43 @Override setUp()44 protected void setUp() throws Exception { 45 subscriber = createSubscriber(); 46 EventBus bus = new EventBus(); 47 bus.register(subscriber); 48 bus.post(EVENT); 49 } 50 51 @Override tearDown()52 protected void tearDown() throws Exception { 53 subscriber = null; 54 } 55 } 56