You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Markus Reich <ma...@markusreich.at> on 2013/07/24 22:51:08 UTC
Unit Testing WebApp with 3.2M1 release
Hi,
I'm using following code for unit testing:
package db;
import org.apache.cayenne.ObjectContext;
import org.apache.cayenne.access.DataContext;
import org.apache.cayenne.configuration.server.ServerRuntime;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class PartnerTest {
private ObjectContext context;
@Before
public void setUp() throws Exception {
ServerRuntime runtime = new ServerRuntime("cayenne-mxerp.xml");
context = runtime.getContext();
}
@After
public void tearDown() throws Exception {
context.rollbackChanges();
}
@Test
public void testDB() {
}
}
...but it seems since 3.2M1 runtime.getContext() is deprecated?
What is the right way to get a context for testing?
regards
Markus
Re: Unit Testing WebApp with 3.2M1 release
Posted by Markus Reich <ma...@markusreich.at>.
perfect, thx
2013/7/24 John Huss <jo...@gmail.com>
> getContext() was renamed to newContext()
>
>
> On Wed, Jul 24, 2013 at 3:51 PM, Markus Reich
> <ma...@markusreich.at>wrote:
>
> > Hi,
> >
> > I'm using following code for unit testing:
> >
> > package db;
> >
> > import org.apache.cayenne.ObjectContext;
> > import org.apache.cayenne.access.DataContext;
> > import org.apache.cayenne.configuration.server.ServerRuntime;
> > import org.junit.After;
> > import org.junit.Before;
> > import org.junit.Test;
> >
> > public class PartnerTest {
> >
> > private ObjectContext context;
> >
> > @Before
> > public void setUp() throws Exception {
> > ServerRuntime runtime = new ServerRuntime("cayenne-mxerp.xml");
> > context = runtime.getContext();
> > }
> >
> > @After
> > public void tearDown() throws Exception {
> > context.rollbackChanges();
> > }
> >
> > @Test
> > public void testDB() {
> > }
> >
> > }
> >
> > ...but it seems since 3.2M1 runtime.getContext() is deprecated?
> > What is the right way to get a context for testing?
> >
> > regards
> > Markus
> >
>
--
*Markus Reich*
Moosbach 28/2
6392 St. Jakob i.H.
www.markusreich.at / www.meeximum.at
markus.reich@markusreich.at
Re: Unit Testing WebApp with 3.2M1 release
Posted by John Huss <jo...@gmail.com>.
getContext() was renamed to newContext()
On Wed, Jul 24, 2013 at 3:51 PM, Markus Reich
<ma...@markusreich.at>wrote:
> Hi,
>
> I'm using following code for unit testing:
>
> package db;
>
> import org.apache.cayenne.ObjectContext;
> import org.apache.cayenne.access.DataContext;
> import org.apache.cayenne.configuration.server.ServerRuntime;
> import org.junit.After;
> import org.junit.Before;
> import org.junit.Test;
>
> public class PartnerTest {
>
> private ObjectContext context;
>
> @Before
> public void setUp() throws Exception {
> ServerRuntime runtime = new ServerRuntime("cayenne-mxerp.xml");
> context = runtime.getContext();
> }
>
> @After
> public void tearDown() throws Exception {
> context.rollbackChanges();
> }
>
> @Test
> public void testDB() {
> }
>
> }
>
> ...but it seems since 3.2M1 runtime.getContext() is deprecated?
> What is the right way to get a context for testing?
>
> regards
> Markus
>