| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 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 |
| 29 |
|
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 6 |
Complexity Density: 0.4 |
|
| 30 |
|
public class ErrorHandlingTest { |
| 31 |
|
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.31 |
|
| 32 |
0
|
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() { |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 42 |
0
|
protected void configure() {... |
| 43 |
0
|
bind(String.class).toProvider(new Provider<String>() { |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 44 |
0
|
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 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
| 66 |
|
static class NeedsString { |
| 67 |
|
@Inject String mofo; |
| 68 |
|
} |
| 69 |
|
|
| 70 |
|
@Inject @Named("missing") |
| 71 |
|
static List<String> missing = null; |
| 72 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 2 |
Complexity Density: - |
|
| 73 |
|
static class Foo { |
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 74 |
0
|
@Inject... |
| 75 |
|
public Foo(Runnable r) {} |
| 76 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 77 |
0
|
@Inject void setNames(List<String> names) {}... |
| 78 |
|
} |
| 79 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 3 |
Complexity Density: - |
|
| 80 |
|
static class Bar { |
| 81 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 82 |
0
|
Bar(String s) {}... |
| 83 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 84 |
0
|
@Inject void setNumbers(@Named("numbers") List<Integer> numbers) {}... |
| 85 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 86 |
0
|
@Inject void bar(@Named("foo") String s) {}... |
| 87 |
|
} |
| 88 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: - |
|
| 89 |
|
static class Tee { |
| 90 |
|
@Inject String s; |
| 91 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 92 |
0
|
@Inject void tee(String s, int i) {}... |
| 93 |
|
|
| 94 |
|
@Inject Invalid invalid; |
| 95 |
|
} |
| 96 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: - |
|
| 97 |
|
static class Invalid { |
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 98 |
0
|
Invalid(String s) {}... |
| 99 |
|
} |
| 100 |
|
|
| 101 |
|
@Singleton @GoodScope |
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
| 102 |
|
static class TooManyScopes { |
| 103 |
|
} |
| 104 |
|
|
| 105 |
|
@Target(ElementType.TYPE) |
| 106 |
|
@Retention(RUNTIME) |
| 107 |
|
@ScopeAnnotation |
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
| 108 |
|
@interface GoodScope {} |
| 109 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
| 110 |
|
@interface BadScope {} |
| 111 |
|
|