This content has been marked as final.
Show 2 replies
-
1. Re: Help with entity test
paulmkeogh Dec 25, 2008 1:18 AM (in response to paulmkeogh)Managed to answer the first part of my question... here it is;
public class TestCDREntity extends SeamTest {
@Test
public void testSingleCDRParse () throws Exception {
new ComponentTest() {
protected void testComponents() throws Exception {
EntityManager em = (EntityManager) Component.getInstance("entityManager");
UserTransaction tx = Transaction.instance();
tx.begin();
Cdr entity = new Cdr();
CdrId id = new CdrId();
id.setXXX("123");
entity.setId(id);
entity.setYYY(3);
tx.commit();
assert(entity.getId() != null);
em.close();
}
}.run();
}
}
I didn't need to change anything under test as generated - the explcit support for Tx is required because the test config doesn't support JTA Txs by default. -
2. Re: Help with entity test
matt.nirgue Dec 26, 2008 9:42 AM (in response to paulmkeogh)Wouldn't it be something quite similar to what you've done in the first test? you'd need to create and persist both objects though:
ReferencedComponent refComp = new ReferencedComponent(); refCompt.setBlaBlaBla("anything you need to set"); //... //save refComp YourComponent comp = new YourComponent(); comp.setBla("whatever"); //... comp.setReferencedComponent(refComp); //save comp
Is this what you were asking about?