Questions tagged [cdi-unit]

CDI-Unit is a JUnit 4 and TestNG test runner that enables unit testing Java CDI applications.

CDI-Unit is a JUnit 4 and TestNG test runner that enables unit testing Java CDI applications.

The tests run outside of a web container. The configuration is performed in the unit test class using annotations.

21 questions
7
votes
1 answer

CdiUnit test with Junit @Rule is impossible because of a public private field paradox

The following snippet is enough to reproduce my problem: Either I set the thrown attribute public and get the error org.jboss.weld.exceptions.DefinitionException: WELD-000075: Normal scoped managed bean implementation class has a public field Or I…
Aldian
  • 2,481
  • 2
  • 24
  • 38
3
votes
2 answers

Injection of @PersistenceContext in CDI-Unit

Here is the unit testing code. When we run unit test code (SampleServiceTest2); EntityManager injected in AbstractDao is always null! How can we inject em during unit test. *** SampleServiceTest2.java import javax.inject.Inject; import…
fatihn
  • 117
  • 1
  • 8
3
votes
1 answer

Java EE JUnit not working with CDI-Unit while using EJBs

I'm using the CDI-Unit JAR http://jglue.org/cdi-unit/ to be able to use CDI in my JUnit 4 tests, I've injected my EJB and called a method to persist a Client object, but I get the following error : java.lang.NoClassDefFoundError…
dwix
  • 844
  • 2
  • 11
  • 30
3
votes
2 answers

Cannot inject EntityManager declared in persistence.xml

I'm trying to develop a (Maven-based) jar library which can act as a DAL for my Java application. This is my persistence.xml file
gvdm
  • 2,373
  • 4
  • 29
  • 59
3
votes
3 answers

Unit testing CDI with CDI-Unit Jglue

we want to use Jglue framework for unit testing our CDI application. We use gradle for building. We have prepared something like this: 1) Class to test: @Default public class RateTypeHibernateFactory implements RateTypeFactory { @Override public…
3
votes
3 answers

unit test with CDI Unit and EasyMock

I have a project with CDI and I would like to create unit test with mocks. To manage mocks, I would like to use EasyMock and to run with CDI, I find the cdi-unit project which seem easy to use. I have a problem to get a mock with EasyMock in CDI…
Kiva
  • 8,863
  • 16
  • 56
  • 91
2
votes
0 answers

Unit testing an application with CDI and ServletContextListener

I've got a CDI web application which has a ServletContextListener to initialise a few things on startup. In that ServletContextListener, this (among other things) happens: @Inject Config config; public void contextInitialized(ServletContextEvent…
Steven De Groote
  • 2,035
  • 3
  • 30
  • 49
2
votes
1 answer

Activiti CDI / Weld SE / CDI unit

Has anyone ever tried to test Activiti / BPMN processes using pure CDI? In theory (if I didn't miss anything) I would think it should be possible to use f.ex. cdi-unit for testing processes together with activiti-engine and activiti-cdi. CDI unit…
cslotty
  • 1,210
  • 17
  • 24
2
votes
1 answer

How to exclude classes from scanning with CDI-unit?

I am running tests with CDI-unit runner and want some classes to be excluded (because they act on CDI events). I tried beans.xml:
mmm
  • 1,558
  • 15
  • 28
2
votes
1 answer

Unit test with WicketTester and CDI-Unit works in Eclipse but fails during Maven build. What am I missing?

I am trying out using CDI-Unit to test my Wicket components, which are using CDI for dependency injection. Tests seems to work perfectly in Eclipse but fail during my Maven build and I cant seem to find any hints and what is wrong. I have created a…
Jesper Tejlgaard
  • 817
  • 9
  • 16
1
vote
0 answers

cdi-unit tests failing with recent maven-failsafe-plugin versions

After updating maven-failsafe-plugin from 2.18.1 to version 2.22.2, cdi-unit (4.1.0) tests started to fail with the error: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Validator with qualifiers…
g6380647
  • 237
  • 2
  • 8
1
vote
1 answer

Weld class not found when executing cdi-unit test

I have a JEE project that is deployed on wildfly 10 smoothly. I'm trying to write junit tests for my CDI beans with cdi-unit library (http://bryncooke.github.io/cdi-unit/) My pom.xml looks like the following:
user711189
  • 3,984
  • 4
  • 25
  • 44
1
vote
1 answer

CDI, cdi-unit. Exception trying inject interface

I test class using cdi-unit library. Test class: @RunWith(CdiRunner.class) public class IAktResponseMapperTest { @Inject private ITestCDI testCDI; @Test public void testCDI(){ testCDI.testCDI(); } } ITestCDI…
1
vote
1 answer

CDI-Unit @Produces not working

First off I googled intensively and according to http://jglue.org/cdi-unit-user-guide/ producing stuff to inject in a unit test should work just fine. My setup: @RunWith(CdiRunner.class) public abstract class CdiUnitBaseTest extends DBUnitBaseTest…
Thomas
  • 575
  • 10
  • 28
0
votes
0 answers

CdiUnit: DeploymentException: WELD-001408: Unsatisfied dependencies for type AppealRepositoryApi with qualifiers @Named

I'm trying to test some logic using CdiUnit. There is interface: public interface Repository { T getByReferenceId(UUID referenceUUID); } Realization: @Named("appealRepository") public class RepositoryImpl
Andrew
  • 394
  • 3
  • 14
1
2