[arquillian-issues] [JBoss JIRA] Issue Comment Edited: (ARQ-321) Test enrichers should provide a ready-made auxiliary archive dependency

Aslak Knutsen (JIRA) jira-events at lists.jboss.org
Sun Feb 6 11:44:39 EST 2011


    [ https://issues.jboss.org/browse/ARQ-321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12580363#comment-12580363 ] 

Aslak Knutsen edited comment on ARQ-321 at 2/6/11 11:44 AM:
------------------------------------------------------------

The reason why the containers have their own v. is they rely on providing e.g. the InitialContext or BeanManager so the enricher can function. 

If we turn this around a bit, and let the Enrichers operate if a InitialContext or a BeanManager is found in the Arquillian context, the containers would merely have to produce the correct types. The enrichers don't care if this happens client side or incontainer either, instant client side enrichment support(just a different producer).

e.g. 

{code}

public class JBossASContextProducer
{
  @Inject @SuiteScoped
  private InstanceProducer<InitialContext> context;

  public void createContext(@Observes BeforeSuite event)
  {
    context.set(new InitialContext()); // this will trigger listeners for InitialContext
  }
}

public class CDIBeanManagerProducer
{
  @Inject @TestScoped
  private InstanceProducer<BeanManager> manager;

  public void onContextCreation(@Observes InitialContext context)
  {
    if(context.lookup("beanmanager") != null)
    {
      manager.set(context.loopup(""))
    }
  }
}

public class CDIEnricher 
{
  @Inject
  private Instance<BeanManager> beanManager;

  public void enrich(Object test)
  {
    if(beanManager.get() != null)
    {
      // do stuff..
    }
  }
}

{code}


      was (Author: aslak):
    The current reason why the containers have their own v. today is they rely on providing e.g. the InitialContext or BeanManager so the enricher can function. 

If we turn this around a bit, and let the Enrichers operate if a InitialContext or a BeanManager is found in the Arquillian context, the containers would merely have to produce the correct types. The enrichers don't care if this happens client side or incontainer either, instant client side enrichment support(just a different producer).

e.g. 

{code}

public class JBossASContextProducer
{
  @Inject @SuiteScoped
  private InstanceProducer<InitialContext> context;

  public void createContext(@Observes BeforeSuite event)
  {
    context.set(new InitialContext()); // this will trigger listeners for InitialContext
  }
}

public class CDIBeanManagerProducer
{
  @Inject @TestScoped
  private InstanceProducer<BeanManager> manager;

  public void onContextCreation(@Observes InitialContext context)
  {
    if(context.lookup("beanmanager") != null)
    {
      manager.set(context.loopup(""))
    }
  }
}

public class CDIEnricher 
{
  @Inject
  private Instance<BeanManager> beanManager;

  public void enrich(Object test)
  {
    if(beanManager.get() != null)
    {
      // do stuff..
    }
  }
}

{code}

  
> Test enrichers should provide a ready-made auxiliary archive dependency
> -----------------------------------------------------------------------
>
>                 Key: ARQ-321
>                 URL: https://issues.jboss.org/browse/ARQ-321
>             Project: Arquillian
>          Issue Type: Feature Request
>          Components: Packaging Enricher SPI, Runtime Enricher SPI
>    Affects Versions: 1.0.0.Alpha4
>            Reporter: Dan Allen
>            Priority: Minor
>             Fix For: 1.0.0.CR1
>
>
> Each test enrichers implementation should provide a dependency that packages the test enricher as an auxiliary archive. Currently, a container adapter will assemble an auxiliary archive of the test enrichers that are supported by that container. But there are cases when the container may have been enhanced with additional capabilities that allow it to support an additional enricher. At this point, it's up to the developer to package the enricher.
> We could alleviate this requirement by providing ready-made test enrichers that include the auxiliary archive packaging. This supplementary dependency could be named using an additional classifier on the test enricher artifact, as such:
> <groupId>org.jboss.arquillian.testenricher</groupId>
> <artifactId>arquillian-testenricher-cdi</artifactId>
> <classifier>auxiliary-archive</classifier>
> <version>...</version>
> This will give you not only the test enricher, but also enlistment as an auxiliary archive. The containers will still do their own packaging...this is for standalone usage.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the arquillian-issues mailing list