Hello,
I am using Arquillian framework for my tests. Now i have the problem when i want to test my Mapper classes. I can not add Orika to my jar file or i don't know how to do that properly. Please, help.
I have the following createDeployment method in the AbstractMapperTest class:
@Deployment public static JavaArchive createDeployment() { return ShrinkWrap.create(JavaArchive.class, "test.jar") .addPackage(Mapper.class.getPackage()) .addPackage(AbstractMapperTest.class.getPackage()) .addPackage(MapperImpl.class.getPackage()) .addPackage(SomeDTO.class.getPackage()) .addPackage(SomeEntity.class.getPackage()) .addPackages(true, "ma.glasnost") .addPackages(true, "com.thoughtworks") .addPackages(true, "com.googlecode") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); }
Maven dependency:
<!-- Orika Mapper --> <dependency> <groupId>ma.glasnost.orika</groupId> <artifactId>orika-core</artifactId> <version>1.4.6</version> </dependency> <!--Strange dependency that i need for deployment file creation--> <dependency> <groupId>com.thoughtworks.paranamer</groupId> <artifactId>paranamer</artifactId> <version>2.7</version> </dependency> <dependency> <groupId>com.googlecode.concurrentlinkedhashmap</groupId> <artifactId>concurrentlinkedhashmap-lru</artifactId> <version>1.4.2</version> </dependency>
And simple test:
@RunWith(Arquillian.class) public class ActivityMapperTest extends AbstractMapperTest { @Inject private ActivityMapper activityMapper; @Test public void getActivityMapper_existentActivityMapper_notNullMapperFactory() { Assert.assertThat(activityMapper, is(notNullValue())); Assert.assertThat(activityMapper.getMapperFactory(), is(notNullValue())); } }
And this works fine.
But for what reason i need to add this lines of the code in the deployment method and additional dependency for maven? Please, suggest how i can add Orika artifacts properly through maven.
.addPackages(true, "ma.glasnost") .addPackages(true, "com.thoughtworks") .addPackages(true, "com.googlecode")
Thanks,
Alex
Hi Alex,
I'm just guessing that the additional dependencies are some necessary transitive dependencies you are using in your implementation.
If you're asking how to add the whole jar Orika into the JavaArchive - this is not possible in general. see this thread: Can you add a jar to a arquillian Java Archive