Created
September 1, 2014 19:09
-
-
Save shrikanthavale/b72e8c8348354db4d0c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package at.prosigma.profiler.database; | |
import java.io.File; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
import org.apache.maven.Maven; | |
import org.jboss.shrinkwrap.api.ArchivePaths; | |
import org.jboss.shrinkwrap.api.ShrinkWrap; | |
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | |
import org.jboss.shrinkwrap.api.importer.ZipImporter; | |
import org.jboss.shrinkwrap.api.spec.WebArchive; | |
/** | |
* | |
* This class is used for deployment of test war on the wildfly container. It is | |
* used when using Arquillian integration testing. Arquillian testing needs a | |
* war and container in order to carry out testing . Dependencies are not added | |
* properly in WAR, add them when doing Arquillium testing | |
* | |
* @author shhav | |
* | |
*/ | |
public final class ProfilerTestWarDeployment { | |
/** | |
* <p> | |
* Creates new instance of {@link ProfilerTestWarDeployment} class. | |
* </p> | |
* | |
* <p> | |
* Private constructor prevents from instantiation outside of this class. | |
* </p> | |
*/ | |
private ProfilerTestWarDeployment() { | |
// empty constructor | |
} | |
/** | |
* <p> | |
* Creates new tests deployment. | |
* </p> | |
* | |
* @return the create archive | |
*/ | |
public static WebArchive createDeployment() { | |
WebArchive webArchive = ShrinkWrap.create(ZipImporter.class, "profilerNT.war") | |
.importFrom(new File("C:\\Users\\mypersonalpc\\.m2\\repository\\at\\prosigma\\profilerNT\\0.0.1\\profilerNT-0.0.1.war")) | |
.as(WebArchive.class) | |
; | |
System.out.println(webArchive.toString(true)); | |
return webArchive; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package at.prosigma.profiler.database.entity; | |
import javax.persistence.EntityManager; | |
import javax.persistence.EntityManagerFactory; | |
import javax.persistence.PersistenceUnit; | |
import org.jboss.arquillian.container.test.api.Deployment; | |
import org.jboss.arquillian.container.test.api.OverProtocol; | |
import org.jboss.arquillian.junit.Arquillian; | |
import org.jboss.arquillian.spring.integration.test.annotation.SpringWebConfiguration; | |
import org.jboss.shrinkwrap.api.Archive; | |
import org.junit.Before; | |
import org.junit.Ignore; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.springframework.util.Assert; | |
import at.prosigma.profiler.database.ProfilerTestWarDeployment; | |
/** | |
* This class test the entities present with Adhoc prefix from profiler entity package. They were written to check, | |
* after migration to Hibernate 4 if the database layer or entities with database mapping is correct. | |
* | |
* @author shhav | |
* | |
*/ | |
@RunWith(Arquillian.class) | |
//@Transactional(manager = "transactionManager") | |
@SpringWebConfiguration(servletName = "mvc-dispatcher") | |
public class TestAdhocEntities{ | |
// @PersistenceContext(unitName="profilerntpersistenceunit") | |
protected EntityManager entityManager; | |
@PersistenceUnit | |
protected EntityManagerFactory entityManagerFactory; | |
@Before | |
public void setUp() | |
{ | |
//Nothing Here | |
} | |
//This is the place where WAR/EAR for Arquillim deployment is created, but as we are currently using JUnit testing only | |
// for module testing so this code is commented, uncomment when using Arquilliun | |
@Deployment | |
@OverProtocol("Servlet 3.0") | |
public static Archive createTestArchive() { | |
return ProfilerTestWarDeployment.createDeployment(); | |
} | |
/** | |
* This is test cases to verify if entity manager and other beans are successfully injected by Spring Framework | |
*/ | |
@Test | |
public void testNotNullEntityManager(){ | |
Assert.notNull(entityManagerFactory); | |
entityManager = entityManagerFactory.createEntityManager(); | |
System.out.println("\n\n Testing Entity Manager Injection ... "); | |
Assert.notNull(entityManager); | |
} | |
/** | |
* This is a test class, test the loading of database entities. | |
* | |
*/ | |
@Test | |
@Ignore | |
public void loadEntitiesAdhoc() { | |
System.out.println("\n\n Testing Adhoc Entities Loading ... "); | |
Assert.isTrue(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment