1 package no.knowit.helloseam; 2 import org.jboss.seam.Component; 3 import org.jboss.seam.log.LogProvider; 4 import org.jboss.seam.log.Logging; 5 import org.testng.Assert; 6 import org.testng.annotations.BeforeSuite; 7 import org.testng.annotations.Test; 8 9 import no.knowit.seam.openejb.mock.SeamOpenEjbTest; 10 11 public class HelloSeamTest extends SeamOpenEjbTest { 12 private static final String EXPECTED_HELLO = "hello"; 13 private static final LogProvider log = Logging.getLogProvider(SeamOpenEjbTest.class); 14 15 @Override 16 @BeforeSuite 17 public void beforeSuite() throws Exception { 18 // Change some logging, INFO|DEBUG|WARN|ERROR|FATAL 19 contextProperties.put("log4j.category.no.knowit.seam.openejb.mock", "DEBUG"); 20 contextProperties.put("log4j.category.no.knowit.helloseam", "debug"); 21 super.beforeSuite(); 22 } 23 24 @Test 25 public void shouldSayHelloToSeam() throws Exception { 26 27 new ComponentTest() { 28 @Override 29 protected void testComponents() throws Exception { 30 Object instance = Component.getInstance("helloSeam"); 31 assert instance != null : "Component.getInstance(\"" + "helloSeam" + "\") returned null"; 32 assert instance instanceof HelloSeam : "Component.getInstance(\"" + "helloSeam" + "\") returned incorrect type"; 33 34 HelloSeam helloSeam = (HelloSeam)instance; 35 Assert.assertEquals(EXPECTED_HELLO, helloSeam.sayHello(), "helloSeam.sayHello:"); 36 log.debug("**** Seam says Hello :-)"); 37 } 38 }.run(); 39 } 40 }