Hi!
We are using wicket-1.4.8.
We have a lot of unit tests and it takes long time to run them. To reduce
running time at multi-core systems we decided to run them parallel in
multiple threads.
I use this
http://mycila.googlecode.com/svn/sandbox/src/main/java/com/mycila/sandbox/junit/runner/ConcurrentSuite.java
class
to run junits concurrently.
First problem I've faced with was some exception from
org.apache.wicket.jmx.Initializer :
*org.apache.wicket.WicketRuntimeException:
javax.management.InstanceAlreadyExistsException:
org.apache.wicket.app.SimpleWicketTester$1:type=Application
        at org.apache.wicket.jmx.Initializer.init(Initializer.java:207)
        at
org.apache.wicket.Application.callInitializers(Application.java:843)
        at
org.apache.wicket.Application.initializeComponents(Application.java:678)
        at
org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:725)
        at
org.apache.wicket.protocol.http.MockWebApplication.<init>(MockWebApplication.java:168)

        at
org.apache.wicket.util.tester.BaseWicketTester.<init>(BaseWicketTester.java:219)

        at
org.apache.wicket.util.tester.WicketTester.<init>(WicketTester.java:325)
        at
org.apache.wicket.util.tester.WicketTester.<init>(WicketTester.java:308)
        at
com.infoblox.platform.test.PlatformWicketTester.<init>(PlatformWicketTester.java:60)

        at
com.infoblox.nios.ui.widget.test.SimpleWicketTester.setUp(SimpleWicketTester.java:54)
*

I've patched the Initializer file, added some synchronization:
*
synchronized (mbeanServer) {


    int i = 0;
    while (mbeanServer.isRegistered(appBeanName))
    {
    tempDomain = name + "-" + i++; //$NON-NLS-1$
    appBeanName = new ObjectName(tempDomain + ":type=Application");
//$NON-NLS-1$
    }
    domain = tempDomain;

    Application appBean = new Application(application);
    register(appBean, appBeanName);

    register(new ApplicationSettings(application), new ObjectName(domain +
    ":type=Application,name=ApplicationSettings")); //$NON-NLS-1$
    register(new DebugSettings(application), new ObjectName(domain +
    ":type=Application,name=DebugSettings")); //$NON-NLS-1$
    register(new MarkupSettings(application), new ObjectName(domain +
    ":type=Application,name=MarkupSettings")); //$NON-NLS-1$
    register(new ResourceSettings(application), new ObjectName(domain +
    ":type=Application,name=ResourceSettings")); //$NON-NLS-1$
    register(new PageSettings(application), new ObjectName(domain +
    ":type=Application,name=PageSettings")); //$NON-NLS-1$
    register(new RequestCycleSettings(application), new ObjectName(domain +
    ":type=Application,name=RequestCycleSettings")); //$NON-NLS-1$
    register(new SecuritySettings(application), new ObjectName(domain +
    ":type=Application,name=SecuritySettings")); //$NON-NLS-1$
    register(new SessionSettings(application), new ObjectName(domain +
    ":type=Application,name=SessionSettings")); //$NON-NLS-1$
    register(new CookieValuePersisterSettings(application), new
ObjectName(domain +
    ":type=Application,name=CookieValuePersisterSettings")); //$NON-NLS-1$

    RequestLogger sessionsBean = new RequestLogger(application);
    ObjectName sessionsBeanName = new ObjectName(domain +
":type=RequestLogger"); //$NON-NLS-1$
    register(sessionsBean, sessionsBeanName);
}*

and the problem was gone.

The second problem I found was such mysterious exceptions from different
classes:
*org.apache.wicket.WicketRuntimeException: Exception in rendering
component: [MarkupContainer [Component id = _header_0]]
        at org.apache.wicket.Component.renderComponent(Component.java:2658)
        at
org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1512)
        at org.apache.wicket.Component.render(Component.java:2450)
        at
org.apache.wicket.MarkupContainer.autoAdd(MarkupContainer.java:229)
        at
org.apache.wicket.markup.resolver.HtmlHeaderResolver.resolve(HtmlHeaderResolver.java:80)

        at
org.apache.wicket.markup.resolver.ComponentResolvers.resolve(ComponentResolvers.java:81)

        at
org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1418)
        at
org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1528)
        at org.apache.wicket.Page.onRender(Page.java:1565)
        at org.apache.wicket.Component.render(Component.java:2450)
        at org.apache.wicket.Page.renderPage(Page.java:914)
        at
org.apache.wicket.request.target.component.PageRequestTarget.respond(PageRequestTarget.java:63)

        at
org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:105)

        at
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1258)

        at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
        at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
        at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
        at
org.apache.wicket.protocol.http.MockWebApplication.processRequestCycle(MockWebApplication.java:524)

        at
org.apache.wicket.util.tester.BaseWicketTester.executeListener(BaseWicketTester.java:265)

        at
org.apache.wicket.util.tester.BaseWicketTester.startPage(BaseWicketTester.java:249)

        at
com.infoblox.nios.ui.widget.test.DummyPlatformWicketTester.startPlatformPanel(DummyPlatformWicketTester.java:440)

        at
com.infoblox.nios.ui.page.permissions.dialogs.TestCommonPermissionPanel.testRoleCorrectRender(TestCommonPermissionPanel.java:84)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

        at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

        at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

        at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

        at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

        at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
        at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

        at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
        at
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
        at org.junit.runners.Suite.runChild(Suite.java:128)
        at org.junit.runners.Suite.runChild(Suite.java:24)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown
Source)
        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown
Source)
        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
        at java.util.concurrent.ConcurrentHashMap.putIfAbsent(Unknown
Source)
        at org.apache.wicket.SharedResources.add(SharedResources.java:162)
        at
org.apache.wicket.ResourceReference.bind(ResourceReference.java:167)
        at
org.apache.wicket.ResourceReference.getSharedResourceKey(ResourceReference.java:230)

        at org.apache.wicket.RequestCycle.urlFor(RequestCycle.java:1068)
        at org.apache.wicket.RequestCycle.urlFor(RequestCycle.java:1053)
        at
org.apache.wicket.markup.html.internal.HeaderResponse.renderJavascriptReference(HeaderResponse.java:157)

        at
com.infoblox.widget.ext.ExtInitializerBehavior.renderOptional(ExtInitializerBehavior.java:263)

        at
com.infoblox.widget.ext.ExtBaseInitializer.renderHead(ExtBaseInitializer.java:126)

        at
com.infoblox.widget.ext.ExtInitializerBehavior.renderHead(ExtInitializerBehavior.java:158)

        at
com.infoblox.nios.ui.page.IBExtInitializerBehavior.renderHead(IBExtInitializerBehavior.java:107)

        at org.apache.wicket.Component.renderHead(Component.java:2701)
        at
org.apache.wicket.markup.html.internal.HtmlHeaderContainer.renderHeaderSections(HtmlHeaderContainer.java:218)

        at
org.apache.wicket.markup.html.internal.HtmlHeaderContainer.onComponentTagBody(HtmlHeaderContainer.java:137)

        at org.apache.wicket.Component.renderComponent(Component.java:2619)
        ... 52 more*

Then I found the notice in the
org.apache.wicket.protocol.http.MockWebApplication:
* * <p>
 * IMPORTANT NOTES
 * <ul>
 * <li>This harness is SINGLE THREADED - there is only one global session.
For multi-threaded
 * testing you must do integration testing with a full tester server.
 * </ul>*
If I got correctly, Wicket testers can't be run in multiple threads.
But this class is absent in new version of wicket, 1.5.x.
Does that mean that there are no concurrency problems with WicketTester in
1.5.x version?
I'll be thankful for any tips of running wicket tests in paralllel.

Thanks

Reply via email to