How to create JUnit 4 tests with Weld

How to create JUnit 4 tests with Weld published on No Comments on How to create JUnit 4 tests with Weld

Problem You want to write a couple of Integration tests with JUnit and want to use Weld for the CDI part, but don’t know how… Solution Add Weld dependency to your maven project Weld dependency

Create a couple of helper classes: WeldContext

WeldJUnit4Runner

Initialize bean context for test by creating in the… Continue reading How to create JUnit 4 tests with Weld

How to @Inject property file properties with CDI

How to @Inject property file properties with CDI published on No Comments on How to @Inject property file properties with CDI

Also published on DZone Problem You use CDI for your Java application and want to use a Property file for some needed configuration, but don’t know how to do this … Solution Create producers and an annotation to direct it. Annotation

Producer The examples provided here enable parsing of Strings, Booleans and Integers but… Continue reading How to @Inject property file properties with CDI

Field Injection when Mocking frameworks fail

Field Injection when Mocking frameworks fail published on No Comments on Field Injection when Mocking frameworks fail

Also published on DZone Problem You use Dependency Injection (CDI) in your application and you want to unit test your Java classes without making it an integration test by using Weld of Arquillian. You use a Mocking framework like Mockito or EasyMock but still have trouble getting all your dependencies injected into the class because… Continue reading Field Injection when Mocking frameworks fail