package org.apache.ode.dao.jpa.test;

import java.util.Collection;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.apache.ode.bpel.dao.BpelDAOConnection;
import org.apache.ode.dao.jpa.ojpa.*;
import org.apache.openjpa.persistence.ArgumentException;

import junit.framework.TestCase;

public class InsertObjectTest extends TestCase {
	
	private EntityManager em;

	@Override
	protected void setUp() throws Exception {
		
		try {
			
		
		EntityManagerFactory emf = Persistence.createEntityManagerFactory("ode-unit-test");
		em = emf.createEntityManager();
		
		if ( em.isOpen() ) {
			System.out.println("connection open");
		}
		

		
		} catch ( Exception e ) {
			e.printStackTrace();
		}
		
		
	}
	
	public void testStart() throws Exception {
		System.out.println("start test");
		String tmp = new String("some data");
		
		BPELDAOConnectionFactoryImpl factory = new BPELDAOConnectionFactoryImpl();
		BpelDAOConnection conn = factory.getConnection();
		
		
//	    Collection<MessageTest> tmp2 = ft.getFaultMessages();
//		ft.addMessage("Test Message");
//		ft.addProp("test1", "test prop 1");
	    

		//Collection<TestMessage> tmp = ft.g
		try {
		em.getTransaction().begin();
		em.persist(conn);
				
		em.flush();
		em.getTransaction().commit();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		
	}

	@Override
	protected void tearDown() throws Exception {
		em.close();
	}
	

}

@@ -246,16 +246,68 @@
 ction;%0D%0A
+import org.apache.ode.bpel.dao.MessageExchangeDAO;%0D%0A
 import o
@@ -337,16 +337,16 @@
 jpa.*;%0D%0A
-
 import o
@@ -588,24 +588,16 @@
 y %7B%0D%0A%09%09%09
-%0D%0A%09%09%0D%0A%09%09
 EntityMa
@@ -675,16 +675,17 @@
 t%22);%0D%0A%09%09
+%09
 em = emf
@@ -713,90 +713,8 @@
 );%0D%0A
-%09%09%0D%0A%09%09if ( em.isOpen() ) %7B%0D%0A%09%09%09System.out.println(%22connection open%22);%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%0D%0A
 %09%09%0D%0A
@@ -759,32 +759,44 @@
 tStackTrace();%0D%0A
+%09%09%09fail();%0D%0A
 %09%09%7D%0D%0A%09%09%0D%0A%09%09%0D%0A%09%7D%0D
@@ -848,86 +848,8 @@
  %7B%0D%0A
-%09%09System.out.println(%22start test%22);%0D%0A%09%09String tmp = new String(%22some data%22);%0D%0A
 %09%09%0D%0A
@@ -991,196 +991,8 @@
 %09%09%0D%0A
-//%09    Collection%3CMessageTest%3E tmp2 = ft.getFaultMessages();%0D%0A//%09%09ft.addMessage(%22Test Message%22);%0D%0A//%09%09ft.addProp(%22test1%22, %22test prop 1%22);%0D%0A%09    %0D%0A%0D%0A%09%09//Collection%3CTestMessage%3E tmp = ft.g%0D%0A
 %09%09tr
@@ -1151,24 +1151,36 @@
 ckTrace();%0D%0A
+%09%09%09fail();%0D%0A
 %09%09%7D%0D%0A%09%09%0D%0A%09%09%0D
@@ -1241,24 +1241,24 @@
 xception %7B%0D%0A
-
 %09%09em.close()
@@ -1266,14 +1266,145 @@
 %0D%0A%09%7D%0D%0A%09%0D
+%0A%09private void createMessageExchange(BpelDAOConnection conn ) %7B%0D%0A%09%09MessageExchangeDAO me = conn.createMessageExchange('0');%0D%0A%09%7D%0D%0A%09%0D
 %0A%0D%0A%7D%0D%0A

Extend unit test