//**************************************************************** //* Copyright (c) 2014 Ford Motor Company. All Rights Reserved. //**************************************************************** package com.ford.it.jsftest; import java.io.File; import javax.enterprise.inject.spi.BeanManager; import javax.faces.application.ProjectStage; import javax.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.ArchivePaths; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Unit test that tests the Greeting Bean */ @RunWith(Arquillian.class) public class GreetingBeanTest { /** * Creates a Web Archive (greeting.war) for the test * * @return the greeting archive */ @Deployment public static WebArchive createDeployment() { final WebAppDescriptor webXml = Descriptors.create(WebAppDescriptor.class); final File shrinkwrapApiJar = new File("C:/Projects/JCOE/JsfTestCases/JsfTestCaseWeb/WebContent/WEB-INF/lib/testing/shrinkwrap/1.2.2/shrinkwrap-api.jar"); return ShrinkWrap.create(WebArchive.class, "greeting.war") .addClasses(GreetingBean.class, PhraseBuilder.class) .addAsLibrary(shrinkwrapApiJar) .addAsWebInfResource("beans.xml") .addAsManifestResource(new ByteArrayAsset(new byte[0]), ArchivePaths.create("beans.xml")) .setWebXML(new StringAsset(webXml.getOrCreateContextParam() .paramName(ProjectStage.PROJECT_STAGE_PARAM_NAME).paramValue(ProjectStage.Development.name()).up() .exportAsString())); } @Inject GreetingBean greeter; @Inject BeanManager beanManager; /** * Tests that Greeting Bean returns the expected greeting phrase ... Hello, Earthling! */ @Test public void should_create_greeting() { final GreetingBean greetingBean = this.greeter; Assert.assertEquals("Hello, Earthling!", greetingBean.createGreeting("Earthling")); this.greeter.greet(System.out, "Earthling"); } }