View Javadoc

1   package org.apache.onami.test;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
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  }