[hibernate-issues] [Hibernate-JIRA] Commented: (HSEARCH-931) CollectionUpdateEventTest fails from the commans line when run after a unit test which extends JPATestcase

Hardy Ferentschik (JIRA) noreply at atlassian.com
Thu Sep 29 05:35:29 EDT 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-931?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43836#comment-43836 ] 

Hardy Ferentschik commented on HSEARCH-931:
-------------------------------------------

An even easier way to reproduce the error (also in the IDE). Change the _CollectionUpdateEventTest_ to:

{code}
	@Test
	public void testWithClassBridge() {
		EntityManagerFactory factory = new HibernatePersistence().createEntityManagerFactory( new HashMap() );
		factory.close();
		testScenario( true, 2, false );
	}
{code}

using _HibernatePersistence_ to create the _EntityManagerFactory_ creates some side effects in the test

> CollectionUpdateEventTest fails from the commans line when run after a unit test which extends JPATestcase
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: HSEARCH-931
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-931
>             Project: Hibernate Search
>          Issue Type: Bug
>          Components: tests
>    Affects Versions: 4.0.0.Beta2
>            Reporter: Hardy Ferentschik
>             Fix For: 4.0.0.CR1
>
>
> The first problem was that we could not reproduce the problem and that was due to the fact that the execution order of tests varies depending on the OS. The surefire plugin has the _runOrder_ property to define the order. The default is _filesystem_ which has different results on Mac vs Linux. On Mac the tests are run in alphabetical order on Linux in "random" order. 
> If the tests are ordered alphabetically JPA tests are run after _CollectionUpdateEventTest_ and all works fine. If the order is random and a JPA test runs first we get the following error:
> {noformat}
> -------------------------------------------------------------------------------
> Test set: org.hibernate.search.test.engine.optimizations.CollectionUpdateEventTest
> -------------------------------------------------------------------------------
> Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.574 sec <<< FAILURE!
> testWithClassBridge(org.hibernate.search.test.engine.optimizations.CollectionUpdateEventTest)  Time elapsed: 0.242 sec  <<< FAILURE!
> org.junit.ComparisonFailure: [catalogItems should have been initialized] expected:<[tru]e> but was:<[fals]e>
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>         at org.fest.assertions.ConstructorInvoker.newInstance(ConstructorInvoker.java:36)
>         at org.fest.assertions.ComparisonFailureFactory.newComparisonFailure(ComparisonFailureFactory.java:60)
>         at org.fest.assertions.ComparisonFailureFactory.comparisonFailure(ComparisonFailureFactory.java:46)
>         at org.fest.assertions.Fail.comparisonFailed(Fail.java:83)
>         at org.fest.assertions.Fail.failIfNotEqual(Fail.java:71)
>         at org.fest.assertions.GenericAssert.isEqualTo(GenericAssert.java:217)
>         at org.fest.assertions.BooleanAssert.isEqualTo(BooleanAssert.java:73)
>         at org.fest.assertions.BooleanAssert.isTrue(BooleanAssert.java:55)
>         at org.hibernate.search.test.engine.optimizations.CollectionUpdateEventTest.testScenario(CollectionUpdateEventTest.java:98)
>         at org.hibernate.search.test.engine.optimizations.CollectionUpdateEventTest.testWithClassBridge(CollectionUpdateEventTest.java:52)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
> {noformat} 
> At the moment we explicitly set the _runOrder_ option in the surefire plugin to _alphabetical_ which will make the tests pass. To trigger the failure you can change _runOrder_ to _reversealphabetical_ and run:
> {code}
> mvn test -Dtest=org.hibernate.search.test.engine.optimizations.CollectionUpdateEventTest,EntityManagerTest
> {code}
> Also important for this issue is that the surefire plugin is configured to only fork _once_ for all tests, so the same JVM is shared between tests. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list