| At line 5 removed 1 line. |
|
| At line 8 changed 8 lines. |
| List list = new ArrayList(); |
| ... |
| CollectionUtils.forAllDo(list, new Closure() { |
| public void execute(Object obj) { |
| // execute something for each item obj |
| } |
| }); |
| }] |
| import javax.naming.Context; |
| import javax.naming.InitialContext; |
| At line 10 added 1 line. |
| import junit.framework.TestCase; |
| At line 18 changed 1 line. |
| Configuring (and more importantly, supressing) Tomcat 5.x logging |
| import org.mockejb.MockContainer; |
| import org.mockejb.SessionBeanDescriptor; |
| import org.mockejb.jndi.MockContextFactory; |
| import org.springframework.context.ApplicationContext; |
| import org.springframework.context.support.ClassPathXmlApplicationContext; |
| At line 20 changed 1 line. |
| Create a log4j.properties file in $CATALINA_HOME/common/classes |
| /** |
| * Parent TestCase class for testing EJBs using MockEJB |
| * |
| * @author mraible |
| * |
| */ |
| public abstract class MockEJBTestCase extends TestCase { |
| At line 22 changed 10 lines. |
| {{{ |
| log4j.rootLogger=ERROR, R |
| log4j.appender.R=org.apache.log4j.DailyRollingFileAppender |
| log4j.appender.R.File=${catalina.home}/logs/tomcat.log |
| log4j.appender.R.DatePattern='.'yyyy-MM-dd |
| log4j.appender.R.layout=org.apache.log4j.PatternLayout |
| log4j.appender.R.layout.ConversionPattern={%p} %c{2} %x %m%n |
| |
| |
| }}} |
| /** |
| * 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(); |
| At line 33 changed 1 line. |
| You also need to copy commons-logging.jar and log4j-1.2.9.jar to $CATALINA_HOME/common/lib. |
| 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(); |
| } |
| At line 35 changed 1 line. |
| Then, in your application log4j.properties file, add this: |
| protected String[] getConfigLocations() { |
| return new String[] { "classpath:/applicationContext.xml" }; |
| } |
| At line 37 changed 1 line. |
| {{{ |
| protected void onSetUp() throws Exception {} |
| At line 39 changed 4 lines. |
| # Suppress the tomcat logging whilst DEBUG is switched on |
| log4j.logger.org.apache.catalina.core=ERROR |
| log4j.logger.org.apache.catalina.session=ERROR |
| log4j.logger.org.apache.jasper.compiler=ERROR |
| protected abstract SessionBeanDescriptor getDeploymentDescriptor(); |
| } |
| At line 44 changed 1 line. |
| }}} |
| }] |
| At line 46 changed 3 lines. |
| Because if, whilst developing, you set your root logger to DEBUG, then it seems |
| to set the Tomcat logging to DEBUG as well, and you will probably witness thousands of lines |
| of compilation trace from the Jasper compiler! |
| [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 68 added 1 line. |
| [δΈζζε|Articles_zh] |