james, would setting up the unit test in that way load up the service class as if it would in in the J2EE container?
the reason why i asked is because in the tutorial, as far as i understand, they have wired in using Spring a transaction manager. that means in my service object, when i call update/delete/create, i don't have to get a EntityTransaction and do .begin() and .commit() before and after i call the EntityManager's merge/remove/persist methods, respectively. i tried unit testing naively, by constructing an EntityManagerFactory from the Persistence class (defining yet another META-INF/persistence.xml file), but my CRUD operations (minus read) never persists changes to the database (because it is in a J2SE environment without a transaction manager? as opposed to being in a J2EE environment with a transaction manager? well, that's what some sites suggests anyways). On Mon, Jun 21, 2010 at 5:02 AM, James Cook <james.c...@wecomm.com> wrote: > Get involved with: > > Junit 4.4 > Spring-test libs > > And started your service test class like such: > > @RunWith(SpringJUnit4ClassRunner.class) > @ContextConfiguration(locations = "classpath:/testConfigXML.xml") > public class MyServiceImplTest extends AbstractJUnit4SpringContextTests > { > > �...@autowired(required = true) > private MyService myService = null; > > testConfigXML.xml will contain your *test* config.. > > Then do the do! > > > -----Original Message----- > From: Jake Vang [mailto:vangj...@googlemail.com] > Sent: 21 June 2010 05:54 > To: Struts Users Mailing List > Subject: unit test the service layer (aka data access layer) > > hi, i've been following this code here at > http://struts.apache.org/2.0.14/docs/struts-2-spring-2-jpa-ajax.html. > what i want to know is how to unit test the service layer (or data > access object layer). in the case of the link, it would be the > PersonServiceImpl class. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org