Questions tagged [weld-junit5]

14 questions
2
votes
2 answers

junit5 + weld + mockito extension, how to inject @Context object

This is my REST resource: @Context HttpServletRequest webRequest; @Override public DomainConfig get() { return configDelegate.get(webRequest.getHeader("Origin")); } I've built my unit test with Junit 5 + Weld / Mockito…
Fabrizio Stellato
  • 1,727
  • 21
  • 52
1
vote
1 answer

Weld-Junit5: addPackages doesn't add all contained beans to the test container

I'm trying to migrate from Java EE 8 to Jakarta EE 10 and was running a JUnit 5 test with Weld. I created a simple example with JUnit5 and Weld (cdi) could not resolve the (inner) injected classes. The test failed with: WELD-001408: Unsatisfied…
Iceplanet
  • 11
  • 2
1
vote
1 answer

Is bean discovery for @QuarkusTest configurable?

Consider the following Quarkus application: @ApplicationScoped @Path("/hello") public class HelloService { @Inject Helper helper; @GET @Produces(MediaType.TEXT_PLAIN) public String sayHello(){ return "Hello…
Johannes Hahn
  • 363
  • 3
  • 18
1
vote
0 answers

hibernate-validatior-cdi: Why is the ConstraintValidator not a managed instance in the weld-se container?

In our project we are testing jpa database access with the weld-junit5 framework. The EntityManager is injected into the test class. The entity to be saved is annotated with a custom…
duschata
  • 33
  • 5
1
vote
3 answers

Unsatisfied dependencies using CDI with Weld when running unit tests on Java SE

I have a small (Java SE 11.x) project where I'm testing CDI with Weld. I have these dependencies (among others but these are the relevant ones for this…
x80486
  • 6,627
  • 5
  • 52
  • 111
1
vote
2 answers

Mockito does not recognize class

I tried to user weld-junit5 with mocking a class. I mock the class because i want to know how often it will be called. But each time i try to Mockito.verify() this mocked class it throws a "NotAMockException" The Intellij Debugger is validating the…
Punching
  • 55
  • 7
1
vote
1 answer

WeldSE with JUnit5 - Can't inject dependencies

This is my service class: @Path("/foo") @RequestScoped public class FooService { @Inject @Log Logger logger; @GET @Produces(MediaType.TEXT_PLAIN) public String ping() { return "pong"; } } In the same module I have…
Fabrizio Stellato
  • 1,727
  • 21
  • 52
0
votes
1 answer

weld-junit5 4.0.0.CR1 namespace confusion

I'm a bit confused about the namespace usage for @Inject, @Produces etc. with weld-junit5 4.0.0.CR2. I'm toying around with JakartaEE 8 + Java 17 and weld-junit5 3.x got upset so I guess 4.x is the way to go? The problem is that with a test class…
Nicklas Karlsson
  • 317
  • 1
  • 4
  • 12
0
votes
0 answers

Experience using weld-junit with spring data jpa as a lightweight arquillian replacement?

Good Morning everybody, I am currently facing the problem that my project wants to use weld-junit (https://github.com/weld/weld-junit/blob/master/junit5/README.md) to provide easy unit tests, wit the power of injection and a CDI container. In an…
0
votes
1 answer

How can I handle multiple disposal methods for inherited types?

I have two classes. class A { } class B extends A { } And in my producer class I declared like this. @Produces A produceA(InjectionPoint ip) { return new A(); } void disposeA(@Disposes A a) { // empty } @Produces B…
Jin Kwon
  • 20,295
  • 14
  • 115
  • 184
0
votes
1 answer

In a junit5 test class can weldinitiator config be specific for each test method?

In a junit5 test class can weldinitiator config be specific (i.e different behaviour of mocks) for each method of the test class? Because I could only do and I only found one weldinitiator config for the whole test class but never for test methods…
0
votes
1 answer

WELD-SE + JUnit5 WELD-001409: Ambiguous dependencies for type Validator with qualifiers @Default

I want to create a unit test of a REST resource using WELD SE with JEE8 (CDI 2.0). This is the code of the REST resource class: @Path("/members") @RequestScoped public class MemberResourceRESTService { @Inject private Logger log; …
Fabrizio Stellato
  • 1,727
  • 21
  • 52
0
votes
1 answer

weld-junit5 with weld 3

Recently we upgraded Weld to 3.0.3.Final (with is the one in Wildfly 12). Now weld-junit5 1.3.1.Final (the most recent version) throws an exception java.lang.NoSuchMethodError:…
Marc von Renteln
  • 1,229
  • 15
  • 34
0
votes
1 answer

How can I inject for generic inherited types?

I spent a plenty of time for finding any answers, but I think I have to ask. I'm using Weld-SE for testing my entities. I prepared entity randomizer for testing. abstract class BaseEntityRandomizer implements…
Jin Kwon
  • 20,295
  • 14
  • 115
  • 184