You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently working on open source project which have junit test cases (Junit 4) using EasyMock. When I use ContiPerf for testing performance with many threads , I get this exception:
org.databene.contiperf.PerfTestExecutionError: java.util.ConcurrentModificationException
at org.databene.contiperf.util.ContiPerfUtil.executionError(ContiPerfUtil.java:58)
at org.databene.contiperf.junit.JUnitInvoker.invoke(JUnitInvoker.java:46)
at org.databene.contiperf.util.InvokerProxy.invoke(InvokerProxy.java:38)
at org.databene.contiperf.PerformanceTracker.invoke(PerformanceTracker.java:87)
at org.databene.contiperf.CountRunner.run(CountRunner.java:44)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:819)
at java.util.ArrayList$Itr.next(ArrayList.java:791)
at org.easymock.internal.UnorderedBehavior.addExpected(UnorderedBehavior.java:38)
at org.easymock.internal.MocksBehavior.addExpected(MocksBehavior.java:61)
at org.easymock.internal.RecordState.times(RecordState.java:184)
at org.easymock.internal.RecordState.closeMethod(RecordState.java:226)
at org.easymock.internal.RecordState.invoke(RecordState.java:76)
at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:40)
at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:85)
at $Proxy7.getByName(Unknown Source)
at fi.hut.soberit.agilefant.business.SettingBusinessTest.testStoreSetting_boolean(SettingBusinessTest.java:94)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.databene.contiperf.junit.JUnitInvoker.invoke(JUnitInvoker.java:43)
... 4 more
My Question is how can I use multi threads using ContiPerf with EasyMock?
And to be more clear the test case like this:
@Test
@PerfTest(invocations = 10, threads = 5)
public void testStoreSetting_boolean() {
expect(settingDAO.getByName("bool")).andReturn(null);
expect(settingDAO.create(EasyMock.isA(Setting.class))).andReturn((Integer)1);
Setting created = new Setting();
created.setValue("true");
expect(settingDAO.getByName("bool")).andReturn(created);
replay(settingDAO);
testable.storeSetting("bool", true);
assertEquals("true", testable.retrieveByName("bool").getValue());
verify(settingDAO);
}
The text was updated successfully, but these errors were encountered:
I will need to dig a little more into it to see if something can be done about it. But right now I'll call this "normal". This idea was that for a multithreaded test, you record on mono thread and then we sync replay during the replay phase. In your case, you would need full sync. Which could be done by EasyMock, but also externally.
For instance,
@Test
@PerfTest(invocations = 10, threads = 5)
public void testStoreSetting_boolean() {
Setting created = new Setting();
created.setValue("true");
synchronized(this) {
expect(settingDAO.getByName("bool")).andReturn(null);
expect(settingDAO.create(EasyMock.isA(Setting.class))).andReturn((Integer)1);
expect(settingDAO.getByName("bool")).andReturn(created);
}
replay(settingDAO);
testable.storeSetting("bool", true);
assertEquals("true", testable.retrieveByName("bool").getValue());
verify(settingDAO);
}
might work.
I will keep this bug open for now in case you might do something better than that.
I am currently working on open source project which have junit test cases (Junit 4) using EasyMock. When I use ContiPerf for testing performance with many threads , I get this exception:
My Question is how can I use multi threads using ContiPerf with EasyMock?
And to be more clear the test case like this:
The text was updated successfully, but these errors were encountered: