Open
Description
When running mvn clean test
, we're seeing the DynamicFederatedServiceCollectionImplTest
sometimes fail and sometimes pass in sequential executions on the exact same code. Here's the stack trace of the failure:
-------------------------------------------------------------------------------
Test set: org.onebusaway.federations.impl.DynamicFederatedServiceCollectionImplTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 30.466 sec <<< FAILURE!
test(org.onebusaway.federations.impl.DynamicFederatedServiceCollectionImplTest) Time elapsed: 30.461 sec <<< FAILURE!
java.lang.AssertionError:
at org.junit.Assert.fail(Assert.java:91)
at org.junit.Assert.assertTrue(Assert.java:43)
at org.junit.Assert.assertTrue(Assert.java:54)
at org.onebusaway.federations.impl.DynamicFederatedServiceCollectionImplTest.test(DynamicFederatedServiceCollectionImplTest.java:119)
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:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
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:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:115)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:102)
at org.apache.maven.surefire.Surefire.run(Surefire.java:180)
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:606)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
Here's the code that causes the failure:
Set<FederatedService> services = _collection.getAllServices();
assertTrue(services.isEmpty());
_registry.addService("http://localhost:" + PORT + "/service-A/service",
SimpleFederatedService.class.getName(), new HashMap<String, String>());
Thread.sleep(TIMEOUT);
services = _collection.getAllServices();
assertEquals(1, services.size());
SimpleFederatedService service = (SimpleFederatedService) _collection.getServiceForAgencyId("A");
assertEquals("A", service.getValueForId(""));
_registry.addService("http://localhost:" + PORT + "/service-B/service",
SimpleFederatedService.class.getName(), new HashMap<String, String>());
Thread.sleep(TIMEOUT);
services = _collection.getAllServices();
assertEquals(2, services.size());
service = (SimpleFederatedService) _collection.getServiceForAgencyId("A");
assertEquals("A", service.getValueForId(""));
service = (SimpleFederatedService) _collection.getServiceForAgencyId("B");
assertEquals("B", service.getValueForId(""));
// Simulate a server crash
_server.stop();
_server = null;
Thread.sleep(TIMEOUT);
services = _collection.getAllServices();
assertTrue(services.isEmpty());
The final assertTrue(services.isEmpty());
is what triggers the failure.