| At line 1 changed 1 line. |
| [{Java2HtmlPlugin |
| [this mailing list thread|http://nagoya.apache.org/eyebrowse/[email protected]&msgNo=451]. |
| At line 3 changed 6 lines. |
| public static Test suite() { |
| return new TestSetup(new TestSuite(UserDaoTest.class)) { |
| public void setUp() throws Exception { |
| start(); |
| dao = (UserDAO) ctx.getBean("userDAO"); |
| } |
| [What is this SandBox?|WhatIsThisSandBox] |
| At line 10 changed 6 lines. |
| public void tearDown() throws Exception { |
| stop(); |
| dao = null; |
| } |
| }; |
| } |
| [{Java2HtmlPlugin |
| At line 17 changed 1 line. |
| }] |
| import javax.naming.Context; |
| import javax.naming.InitialContext; |
| At line 19 changed 1 line. |
| [{Java2HtmlPlugin |
| import junit.framework.TestCase; |
| At line 21 changed 11 lines. |
| protected static void start() throws Exception { |
| String[] paths = {"/WEB-INF/applicationContext*.xml", |
| "/org/appfuse/dao/applicationContext-test.xml"}; |
| ctx = new ClassPathXmlApplicationContext(paths); |
| |
| DataSource ds = (DataSource) ctx.getBean("dataSource"); |
| conn = new DatabaseConnection(ds.getConnection()); |
| dataSet = new XmlDataSet(new FileInputStream("test/data/sample-data.xml")); |
| // clear table and insert only sample data |
| DatabaseOperation.CLEAN_INSERT.execute(conn, dataSet); |
| } |
| import org.mockejb.MockContainer; |
| import org.mockejb.SessionBeanDescriptor; |
| import org.mockejb.jndi.MockContextFactory; |
| import org.springframework.context.ApplicationContext; |
| import org.springframework.context.support.ClassPathXmlApplicationContext; |
|
| /** |
| * Parent TestCase class for testing EJBs using MockEJB |
| * |
| * @author mraible |
| * |
| */ |
| public abstract class MockEJBTestCase extends TestCase { |
|
| /** |
| * This method sets up a MockContainer and allows you to deploy an EJB to |
| * it. Override <code>onSetUp()</code> to add custom set-up behavior. |
| * |
| * @see #onSetUp() |
| */ |
| protected final void setUp() throws Exception { |
| MockContextFactory.setAsInitial(); |
|
| Context ctx = new InitialContext(); |
| ApplicationContext appCtx = |
| new ClassPathXmlApplicationContext(getConfigLocations()); |
| |
| ctx.bind("java:comp/env/jdbc/appDS", appCtx.getBean("dataSource")); |
| |
| MockContainer mc = new MockContainer(ctx); |
| SessionBeanDescriptor dd = getDeploymentDescriptor(); |
| mc.deploy(dd); |
| onSetUp(); |
| } |
|
| protected String[] getConfigLocations() { |
| return new String[] { "classpath:/applicationContext.xml" }; |
| } |
|
| protected void onSetUp() throws Exception {} |
|
| protected abstract SessionBeanDescriptor getDeploymentDescriptor(); |
| } |
|
| At line 57 added 12 lines. |
|
| [CreateDAO_zh] |
| [CreateDAO_sp] |
|
| [CreateManager_es] |
|
| [QuickStart Guide_es] |
|
| [SpringControllerUnitTest] |
|
|
| [δΈζζε|Articles_zh] |