lightblue-platform/lightblue-client

Trouble using LightblueExternalResource in multiple test classes

Closed this issue · 5 comments

If I have two test classes, both with the external resource, and both with empty tests that make no lightblue calls, both test classes run and mongo is started/stopped both times.

If I have two test classes, both with the external resource, and both with tests that make calls to lightblue rest, only the first test class will run, and the second will never start in my IDE. From Maven in my command line, the second will fail with:

com.redhat.lightblue.client.http.LightblueHttpClientException: java.net.SocketException: Unexpected end of file from server
        at com.redhat.lightblue.client.http.transport.JavaNetHttpTransport.response(JavaNetHttpTransport.java:182)
        at com.redhat.lightblue.client.http.transport.JavaNetHttpTransport.executeRequest(JavaNetHttpTransport.java:127)
        at com.redhat.lightblue.client.http.LightblueHttpClient.callService(LightblueHttpClient.java:255)
        at com.redhat.lightblue.client.http.LightblueHttpClient.data(LightblueHttpClient.java:225)
        at com.redhat.lightblue.client.http.LightblueHttpClient.data(LightblueHttpClient.java:32)
        at org.esbtools.eventhandler.lightblue.BugTest1.insertNotificationEntities(BugTest1.java:72)

This leads me to believe one or more lightblue components are not being shut down correctly.

Does anyone else have this issue?

Have you tried running tests in separate forks?

On Mon, Jan 11, 2016 at 11:34 AM, Alec Henninger notifications@github.com
wrote:

Does anyone else have this issue?


Reply to this email directly or view it on GitHub
#231 (comment)
.

I have not had this issue. We have many cases at this point where this is working. Any chance you could provide example code?

Alright, could just be me. I'll look into it and get back to this issue.

@bserdar was right. It requires running the tests in another VM via the following Maven config:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19</version>
    <dependencies>
      <dependency>
        <groupId>org.apache.maven.surefire</groupId>
        <artifactId>surefire-junit47</artifactId>
        <version>2.19</version>
      </dependency>
    </dependencies>
    <configuration>
        <forkCount>1</forkCount>
        <reuseForks>false</reuseForks>
    </configuration>
  </plugin>

It would be nice if this would not be required, but I'm unblocked for now. Thanks all!