Fornax-Platform
Forum

 « Return to Thread: Configuration/running Unit Tests

Configuration/running Unit Tests

by deepshar027 :: Rate this Message:

Reply to Author | View in Thread

Hey Guys,

I have been working diligently to run a unit test after code generation from sculptor(version 1.6).Havent been there yet.

few queries.

1) I see there is difference in config files generated for main and test with regards to EntityManagerFactory.xml specifically.
for e.g Test file has a datasource specified while main file doesnt.
Also following bean is specified in test EntitymanagerFactory.xml but not in main.

<bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
    <property name="defaultDataSource" ref="hsqldbDataSource"/>  
    <property name="persistenceXmlLocations">
      <list>
        <value>classpath:META-INF/persistence-test.xml</value>
      </list>
    </property>
  </bean>

I want to have my main EntitymanagerFactory.xml file have same stuff its there in test file.Not sure why there is discrepency.

2) The tests file uses hsqldb by default.Is there a way I can override that to use oracle for tests as well?

3) When I run my tests I get an error
   14:20:29,984  INFO UserServiceTest:162 - Custom transaction definition [PROPAGAT
   ION_REQUIRED,ISOLATION_DEFAULT] for test method [testCreateAccount].
   14:20:29,984  INFO UserServiceTest:175 - ApplicationContext has not been configu
   red for test [com.bookonz.account.serviceapi.UserServiceTest]: dependency inject
   ion will NOT be performed.


I think this is becoz I need to define the test bean(UserServiceTest) in applicationContext.xml and configure transaction params.
Do you guys have any working example of this?

I really want to get past configuring spring/hibernate/jpa stuff and be able to run a few tests.

Thanks,
Deepak

 « Return to Thread: Configuration/running Unit Tests