org.junit.ComparisonFailure: expected:<'Connection refused[]'> but was:<'Connection refused\[: connect]'>

Hibernate JIRA | Sanne Grinovero | 5 months ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    org.hibernate.search.elasticsearch.test.HostCanBeConfiguredIT.shouldApplyConfiguredElasticsearchHost Failing for the past 5 builds (Since Unstable#522 ) Took 1 sec. Error Message expected:<'Connection refused[]'> but was:<'Connection refused\[: connect]'> Stacktrace {code:java} org.junit.ComparisonFailure: expected:<'Connection refused[]'> but was:<'Connection refused\[: connect]'> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 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.ThrowableAssert.hasMessage(ThrowableAssert.java:85) at org.hibernate.search.elasticsearch.test.HostCanBeConfiguredIT.shouldApplyConfiguredElasticsearchHost(HostCanBeConfiguredIT.java:48) {code} I've seen this happening only on Windows, I guess ES gives a slightly different error message on Windows?

    Hibernate JIRA | 5 months ago | Sanne Grinovero
    org.junit.ComparisonFailure: expected:<'Connection refused[]'> but was:<'Connection refused\[: connect]'>
  2. 0

    Incorrect spelling for true, false in Comparison failure

    YouTrack | 3 years ago
    org.junit.ComparisonFailure: Expected :[fals]e Actual :[tru]e <Click to see difference>
  3. 0

    Unit test execution failing when org.sonar.java.checks.verifier.JavaCheckVerifier is used

    Google Groups | 1 year ago | Vara Prasad
    org.junit.ComparisonFailure: expected:<null> but was:<4>
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    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.

    Hibernate JIRA | 5 years ago | Hardy Ferentschik
    org.junit.ComparisonFailure: [catalogItems should have been initialized] expected:<[tru]e> but was:<[fals]e>

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.junit.ComparisonFailure

      expected:<'Connection refused[]'> but was:<'Connection refused\[: connect]'>

      at sun.reflect.NativeConstructorAccessorImpl.newInstance0()
    2. Java RT
      Constructor.newInstance
      1. sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      2. sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      3. sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      4. java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      4 frames
    3. FEST Fluent Assertions
      ThrowableAssert.hasMessage
      1. org.fest.assertions.ConstructorInvoker.newInstance(ConstructorInvoker.java:36)
      2. org.fest.assertions.ComparisonFailureFactory.newComparisonFailure(ComparisonFailureFactory.java:60)
      3. org.fest.assertions.ComparisonFailureFactory.comparisonFailure(ComparisonFailureFactory.java:46)
      4. org.fest.assertions.Fail.comparisonFailed(Fail.java:83)
      5. org.fest.assertions.Fail.failIfNotEqual(Fail.java:71)
      6. org.fest.assertions.ThrowableAssert.hasMessage(ThrowableAssert.java:85)
      6 frames
    4. org.hibernate.search
      HostCanBeConfiguredIT.shouldApplyConfiguredElasticsearchHost
      1. org.hibernate.search.elasticsearch.test.HostCanBeConfiguredIT.shouldApplyConfiguredElasticsearchHost(HostCanBeConfiguredIT.java:48)
      1 frame