Clover Coverage Report - guice
Coverage timestamp: Tue Jan 6 2009 19:08:51 CST
../../../img/srcFileCovDistChart0.png 84% of files have more coverage
34   146   16   2.83
0   103   0.47   1.09
12     1.33  
11    
 
  ErrorHandlingTest       Line # 30 15 6 18 0% 0.0
  ErrorHandlingTest.NeedsString       Line # 66 0 0 0 - -1.0
  ErrorHandlingTest.Foo       Line # 73 0 2 2 0% 0.0
  ErrorHandlingTest.Bar       Line # 80 0 3 3 0% 0.0
  ErrorHandlingTest.Tee       Line # 89 0 1 1 0% 0.0
  ErrorHandlingTest.Invalid       Line # 97 0 1 1 0% 0.0
  ErrorHandlingTest.TooManyScopes       Line # 102 0 0 0 - -1.0
  ErrorHandlingTest.GoodScope       Line # 108 0 0 0 - -1.0
  ErrorHandlingTest.BadScope       Line # 110 0 0 0 - -1.0
  ErrorHandlingTest.I       Line # 113 0 0 0 - -1.0
  ErrorHandlingTest.MyModule       Line # 115 19 3 21 0% 0.0
 
No Tests
 
1    /**
2    * Copyright (C) 2006 Google Inc.
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.inject;
18   
19    import com.google.inject.name.Named;
20    import com.google.inject.name.Names;
21    import java.lang.annotation.ElementType;
22    import java.lang.annotation.Retention;
23    import static java.lang.annotation.RetentionPolicy.RUNTIME;
24    import java.lang.annotation.Target;
25    import java.util.List;
26   
27    /**
28    * @author crazybob@google.com (Bob Lee)
29    */
 
30    public class ErrorHandlingTest {
31   
 
32  0 toggle public static void main(String[] args) throws CreationException {
33  0 try {
34  0 Guice.createInjector(new MyModule());
35    }
36    catch (CreationException e) {
37  0 e.printStackTrace();
38  0 System.err.println("--");
39    }
40   
41  0 Injector bad = Guice.createInjector(new AbstractModule() {
 
42  0 toggle protected void configure() {
43  0 bind(String.class).toProvider(new Provider<String>() {
 
44  0 toggle public String get() {
45  0 return null;
46    }
47    });
48    }
49    });
50  0 try {
51  0 bad.getInstance(String.class);
52    }
53    catch (Exception e) {
54  0 e.printStackTrace();
55  0 System.err.println("--");
56    }
57  0 try {
58  0 bad.getInstance(NeedsString.class);
59    }
60    catch (Exception e) {
61  0 e.printStackTrace();
62  0 System.err.println("--");
63    }
64    }
65   
 
66    static class NeedsString {
67    @Inject String mofo;
68    }
69   
70    @Inject @Named("missing")
71    static List<String> missing = null;
72   
 
73    static class Foo {
 
74  0 toggle @Inject
75    public Foo(Runnable r) {}
76   
 
77  0 toggle @Inject void setNames(List<String> names) {}
78    }
79   
 
80    static class Bar {
81    // Invalid constructor.
 
82  0 toggle Bar(String s) {}
83   
 
84  0 toggle @Inject void setNumbers(@Named("numbers") List<Integer> numbers) {}
85   
 
86  0 toggle @Inject void bar(@Named("foo") String s) {}
87    }
88   
 
89    static class Tee {
90    @Inject String s;
91   
 
92  0 toggle @Inject void tee(String s, int i) {}
93   
94    @Inject Invalid invalid;
95    }
96   
 
97    static class Invalid {
 
98  0 toggle Invalid(String s) {}
99    }
100   
101    @Singleton @GoodScope
 
102    static class TooManyScopes {
103    }
104   
105    @Target(ElementType.TYPE)
106    @Retention(RUNTIME)
107    @ScopeAnnotation
 
108    @interface GoodScope {}
109   
 
110    @interface BadScope {}
111