1. Vineet Reynolds
  2. Java EE 6-Galleria

Commits

Vineet Reynolds  committed a4c4fe3

Modified the deployment process, to create an EnterpriseArchive instead of a WebArchive as ARQ-527 appears to be fixed in 1.0.0.CR1 of the arquillian-glassfish-remote-3.1 project. Also, this change no longer results in the javax.naming.NameNotFoundException being thrown with the message: "Cannot find name to unbind" during undeployment of the archive by Arquillian.

As a side note, it appears that the javax.naming.NameNotFoundException exception is thrown when the WebArchive contains one of the following - EJBs with JPA entities using Hibernate, or facelets that use Primefaces components, or both.

  • Participants
  • Parent commits 8373f4a
  • Branches default

Comments (0)

Files changed (1)

File galleria-jsf/src/test/java/info/galleria/view/AllPagesIntegrationTest.java

View file
  • Ignore whitespace
 import org.dbunit.operation.DatabaseOperation;
 import org.jacoco.core.runtime.*;
 import org.jboss.arquillian.container.test.api.*;
-import org.jboss.arquillian.core.api.annotation.Observes;
 import org.jboss.arquillian.drone.api.annotation.Drone;
 import org.jboss.arquillian.junit.Arquillian;
 import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.arquillian.test.spi.event.suite.*;
 import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.api.spec.*;
 import org.jboss.shrinkwrap.resolver.api.DependencyResolvers;
 import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;
 import org.junit.*;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
 import org.junit.rules.TestName;
 import org.junit.runner.RunWith;
 import org.openqa.selenium.*;
 	private static final String ADDRESS = "localhost";
 
 	private static final int PORT = 6300;
+	
+	private static final String webAppDeploymentName = "galleria-jsf";
 
 	@Rule
 	public TestName testMethod = new TestName();
 	protected WebDriver driver;
 
 	@ArquillianResource
+	protected URI deploymentPath;
+	
 	protected URI contextPath;
 
-	@Deployment
-	public static WebArchive createDeployment()
+	@Deployment(testable=false)
+	public static EnterpriseArchive createDeployment()
 	{
 		logger.info("Preparing deployment.");
-		// A separate EJB archive is not being created unless Arquillian can
-		// create EnterpriseArchives that can be deployed on Glassfish.
-		// Also, when this EJB archive is added to the WebArchive, the EJB
-		// classloader will fail to load classes required, but located in
-		// WEB-INF/lib, like the Commons-Codec class.
-		//
-		// JavaArchive ejbArchive = ShrinkWrap.create(JavaArchive.class,
-		// "galleria-ejb.jar")
-		// .addPackage("info.galleria.domain")
-		// .addPackages(true, "info.galleria.service")
-		// .addPackage("info.galleria.utilities")
-		// .addAsManifestResource("ValidationMessages.properties")
-		// .addAsManifestResource("ValidationMessages_de.properties")
-		// .addAsManifestResource("META-INF/ejb-jar.xml","ejb-jar.xml")
-		// .addAsManifestResource("META-INF/glassfish-ejb-jar.xml","glassfish-ejb-jar.xml")
-		// .addAsManifestResource("META-INF/persistence.xml","persistence.xml");
-		// System.out.println("******Contents of EJB Archive******");
-		// System.out.println(ejbArchive.toString(true));
+		JavaArchive ejbArchive = ShrinkWrap.create(JavaArchive.class, "galleria-ejb.jar")
+				.addPackage("info.galleria.domain")
+				.addPackages(true, "info.galleria.service")
+				.addPackage("info.galleria.utilities")
+				.addAsResource("ValidationMessages.properties")
+				.addAsResource("ValidationMessages_de.properties")
+				.addAsManifestResource("META-INF/ejb-jar.xml", "ejb-jar.xml")
+				.addAsManifestResource("META-INF/glassfish-ejb-jar.xml", "glassfish-ejb-jar.xml")
+				.addAsManifestResource("META-INF/persistence.xml", "persistence.xml");
+		System.out.println("******Contents of EJB Archive******");
+		System.out.println(ejbArchive.toString(true));
 
 		WebArchive webArchive = ShrinkWrap
-				.create(WebArchive.class, "galleria-jsf.war")
+				.create(WebArchive.class, webAppDeploymentName + ".war")
 				.setWebXML(new File("src/main/webapp/WEB-INF/web.xml"))
 				.addPackage("info.galleria.converters")
 				.addPackage("info.galleria.filters")
 				.addAsWebResource(new File("src/main/webapp/private/photo", "EditPhoto.xhtml"), "private/photo/EditPhoto.xhtml")
 				.addAsWebResource(new File("src/main/webapp/private/photo", "ViewPhoto.xhtml"), "private/photo/ViewPhoto.xhtml")
 				.addAsWebInfResource(new File("src/main/webapp/WEB-INF/faces-config.xml"), "faces-config.xml")
-				/*
-				 * Add glassfish-web.xml as glassfish-ejb-jar.xml will be
-				 * ignored in the Web archive deployment
-				 */
-				.addAsWebInfResource(new File("src/test/resources/glassfish-web.xml"), "glassfish-web.xml")
 				/* .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") */
 				.addAsLibraries(
 						DependencyResolvers
 								.artifacts("org.primefaces:primefaces:3.0.M2",
 										"commons-io:commons-io:1.4",
 										"commons-fileupload:commons-fileupload:1.2.1",
-										"commons-codec:commons-codec:1.5").resolveAsFiles())
-				.addPackage("info.galleria.domain").addPackages(true, "info.galleria.service")
-				.addPackage("info.galleria.utilities")
-				.addAsResource("ValidationMessages.properties", "ValidationMessages.properties")
-				.addAsResource("ValidationMessages_de.properties", "ValidationMessages_de.properties")
-				.addAsResource("META-INF/ejb-jar.xml", "ejb-jar.xml")
-				.addAsResource("META-INF/glassfish-ejb-jar.xml", "glassfish-ejb-jar.xml")
-				.addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml");
-		System.out.println("******Contents of WAR Archive******");
+										"commons-codec:commons-codec:1.5").resolveAsFiles());
 		System.out.println(webArchive.toString(true));
 
-		//
-		// Don't use Enterprise archives yet, as bug ARQ-527 is not yet resolved
-		// at the time of writing this test.
-		//
-		// EnterpriseArchive enterpriseArchive =
-		// ShrinkWrap.create(EnterpriseArchive.class,"galleria.ear")
-		// .addAsModule(webArchive)
-		// .addAsModule(ejbArchive)
-		// .addAsLibraries(DependencyResolvers.use(MavenDependencyResolver.class).artifact("org.hibernate:hibernate-entitymanager:3.6.5.Final").exclusions("org.hibernate:hibernate-validator","org.hibernate:hibernate-validator","org.hibernate.javax.persistence:hibernate-jpa-2.0-api","javax.transaction:jta","org.slf4j:slf4j-api:1.6.1").resolveAsFiles());
-		// System.out.println("******Contents of EAR Archive******");
-		// System.out.println(enterpriseArchive.toString(true));
+		EnterpriseArchive enterpriseArchive = ShrinkWrap
+				.create(EnterpriseArchive.class, "galleria.ear")
+				.addAsModule(webArchive)
+				.addAsModule(ejbArchive)
+				.addAsLibraries(
+						DependencyResolvers
+								.use(MavenDependencyResolver.class)
+								.artifact("commons-codec:commons-codec:1.5")
+								.resolveAsFiles());
+		System.out.println("******Contents of EAR Archive******");
+		System.out.println(enterpriseArchive.toString(true));
 
-		return webArchive;
-	}
-
-	public void startCoverage(@Observes BeforeSuite event)
-	{
-		logger.info("Before Suite");
-	}
-
-	public void stopCoverage(@Observes AfterSuite event)
-	{
-		logger.info("After Suite");
+		return enterpriseArchive;
 	}
 
 	@BeforeClass
 		writeCoverageData();
 	}
 
-	private static void writeCoverageData()
-	{
-		try
-		{
-			final FileOutputStream localFile = new FileOutputStream(DESTFILE);
-			final RemoteControlWriter localWriter = new RemoteControlWriter(localFile);
-
-			// Open a socket to the coverage agent:
-			final Socket socket = new Socket(InetAddress.getByName(ADDRESS), PORT);
-			final RemoteControlWriter writer = new RemoteControlWriter(socket.getOutputStream());
-			final RemoteControlReader reader = new RemoteControlReader(socket.getInputStream());
-			reader.setSessionInfoVisitor(localWriter);
-			reader.setExecutionDataVisitor(localWriter);
-
-			// Send a dump command and read the response:
-			writer.visitDumpCommand(true, false);
-			reader.read();
-
-			socket.close();
-			localFile.close();
-		}
-		catch (IOException ioEx)
-		{
-			logger.warn("Failed to write the coverage data.", ioEx);
-		}
-	}
-
 	/**
 	 * Resets the contents of the database tables before every test using
 	 * DbUnit.
 	 * @throws Exception
 	 */
 	@Before
-	public void setUp()
+	public void setUp() throws Exception
 	{
 		logger.info("Performing setup before Test {}", testMethod.getMethodName());
+		contextPath = new URI(deploymentPath.toString() + "/" + webAppDeploymentName + "/");
 		IDatabaseConnection connection = null;
 		try
 		{
 		}
 		catch (Exception ex)
 		{
-			ex.printStackTrace();
+			throw ex;
 		}
 		finally
 		{
 		}
 	}
 
+	private static void writeCoverageData()
+	{
+		try
+		{
+			final FileOutputStream localFile = new FileOutputStream(DESTFILE);
+			final RemoteControlWriter localWriter = new RemoteControlWriter(localFile);
+	
+			// Open a socket to the coverage agent:
+			final Socket socket = new Socket(InetAddress.getByName(ADDRESS), PORT);
+			final RemoteControlWriter writer = new RemoteControlWriter(socket.getOutputStream());
+			final RemoteControlReader reader = new RemoteControlReader(socket.getInputStream());
+			reader.setSessionInfoVisitor(localWriter);
+			reader.setExecutionDataVisitor(localWriter);
+	
+			// Send a dump command and read the response:
+			writer.visitDumpCommand(true, false);
+			reader.read();
+	
+			socket.close();
+			localFile.close();
+		}
+		catch (IOException ioEx)
+		{
+			logger.warn("Failed to write the coverage data.", ioEx);
+		}
+	}
+
 	private IDatabaseConnection getConnection() throws ClassNotFoundException, SQLException, DatabaseUnitException
 	{
 		Class.forName("org.apache.derby.jdbc.ClientDriver");