nicoloboschi opened a new pull request, #15566:
URL: https://github.com/apache/pulsar/pull/15566

   ### Motivation
   BeforeTest TestNG annotations is not "compatible" with 
`MockitoCleanupListener`. 
   Test `ProducerBuilderImplTest` uses BeforeTest in order to mock some 
behaviours. When running the single test from CLI (IntelliJ uses another 
mechanism) with `mvn test -Dtest='ProducerBuilderImplTest' -pl pulsar-client`, 
it fails with
   ```
   java.lang.NullPointerException
        at 
org.apache.pulsar.client.impl.PulsarClientImpl.createProducerAsync(PulsarClientImpl.java:304)
        at 
org.apache.pulsar.client.impl.ProducerBuilderImpl.createAsync(ProducerBuilderImpl.java:109)
        at 
org.apache.pulsar.client.impl.ProducerBuilderImpl.create(ProducerBuilderImpl.java:86)
        at 
org.apache.pulsar.client.impl.ProducerBuilderImplTest.testProducerBuilderImpl(ProducerBuilderImplTest.java:76)
 
   ```
   This is because the order is: 
   1. BeforeTest method
   2. MockitoCleanupListener
   3. Test
   
   In order to solve the issue we can use @BeforeClass annotation and the order 
will be:
   
   1. MockitoCleanupListener
   2. BeforeClass method
   3. Test
   
   ### Modifications
   
   * Replaced BeforeTest with BeforeClass and set alwaysRun=true
   
   - [x] `no-need-doc` 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to