At line 5 removed 1 line. |
|
At line 8 changed 8 lines. |
SqlRowSet rset = getJdbcTemplate().queryForRowSet( |
"select id, name from mytest where id > ? and name < ?", |
new Object[] {new Long(1), "Z"}); |
int i = 0; |
while (rset.next()) { |
i++; |
System.out.println("Row" + i + " " + rset.getString(2)); |
} |
import javax.naming.Context; |
import javax.naming.InitialContext; |
At line 10 added 46 lines. |
import junit.framework.TestCase; |
|
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 58 added 2 lines. |
[CreateDAO_zh] |
[CreateDAO_sp] |
At line 61 added 1 line. |
[CreateManager_es] |
At line 63 added 1 line. |
[QuickStart Guide_es] |
At line 65 added 1 line. |
[SpringControllerUnitTest] |
At line 67 added 2 lines. |
|
[δΈζζε|Articles_zh] |