• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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;
18 
19 import com.google.common.testing.AbstractPackageSanityTests;
20 
21 import java.lang.reflect.Method;
22 
23 import javax.annotation.Nullable;
24 
25 /**
26  * Basic sanity tests for the entire package.
27  *
28  * @author Ben Yu
29  */
30 
31 public class PackageSanityTests extends AbstractPackageSanityTests {
32 
PackageSanityTests()33   public PackageSanityTests() throws Exception {
34     setDefault(EventSubscriber.class, new DummySubscriber().toEventSubscriber());
35     setDefault(Method.class, DummySubscriber.subscriberMethod());
36   }
37 
38   private static class DummySubscriber {
39 
40     @SuppressWarnings("unused") // Used by reflection
handle(@ullable Object anything)41     public void handle(@Nullable Object anything) {}
42 
toEventSubscriber()43     EventSubscriber toEventSubscriber() throws Exception {
44       return new EventSubscriber(this, subscriberMethod());
45     }
46 
subscriberMethod()47     private static Method subscriberMethod() throws NoSuchMethodException {
48       return DummySubscriber.class.getMethod("handle", Object.class);
49     }
50   }
51 }
52