Спасибо, кажется разобрался. ))
Вот так вот работает, вотт… может кому пригодится.
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="in.memory.test"
transaction-type="RESOURCE_LOCAL">
<description>
In memory example using Hibernate and HSQLDB
</description>
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>de.htw_berlin.f4.ai.jobboerse.domain.UserJob</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:mem:test" />
<property name="hibernate.connection.username" value="sa" />
<property name="hibernate.connection.password" value="" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="create" />
</properties>
</persistence-unit>
</persistence>
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
public class EntityManagerProvider {
public static EntityManagerFactory emf;
@PersistenceUnit
public void setEntityManagerFactory(EntityManagerFactory emf) {
this.emf = emf;
}
public static EntityManager createEntityManager(){
return emf.createEntityManager();
}
}
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class UserJobTest {
private UserJob userJob = new UserJob();
@BeforeClass
public static void setUp() {
ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/spring/application-context.xml");
}
@Before
public void init() {
Profile profile = new Profile();
userJob.setProfile(profile);
userJob.setFirstname("Oleg");
userJob.setLastname("Lastname");
userJob.setPostalcode("10318");
userJob.setStreet("Street");
userJob.setCity("Berlin");
userJob.setEmail("E-Mail");
userJob.setIsActive(true);
userJob.setPassword("pass");
}
@Test
public void saveAndLoadUserJobTest() {
userJob.save();
UserJob loadedUserJob = userJob.load("E-Mail", "pass");
Assert.assertEquals(loadedUserJob.getFirstname(), "Oleg");
Assert.assertTrue(loadedUserJob.getId() > 0);
}
@Test
public void updateUserJobTest() {
userJob.setFirstname("OlegUpd");
userJob.setLastname("LastnameUpd");
userJob.setPostalcode("10318Upd");
userJob.setStreet("StreetUpd");
userJob.setCity("BerlinUpd");
userJob.setEmail("E-MailUpd");
userJob.setIsActive(false);
userJob.setPassword("passUpd");
userJob.update();
UserJob loadedUserJob = userJob.load("E-MailUpd", "passUpd");
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>"+ loadedUserJob.toString());
Assert.assertEquals(loadedUserJob.getFirstname(), "OlegUpd");
Assert.assertEquals(loadedUserJob.getLastname(), "LastnameUpd");
Assert.assertEquals(loadedUserJob.getPostalcode(), "10318Upd");
Assert.assertEquals(loadedUserJob.getStreet(), "StreetUpd");
Assert.assertEquals(loadedUserJob.getCity(), "BerlinUpd");
Assert.assertEquals(loadedUserJob.getEmail(), "E-MailUpd");
Assert.assertEquals(loadedUserJob.getIsActive(), false);
Assert.assertEquals(loadedUserJob.getPassword(), "passUpd");
Assert.assertTrue(loadedUserJob.getId() > 0);
}
}