0 Replies Latest reply on Oct 28, 2006 2:35 PM by henderson_mk

    issue running tests.

    henderson_mk

      Hi folks,

      Having some issues running the testng tests for seam.
      I set up my own project as a copy of the dvdstore example... just renamed the datasource to svDatasource instead of dvdDatasource.

      However, I'm having some issues running unit tests.

      Getting this in my test class:

      FATAL [main] DatasourceConnectionProvider.fatal(129) | Could not find datasource: java:/svDatasource
      javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
       at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
       at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
       at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
       at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
       at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
       at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:61)
       at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1928)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
       at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:631)
       at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:760)
       at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:151)
       at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:205)
       at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
       at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
       at org.mhenderson.sportsvision.domain.test.BaseTest.init(BaseTest.java:47)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:552)
       at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:326)
       at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:159)
       at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:97)
       at org.testng.TestRunner.runWorkers(TestRunner.java:745)
       at org.testng.TestRunner.privateRun(TestRunner.java:703)
       at org.testng.TestRunner.run(TestRunner.java:584)
       at org.testng.SuiteRunner.runTest(SuiteRunner.java:241)
       at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:230)
       at org.testng.SuiteRunner.privateRun(SuiteRunner.java:213)
       at org.testng.SuiteRunner.run(SuiteRunner.java:142)
       at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:958)
       at org.testng.TestNG.runSuitesLocally(TestNG.java:920)
       at org.testng.TestNG.run(TestNG.java:676)
       at org.testng.eclipse.runner.RemoteTestNG.run(RemoteTestNG.java:85)
       at org.testng.eclipse.runner.RemoteTestNG.main(RemoteTestNG.java:127)
      FAILED: init
      javax.persistence.PersistenceException: org.hibernate.HibernateException: Could not find datasource


      from a setup of:

       @Configuration(beforeTestClass=true)
       public void init() {
       Map<String,String> configOverrides = new HashMap<String,String>();
       log.info("Creating programmatic EMF to update schema...");
       configOverrides.put("hibernate.hbm2ddl.auto", "update");
       configOverrides.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
       configOverrides.put("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
       configOverrides.put("hibernate.connection.username", "sa");
       configOverrides.put("hibernate.connection.password", "");
       configOverrides.put("hibernate.connection.url","jdbc:hsqldb:.");
      
       EntityManagerFactory emf = Persistence
       .createEntityManagerFactory("svDatabase", configOverrides);
       log.info("emf=" + emf);
       }
      
      


      Which seems strange as I copied exactly the examples.

      I also tried to run the basic tests for the booking example in the jboss-seam-1.0.1.GA package and the error produced for this was:
       [testng] Creating E:\Projects\jboss-seam-1.0.1.GA\examples\booking\test-outpu
      t\testng-failed.xml
       [testng] Creating E:\Projects\jboss-seam-1.0.1.GA\examples\booking\test-outpu
      t\Booking Unit.html
       [testng] FAILED: org.jboss.seam.example.booking.test.BookingUnitTest.testHote
      lSearching()
       [testng] javax.persistence.PersistenceException: No Persistence provider for
      EntityManager named bookingDatabase
       [testng] at javax.persistence.Persistence.createEntityManagerFactory(Pers
      istence.java:41)
       [testng] at javax.persistence.Persistence.createEntityManagerFactory(Pers
      istence.java:27)
       [testng] at org.jboss.seam.example.booking.test.BookingUnitTest.testHotel
      Searching(BookingUnitTest.java:28)
       [testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       [testng] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
      sorImpl.java:39)
       [testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
      hodAccessorImpl.java:25)
       [testng] at java.lang.reflect.Method.invoke(Method.java:585)
       [testng] at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.ja
      va:529)
       [testng] at org.testng.internal.Invoker.invokeMethod(Invoker.java:398)
       [testng] at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:62
      5)
       [testng] at org.testng.internal.TestMethodWorker.run(TestMethodWorker.jav
      a:88)
       [testng] at org.testng.TestRunner.privateRun(TestRunner.java:614)
       [testng] at org.testng.TestRunner.run(TestRunner.java:505)
       [testng] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:221)
       [testng] at org.testng.SuiteRunner.run(SuiteRunner.java:147)
       [testng] at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:576)
       [testng] at org.testng.TestNG.runSuitesLocally(TestNG.java:539)
       [testng] at org.testng.TestNG.run(TestNG.java:316)
       [testng] at org.testng.TestNG.privateMain(TestNG.java:666)
       [testng] at org.testng.TestNG.main(TestNG.java:608)
      


      so this isn't working either.

      Has anyone managed to get this working? If so I'd love some help.

      Thanks in advance.

      Marty