Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExampleRabbitListenerSpyAndCaptureTest fails #1190

Closed
winster opened this issue May 4, 2020 · 7 comments · Fixed by #1191
Closed

ExampleRabbitListenerSpyAndCaptureTest fails #1190

winster opened this issue May 4, 2020 · 7 comments · Fixed by #1191

Comments

@winster
Copy link

winster commented May 4, 2020

Depdencies: spring-boot-starter-test:2.2.5 & spring-rabbit-test:2.2.5
I had the impression that, I can use testcases in spring-rabbit-test in my application. But unfortunately, it does not run.
Major issue with org/springframework/amqp/rabbit/test/ExampleRabbitListenerSpyAndCaptureTest & ExampleRabbitListenerCaptureTest.

Test fails with error

Test ignored.
java.lang.NoClassDefFoundError: org/junit/Assume
  1. RabbitListenerTestHarness is not imported (because the same package). After import in my testcase, IntelliJ shows warning, (but allow me to run test - but test throws error mentioned above)
Could not autowire. No beans of 'RabbitListenerTestHarness' type found. 
@winster winster changed the title ExampleRabbitListenerSpyAndCaptureTest not running ExampleRabbitListenerSpyAndCaptureTest fails May 4, 2020
@artembilan
Copy link
Member

  1. java.lang.NoClassDefFoundError: org/junit/Assume - good catch! We have to fix BrokerRunningSupport to remove that JUnit 4 class.

  2. RabbitListenerTestHarness is not imported - right because those sample classes are indeed in the same package. We can fix that moving them to a different one, e.g. test.sample

The IntelliJ warning is not relevant. We don't create those beans explicitly so IDEA doesn't know about their configuration. Those beans are created by the @RabbitListenerTest processor.

So, two bugs over here.

Please, don't hesitate to fix them via contribution: https://github.com/spring-projects/spring-amqp/blob/master/CONTRIBUTING.adoc !

@garyrussell
Copy link
Contributor

FYI; this only happens when RabbitMQ is not running locally; we only reference the Assume class if we get an exception when connecting to Rabbit. When RabbitMQ is running, the test passes.

@garyrussell garyrussell self-assigned this May 4, 2020
@garyrussell
Copy link
Contributor

I am going to take it; it's a bit more complicated then just removing the references to Assume.

garyrussell added a commit to garyrussell/spring-amqp that referenced this issue May 4, 2020
Resolves spring-projects#1190

- Remove reference to `Assume` in `BrokerRunningSupport`
- Move example test cases to a new package so they can be easily copied/pasted
- Remove `assumeOnline` field - it looks like it was intended to support running
  tests only if RabbitMQ is NOT running; but there was never any way to set it
  to false

**cherry-pick to 2.2.x**
garyrussell added a commit to garyrussell/spring-amqp that referenced this issue May 4, 2020
Resolves spring-projects#1190

- Remove reference to `Assume` in `BrokerRunningSupport`
- Move example test cases to a new package so they can be easily copied/pasted
- Remove `assumeOnline` field - it looks like it was intended to support running
  tests only if RabbitMQ is NOT running; but there was never any way to set it
  to false

**cherry-pick to 2.2.x**
artembilan pushed a commit that referenced this issue May 5, 2020
Resolves #1190

- Remove reference to `Assume` in `BrokerRunningSupport`
- Move example test cases to a new package so they can be easily copied/pasted
- Remove `assumeOnline` field - it looks like it was intended to support running
  tests only if RabbitMQ is NOT running; but there was never any way to set it
  to false

**cherry-pick to 2.2.x**
artembilan pushed a commit that referenced this issue May 5, 2020
Resolves #1190

- Remove reference to `Assume` in `BrokerRunningSupport`
- Move example test cases to a new package so they can be easily copied/pasted
- Remove `assumeOnline` field - it looks like it was intended to support running
  tests only if RabbitMQ is NOT running; but there was never any way to set it
  to false

**cherry-pick to 2.2.x**
@winster
Copy link
Author

winster commented May 7, 2020

Thanks for the quick fix. How do I get the fix? I tried with 2.2.6.RELEASE (for spring-boot-starter-test & rabbit-test) from mavenrepo, but no luck.

@garyrussell
Copy link
Contributor

It will be in 2.2.7 which is not currently scheduled (we just released 2.2.6 last week).

You can work around it by adding the JUnit4 jar to the class path. If there is some valid reason that you can't do that, I can look at accelerating 2.2.7.

@artembilan
Copy link
Member

@winster , you could get a fix for now only from the https://repo.spring.io/libs-snapshot/ repository and overriding the version like this: <spring-amqp.version>2.2.7.BUILD-SNAPSHOT</spring-amqp.version>.

@winster
Copy link
Author

winster commented May 8, 2020

cool and thanks @garyrussell and @artembilan

artembilan added a commit that referenced this issue May 26, 2020
The regression after #1190

The `assumeNoException(e)` was missed in the `BrokerRunning`
when we don't have a locally ran RabbitMQ and no requirement.
With the `assumeNoException(e)` test are skipped with positive
outcome

**Cherry-pick to `2.2.x`**
artembilan added a commit that referenced this issue May 26, 2020
The regression after #1190

The `assumeNoException(e)` was missed in the `BrokerRunning`
when we don't have a locally ran RabbitMQ and no requirement.
With the `assumeNoException(e)` test are skipped with positive
outcome

**Cherry-pick to `2.2.x`**

# Conflicts:
#	spring-rabbit-junit/src/main/java/org/springframework/amqp/rabbit/junit/BrokerRunning.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants