Skip to content

Instantly share code, notes, and snippets.

@rmpestano
Last active March 12, 2016 20:12
Show Gist options
  • Select an option

  • Save rmpestano/6a38d46145a6a6cf3c18 to your computer and use it in GitHub Desktop.

Select an option

Save rmpestano/6a38d46145a6a6cf3c18 to your computer and use it in GitHub Desktop.
How to Intercept an arquillian test?
@RunWith(Arquillian.class)
@MyInterceptor
public class ItTest {

    @Deployment
    public static Archive<?> createDeployment() {

        WebArchive war = Deployments.getBaseDeployment();
        //war.addAsWebInfResource(new File(WEB_INF, "beans.xml"), "beans.xml");
        war.addAsResource(new File(WEB_INF, "beans.xml"), "META-INF/beans.xml");//beans.xml enables the interceptor
        war.addClass(ItTest.class);
        return war;

    }

  @Test
  public void test(){
    // interceptor should be called...or not
  }

}
Note
interceptor is inside a jar(which has beans.xml) which is added into test deployment.
beans.xml:
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
		http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       bean-discovery-mode="all">

        <interceptors>
        //
        </interceptors>
</beans>
@CharlesQueiroz
Copy link
Copy Markdown

Rafael, você conseguiu uma resposta para esse questionamento?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment