1 package org.apache.onami.test;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.ArrayList;
23
24 import org.apache.onami.test.OnamiRunner;
25 import org.apache.onami.test.annotation.GuiceModules;
26 import org.apache.onami.test.annotation.GuiceProvidedModules;
27 import org.apache.onami.test.data.SimpleModule;
28 import org.junit.runner.RunWith;
29
30 import com.google.inject.AbstractModule;
31 import com.google.inject.Module;
32 import com.google.inject.name.Names;
33
34 @RunWith( OnamiRunner.class )
35 @GuiceModules( SimpleModule.class )
36 abstract public class AbstractTestCase
37 extends AbstractEmptyTestCase
38 {
39
40 @GuiceProvidedModules
41 public static Module genericModule()
42 {
43 return new AbstractModule()
44 {
45 @Override
46 protected void configure()
47 {
48 bind( String.class ).annotatedWith( Names.named( "test.info.inject" ) ).toInstance( "JUnice = JUnit + Guice" );
49 }
50 };
51 }
52
53 @GuiceProvidedModules
54 public static Iterable<Module> genericModule2()
55 {
56 AbstractModule a = new AbstractModule()
57 {
58 @Override
59 protected void configure()
60 {
61 bind( String.class ).annotatedWith( Names.named( "test.info.inject2" ) ).toInstance( "JUnice = JUnit + Guice Iterable" );
62 }
63 };
64
65 ArrayList<Module> al = new ArrayList<Module>();
66 al.add( a );
67 return al;
68 }
69
70 @GuiceProvidedModules
71 public static Module[] genericModule3()
72 {
73 AbstractModule a = new AbstractModule()
74 {
75 @Override
76 protected void configure()
77 {
78 bind( String.class ).annotatedWith( Names.named( "test.info.inject3" ) ).toInstance( "JUnice = JUnit + Guice Array" );
79 }
80 };
81 return new Module[] { a };
82 }
83
84 }