Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7610719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:29:08+00:00 2026-05-31T01:29:08+00:00

I’d like to test some CDI classes. Today, I’m using Arquillian to do that

  • 0

I’d like to test some CDI classes.

Today, I’m using Arquillian to do that like that :

@RunWith(Arquillian.class)
public class MyCDIBeanTest {

    @Deployment
    public static JavaArchive createTestArchive() {
        return ShrinkWrap
                .create(JavaArchive.class, "test.jar")
                .addClasses(MyCDIBean.class)
                .addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
    }

    ...

Here is my current pom.xml :

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.10</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.jboss.arquillian.junit</groupId>
    <artifactId>arquillian-junit-container</artifactId>
    <version>1.0.0.CR6</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.jboss.arquillian.container</groupId>
    <artifactId>arquillian-container-test-spi</artifactId>
    <version>1.0.0.CR6</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.jboss.arquillian.container</groupId>
    <artifactId>arquillian-container-spi</artifactId>
    <version>1.0.0.CR6</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.jboss.arquillian.container</groupId>
    <artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
    <version>1.0.0.CR3</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.jboss.weld</groupId>
    <artifactId>weld-core</artifactId>
    <version>1.0.0.CR3</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.jboss.weld</groupId>
    <artifactId>weld-api</artifactId>
    <version>1.1.2.Final</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.jboss.weld</groupId>
    <artifactId>weld-spi</artifactId>
    <version>1.1.2.Final</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <scope>test</scope>
</dependency>

The versions are in the parent pom and weld and slf4j versions are imported with

<dependency>
    <groupId>org.jboss.weld</groupId>
    <artifactId>weld-core-bom</artifactId>
    <version>1.1.2.Final</version>
    <scope>import</scope>
    <type>pom</type>
</dependency>

Until now, all has been runnig well.

Today, I want to test some classes which use javax.el.ElContext and javax.el.ExpressionFactory.

They use Seam Solder to @Inject them.

So I added .addPackage(org.jboss.solder.el.Expressions.class.getPackage()) to ShrinkWrap.

But now here is what I got :

javax.el.ELException: Provider org.apache.el.ExpressionFactoryImpl not found
    at javax.el.FactoryFinder.newInstance(FactoryFinder.java:97)
    at javax.el.FactoryFinder.find(FactoryFinder.java:193)
    at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:185)
    at javax.el.ExpressionFactory.newInstance(ExpressionFactory.java:156)
    at org.jboss.solder.el.ExpressionFactoryProducer.createExpressionFactory(ExpressionFactoryProducer.java:35)

Does anybody knows how could I do that better ? (or just working)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:29:09+00:00Added an answer on May 31, 2026 at 1:29 am

    OK here is what I did (inspired by that question).

    First I deleted the .addPackage(Expressions.class.getPackage()).

    Then I added a dependency to Juel :

    <dependency>
        <!-- Used to simulate El expressions without Faces environment -->
        <groupId>de.odysseus.juel</groupId>
        <artifactId>juel-impl</artifactId>
        <version>2.2.4</version>
        <scope>test</scope>
    </dependency>
    

    Then in my test I added that code :

    /// Methods & variables for the elContext ///
    static SimpleContext elContext = new SimpleContext();
    static ExpressionFactory expressionFactory = new ExpressionFactoryImpl();
    
    @Produces @RequestScoped
    public static ELContext getElContext() {
        return elContext;
    }
    
    @Produces @RequestScoped
    public static ExpressionFactory getExpressionFactory() {
        return expressionFactory;
    }
    
    @Before
    public void reInitElContext() {
        elContext = new SimpleContext();
    }
    
    private void setElVariable(final String variableName, final Object variableValue) {
        setElVariable(variableName, variableValue, variableValue.getClass());
    }
    
    private void setElVariable(final String variableName, final Object variableValue, final Class<? extends Object> variableClass) {
        expressionFactory.createValueExpression(elContext, "#{"+variableName+"}", variableClass).setValue(elContext, variableValue);
    }
    
    private void setElNullVariable(final String variableName, final Class<?> variableClass) {
        setElVariable(variableName, null, variableClass);
    }
    
    /**
     * By default, set a null String variable
     * @param variableName
     */
    private void setElNullVariable(final String variableName) {
        setElNullVariable(variableName, String.class);
    }
    

    Now I can use setElVariable("variableName", "value") in my tests !

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.