1 Reply Latest reply on Dec 24, 2009 3:27 PM by Wang Liyu

    Seam 2.2.0GA unit test with EJB3 failed

    Wang Liyu Apprentice
      Hi,
      I have a ejb and I have created the unit test class for it.

      @Local
      public interface Permission {
          public boolean isGranted(String process, int accessLevel);
      }

      @Name("defaultPermission")
      @Stateless
      public class DefaultPermissionBean implements Permission {
          @Logger
          private Log logger;
          @Override
          public boolean isGranted(String process, int accessLevel) {
              logger.info("enter isGranted method.");
              return true;
          }
      }

      and the test case for this:
      public class DefaultPermissionBeanTestCase extends SeamTest {
          @Test
          public void testIsGranted() throws Exception {
              new ComponentTest() {
                  @Override
                  protected void testComponents() throws Exception {
                      Component component = new Component(DefaultPermissionBean.class, Contexts.getSessionContext());
                      Contexts.getApplicationContext().set(Component.getComponentName(DefaultPermissionBean.class) + ".component", component);
                      Permission permission = (Permission) Component.getInstance(DefaultPermissionBean.class,ScopeType.SESSION, true);
                      permission.isGranted("testprocess", 1);
                  }
              }.run();
          }
      }


      And I got the exception:
      Caused by: java.lang.RuntimeException: PROVIDER_URL not provided in jndi.properties.  Automatic discovery not implemented yet.
         [testng]      at org.jboss.naming.JBossRemotingContextFactory.getInitialContext(JBossRemotingContextFactory.java:158)
         [testng]      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
         [testng]      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
         [testng]      at javax.naming.InitialContext.init(InitialContext.java:223)
         [testng]      at javax.naming.InitialContext.<init>(InitialContext.java:197)
         [testng]      at org.jboss.seam.util.Naming.getInitialContext(Naming.java:37)
         [testng]      at org.jboss.seam.util.Naming.initInitialContext(Naming.java:59)
         [testng]      at org.jboss.seam.util.Naming.getInitialContext(Naming.java:50)
         [testng]      at org.jboss.seam.Component.instantiateSessionBean(Component.java:1400)
         [testng]      at org.jboss.seam.Component.instantiate(Component.java:1364)
         [testng]      at org.jboss.seam.Component.newInstance(Component.java:2122)
         [testng]      ... 29 more
         [testng] ... Removed 22 stack frames

      the classpath is
        - D:\proj\jboss-seam-2.2.0.GA\lib\jboss-seam.jar
           - D:\testenv\lib\el-api.jar
           - D:\testenv\lib\hibernate-all.jar
           - D:\testenv\lib\jboss-el.jar
           - D:\testenv\lib\jboss-embedded-all.jar
           - D:\testenv\lib\jsf-api.jar
           - D:\testenv\lib\jsf-impl.jar
           - D:\testenv\lib\thirdparty-all.jar
           - D:\common-libs\log4j-1.2.15.jar
           - D:\common-libs\slf4j-api-1.5.2.jar
           - D:\common-libs\slf4j-log4j12-1.5.2.jar
           - D:\common-libs\testng-5.11-jdk15.jar
           - D:\testenv\bootstrap
           - D:\myproj\target\test-classes

      Can anyone help me on this?