2016/02/07 - Apache Onami has been retired.

For more information, please explore the Attic.

The OnamiRunner

The core of Apache Onami-Test is the org.apache.onami.test.OnamiRunner class, that's a JUnit Runner and extends org.junit.internal.runners.BlockJUnit4ClassRunner For each test case the OnamiRunner initializes a google-guice injector before that your test case class is instantiated.

So you have an injector ready to use already into any method @BeforeClass.

Getting Started

To use Apache Onami-Test users have to annotate the junit test class in the following way:

@RunWith( OnamiRunner.class )
public class SimpleTest
{

   @com.google.inject.Inject
   private com.google.inject.Injector injector;

   @org.junit.BeforeClass
   public static void setUpYourClass()
   {
        // use injector.
        injector.getInstance( AcmeService.class );
   }

}

The Apache Onami-Test runner can be used also in a super class:

@com.google.inject.ImplementedBy( AcmeDatabasePoolImpl.class )
public interface AcmeDatabasePool
{

    void open();

    void close();
}
@RunWith( OnamiRunner.class )
public abstract class DatabasePoolInitTest
{

   @com.google.inject.Inject
   private static AcmeDatabasePool pool;

    public void setPool( AcmeDatabasePool pool )
    {
        this.pool = pool;
    }

    @org.junit.BeforeClass
    public static void setUpYourClass()
    {
        ...
        pool.open();
        ...
    }

    @org.junit.AfterClass
    public static void tearDownYourClass()
    {
        ...
        pool.close();
        ...
    }

}
public class DatabaseClassTest
    extends DatabasePoolInitTest
{

   @org.junit.Test
   public  void test()
   {
        ...
   }

}