Arquillian Google Guice Extension 1.0.0.Alpha2 Released

The Arquillian team is proud to announce the 1.0.0.Alpha2 release of the Arquillian Google Guice Extension component!

Some of the highlights in this release

Servlet integration

This release bring one new cool feature, integration with the Guice Servlet extension

The whole integration requires only two simple steps to make the test use the web configured Guice injector.

The first step is to replace the GuiceFilter with the ArquillianGuiceFilter:

web.xml
<filter>
   <filter-name>guiceFilter</filter-name>
   <filter-class>org.jboss.arquillian.guice.api.servlet.ArquillianGuiceFilter</filter-class>
</filter>

<filter-mapping>
   <filter-name>guiceFilter</filter-name>
   <url-pattern>/*</url-pattern>
</filter-mapping> 

This can also be done at runtime; by doing a simple string replacement in the web descriptor when creating the deployment or by using ShrinkWrap Descriptors.

The second step is to annotate your test with @GuiceWebConfiguration. This will instruct the extension to retrieve the injector from the servlet context.

Example test:

WebInjectorTestCase.java
@GuiceWebConfiguration
@RunWith(Arquillian.class)
public class WebInjectorTestCase {

   @Deployment
   public static Archive createTestArchive() {
       return ShrinkWrap.create(WebArchive.class, "guice-test.war")
               .addClasses(Employee.class,
                       EmployeeService.class, DefaultEmployeeService.class,
                       EmployeeRepository.class, DefaultEmployeeRepository.class,
                       EmployeeModule.class, EmployeeModuleContextListener.class)
               .addAsWebInfResource("WEB-INF/web.xml", "web.xml");
   }

   @Inject
   private EmployeeService employeeService;

   @Test
   public void testGetEmployees() {

       List<Employee> result = employeeService.getEmployees();

       assertNotNull("Method returned null list as result.", result);
       assertEquals("Two employees were expected.", 2, result.size());
   }
}

The test can go beyond a simple example like this and allow for injection of other resources like Guice configured servlets, filters and listeners.

We look forward to hearing your feedback about this release in the community forums!

What is Arquillian?

Arquillian is open source software that empowers you to test JVM-based applications more effectively. Created to defend the software galaxy from bugs, Arquillian brings your test to the runtime so you can focus on testing your application's behavior rather than managing the runtime. Using Arquillian, you can develop a comprehensive suite of tests from the convenience of your IDE and run them in any IDE, build tool or continuous integration environment.

Release details

Component Arquillian Google Guice Extension
Version 1.0.0.Alpha2 view tag
Release date 2013-08-01
Released by Aslak Knutsen
Compiled against

Published artifacts org.jboss.arquillian.extension

  • org.jboss.arquillian.extension » arquillian-guice-api jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-guice-impl jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-guice-bom pom
  • org.jboss.arquillian.extension » arquillian-guice-int-tests jar javadoc pom

Release notes and resolved issues 3

Feature Request
  • ARQ-1447 - Inject Injector created through GuiceFilter.
Bug
  • ARQ-1439 - NoClassDefFoundError for MavenDependencyResolver when using Google Guice Extension

Thanks to the following list of contributors: Jakub Narloch, Aslak Knutsen

Arquillian Google Guice Extension 1.0.0.Alpha1 Released

Since we wrote this post we didn't laze around. Check our latest announcement.

The Arquillian team is proud to announce the 1.0.0.Alpha1 release of the Arquillian Google Guice Extension component!

This is the first release of the Arquillian Guice extension. We’re bringing the next IOC container into the Arquillian universe.

Some of the highlights in this release

Dependency injection

Using this extension setting up a Guice test becomes pretty simple, allowing you to inject all Guice managed dependencies directly into the test case.

Built in Guice deployer

With the help of this extension you don’t need to add Guice to your deployments manually, the extension will take care of that for you.

There are two ways of enabling Guice injection in an Arquillian test case:
The first way is to annotate an Arquillian test case with @GuiceConfiguration. The annotation values allow you to specify the modules that will be passed to the injector instance on creation.

Example test:

AppointmentServiceImplTestCase.java
@RunWith(Arquillian.class)
@GuiceConfiguration(AppointmentModule.class)
public class AppointmentServiceImplTestCase {

   @Deployment
   public static JavaArchive createTestArchive() {
       return ShrinkWrap.create(JavaArchive.class, "guice-test.jar")
               .addClasses(Appointment.class,
                       AppointmentRepository.class, AppointmentRepositoryImpl.class,
                       AppointmentService.class, AppointmentServiceImpl.class,
                       AppointmentModule.class);
   }

   @Inject
   @Named("appointmentService")
   private AppointmentService appointmentService;

   @Test
   public void testGetAll() {

       Appointment appointment1 = createAppointment("Important", "Work", new Date());
       Appointment appointment2 = createAppointment("Do not forget", "Work", new Date());

       appointmentService.add(appointment1);
       appointmentService.add(appointment2);

       List<Appointment> result = appointmentService.getAll();
       assertNotNull("Method returned null.", result);
       assertEquals("Invalid element count, 2 appointments were expected.", 2, result.size());
   }
}

Where AppointmentModule is defined as fallows:

AppointmentModule.java
public class AppointmentModule implements Module {

    public void configure(Binder binder) {

        binder.bind(AppointmentRepository.class)
                .annotatedWith(Names.named("appointmentRepository"))
                .to(AppointmentRepositoryImpl.class);
        binder.bind(AppointmentService.class)
                .annotatedWith(Names.named("appointmentService"))
                .to(AppointmentServiceImpl.class);
    }
}

Guice configuration uses module instances instead of static classes known at compile time, which means that modules can have different state at runtime. Taking that into consideration, static annotation could in some cases be limiting. This is way we added a second possibility for enabling Guice. A static factory method could be added in the test case and annotated with @GuiceInjector that instantiates the Injector directly. The extension will invoke the method prior to test execution and based on the returned injector the dependencies will be available for injection. Is the previous test we would only need to add:

@GuiceInjector
public static Injector createInjector() {

    return Guice.createInjector(new AppointmentModule());
}

The extension defines some pretty simple settings to control how the packaging occur; specify the version of guice to package and if the auto packaging should happen at all.

arquillian.xml
<extension qualifier="guice">
     <property name="autoPackage">false</property>
     <property name="guiceVersion">3.0</property>
</extension>

We look forward to hearing your feedback about this release in the community forums!

What is Arquillian?

Arquillian is open source software that empowers you to test JVM-based applications more effectively. Created to defend the software galaxy from bugs, Arquillian brings your test to the runtime so you can focus on testing your application's behavior rather than managing the runtime. Using Arquillian, you can develop a comprehensive suite of tests from the convenience of your IDE and run them in any IDE, build tool or continuous integration environment.

Release details

Component Arquillian Google Guice Extension
Version 1.0.0.Alpha1 view tag
Release date 2013-06-19
Released by Aslak Knutsen
Compiled against

Published artifacts org.jboss.arquillian.extension

  • org.jboss.arquillian.extension » arquillian-guice-api jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-guice-impl jar javadoc pom
  • org.jboss.arquillian.extension » arquillian-guice-bom pom
  • org.jboss.arquillian.extension » arquillian-guice-int-tests jar javadoc pom

Release notes and resolved issues 1

Initial release of Arquillian Google Guice Extension

Thanks to the following list of contributors: Jakub Narloch, Aslak Knutsen

screenRecorder 1.0.0.Alpha1 Released

The Arquillian team is proud to announce the 1.0.0.Alpha1 release of the screenRecorder component!

What is Arquillian?

Arquillian is open source software that empowers you to test JVM-based applications more effectively. Created to defend the software galaxy from bugs, Arquillian brings your test to the runtime so you can focus on testing your application's behavior rather than managing the runtime. Using Arquillian, you can develop a comprehensive suite of tests from the convenience of your IDE and run them in any IDE, build tool or continuous integration environment.

Release details

Component screenRecorder
Version 1.0.0.Alpha1 view tag
Release date 2013-04-19
Released by Petr Mensik
Compiled against

Published artifacts org.jboss.arquillian.extension

  • org.jboss.arquillian.extension » arquillian-screen-recorder jar javadoc pom

Thanks to the following list of contributors: Petr Mensik, Jan Papoušek

Arquillian GWT Testing extension 1.0.0.Alpha2 Released

The Arquillian team is proud to announce the 1.0.0.Alpha2 release of the Arquillian GWT Testing extension component!

This is an update of the Arquillian GWT extension to remove the need for the custom GwtArchive class. Arquillian GWT tests can now leverage the standard ShrinkWrap API for specifiying their deployments. The WebArchive is automatically enhanced to include all dependencies and configurations relevant to the GWT deployment.

Here’s an updated example of a complete test class:

GreeterRpcTest.java

@RunWith(Arquillian.class)
public class GreeterRpcTest extends ArquillianGwtTestCase {

  @Deployment
  public static WebArchive createDeployment() {
    return ShrinkWrap.create(WebArchive.class, "test.war")
      .addClass(Greeter.class)
      .addClass(GreetingService.class)
      .addClass(GreetingServiceImpl.class)
      .addAsWebInfResource(new File("src/main/webapp/WEB-INF/web.xml"));
  }

  @Test
  @RunAsGwtClient(moduleName = "org.myapp.MyGwtModule")
  public void testGreetingService() {
    GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
    greetingService.greetServer("Hello!", new AsyncCallback<String>() {
      @Override
      public void onFailure(Throwable caught) {
        Assert.fail("Request failure: " + caught.getMessage());
      }

      @Override
      public void onSuccess(String result) {
        assertEquals("Received invalid response from Server", "Welcome!", result);
        finishTest();
      }
    });
    delayTestFinish(5000);
  }
}

Note that you will only need to extend ArquillianGwtTestCase if you want to inherit GWT’s asynchronous testing methods (finishTest and delayTestFinish).

We look forward to your feedback on this release in the community forums!

What is Arquillian?

Arquillian is open source software that empowers you to test JVM-based applications more effectively. Created to defend the software galaxy from bugs, Arquillian brings your test to the runtime so you can focus on testing your application's behavior rather than managing the runtime. Using Arquillian, you can develop a comprehensive suite of tests from the convenience of your IDE and run them in any IDE, build tool or continuous integration environment.

Release details

Component Arquillian GWT Testing extension
Version 1.0.0.Alpha2 view tag
Release date 2013-04-15
Released by Christian Sadilek
Compiled against

Published artifacts org.jboss.arquillian.extension

  • org.jboss.arquillian.extension » arquillian-gwt jar javadoc pom

Release notes and resolved issues 2

Automatic deployment archive enhancement for GWT

Feature Request
  • ARQ-1354 - Automatically enhance the deployment archive to include all dependencies and configurations relevant to the GWT deployment

Thanks to the following list of contributors: Christian Sadilek

Arquillian GWT Testing extension 1.0.0.Alpha1 Released

Since we wrote this post we didn't laze around. Check our latest announcement.

The Arquillian team is proud to announce the 1.0.0.Alpha1 release of the Arquillian GWT Testing extension component!

This is the first release of the Arquillian GWT extension which aims to bring true integration testing to GWT.

Highlighted Features

Run GWT integration tests in Arquillian containers

This means that GWT integration tests can break free and execute in the actual runtime container instead of being tied to GWT’s embedded Jetty server.

Combining client-side and in-container tests

It is possible to combine GWT client-side and standard in-container tests in the same test class. This allows to test features without having to worry about the client-server bridge and should pave the way for future support of Arquillian Warp and Drone in GWT integration tests.

Getting Started

To start using the Arquillian GWT extension just add the following dependency to your project:

pom.xml
<dependency>
    <groupId>org.jboss.arquillian.extension</groupId>
    <artifactId>arquillian-gwt</artifactId>
    <version>1.0.0.Alpha1</version>
</dependency>

Writing Arquillian GWT tests

To run a test method as a GWT integration test either annotate the test class or test method with @RunAsGwtClient and specifiy the GWT module. If you annotate the test class all test methods in that class will run as GWT integration tests.

MyTestClass.java

@RunWith(Arquillian.class)
public class MyTestClass {

  @Test 
  @RunAsGwtClient(moduleName = "org.myapp.MyGwtModule")
  public void myGwtTest() {

  }
}

To help packaging your app for the test deployment Arquillian GWT provides a simple utility called GwtArchive. The next version of Arquillian GWT will automatically enhance the used WebArchive. So, you won’t need to use this utility in the future. Here’s a complete example:

GreeterRpcTest.java

@RunWith(Arquillian.class)
public class GreeterRpcTest extends ArquillianGwtTestCase {

  @Deployment
  public static WebArchive createDeployment() {
    return GwtArchive.get()
      .addClass(Greeter.class)
      .addClass(GreetingService.class)
      .addClass(GreetingServiceImpl.class);
  }

  @Test
  @RunAsGwtClient(moduleName = "org.myapp.MyGwtModule")
  public void testGreetingService() {
    GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
    greetingService.greetServer("Hello!", new AsyncCallback<String>() {
      @Override
      public void onFailure(Throwable caught) {
        Assert.fail("Request failure: " + caught.getMessage());
      }

      @Override
      public void onSuccess(String result) {
        assertEquals("Received invalid response from Server", "Welcome!", result);
        finishTest();
      }
    });
    delayTestFinish(5000);
  }
}

Note that you will only need to extend ArquillianGwtTestCase if you want to inherit GWT’s asynchronous testing methods (finishTest and delayTestFinish).

We look forward to your feedback on this release in the community forums!

What is Arquillian?

Arquillian is open source software that empowers you to test JVM-based applications more effectively. Created to defend the software galaxy from bugs, Arquillian brings your test to the runtime so you can focus on testing your application's behavior rather than managing the runtime. Using Arquillian, you can develop a comprehensive suite of tests from the convenience of your IDE and run them in any IDE, build tool or continuous integration environment.

Release details

Component Arquillian GWT Testing extension
Version 1.0.0.Alpha1 view tag
Release date 2013-02-23
Released by Christian Sadilek
Compiled against

Published artifacts org.jboss.arquillian.extension

  • org.jboss.arquillian.extension » arquillian-gwt jar javadoc pom

Release notes and resolved issues 1

Initial prototype release

Thanks to the following list of contributors: Christian Sadilek, Karel Piwko, Aslak Knutsen