Skip to content

Commit b2bd552

Browse files
committed
test: Ensure all integration tests run via JUnit 5
1 parent 257ea01 commit b2bd552

9 files changed

Lines changed: 44 additions & 57 deletions

File tree

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ pkg
33
doc
44
.bundle
55
nbproject
6-
**/target/*
7-
!**/target/.keep
6+
target/
7+
out/
88
Gemfile.lock
99
.idea
1010
warbler.iml

integration/pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@
4747
<type>gem</type>
4848
</dependency>
4949
<dependency>
50-
<groupId>junit</groupId>
51-
<artifactId>junit</artifactId>
52-
<version>4.13.2</version>
50+
<groupId>org.junit.jupiter</groupId>
51+
<artifactId>junit-jupiter</artifactId>
52+
<version>5.14.0</version>
5353
<scope>test</scope>
5454
</dependency>
5555
<dependency>
5656
<groupId>org.hamcrest</groupId>
57-
<artifactId>hamcrest-all</artifactId>
58-
<version>1.3</version>
57+
<artifactId>hamcrest</artifactId>
58+
<version>3.0</version>
5959
<scope>test</scope>
6060
</dependency>
6161
</dependencies>

integration/rails7_test/src/test/java/org/jruby/warbler/Rails7AppTestIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package org.jruby.warbler;
22

3+
import org.junit.jupiter.api.Test;
4+
35
import java.net.*;
46
import java.io.*;
57

6-
import org.junit.Test;
7-
88
import static org.hamcrest.CoreMatchers.containsString;
99
import static org.hamcrest.MatcherAssert.assertThat;
1010

integration/runnable_test/pom.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
</parent>
1010

1111
<artifactId>runnable_test</artifactId>
12-
<packaging>pom</packaging>
13-
1412
<name>runnable_test</name>
1513

1614
<properties>
@@ -21,7 +19,6 @@
2119
<plugins>
2220
<plugin>
2321
<artifactId>maven-clean-plugin</artifactId>
24-
<version>2.5</version>
2522
<executions>
2623
<execution>
2724
<id>auto-clean</id>
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
package org.jruby.warbler;
22

3+
import org.junit.jupiter.api.Test;
4+
35
import java.net.*;
46
import java.io.*;
5-
import org.junit.Assert;
6-
import org.junit.Test;
7-
import org.hamcrest.Matcher;
8-
import org.hamcrest.Matchers;
7+
8+
import static org.junit.jupiter.api.Assertions.assertTrue;
9+
910

1011
/**
1112
* Unit test for simple runnable war.
1213
*/
13-
public class RunnableWarTestIT
14-
{
14+
public class RunnableWarTestIT {
1515
@Test
16-
public void testApp() throws Exception
17-
{
16+
public void testApp() {
1817
String testFilename = System.getProperty("testFilename");
1918
File f = new File(testFilename);
20-
Assert.assertTrue(testFilename + "should exist", f.exists());
19+
assertTrue(f.exists(), testFilename + "should exist");
2120
}
2221
}

integration/runnable_w_bundler_test/pom.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
</parent>
1010

1111
<artifactId>runnable_w_bundler_test</artifactId>
12-
<packaging>pom</packaging>
13-
1412
<name>runnable_w_bundler_test</name>
1513

1614
<properties>
@@ -20,8 +18,8 @@
2018
<build>
2119
<plugins>
2220
<plugin>
21+
<groupId>org.apache.maven.plugins</groupId>
2322
<artifactId>maven-clean-plugin</artifactId>
24-
<version>2.5</version>
2523
<executions>
2624
<execution>
2725
<id>auto-clean</id>
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
package org.jruby.warbler;
22

3+
import org.junit.jupiter.api.Test;
4+
35
import java.net.*;
46
import java.io.*;
5-
import org.junit.Assert;
6-
import org.junit.Test;
7-
import org.hamcrest.Matcher;
8-
import org.hamcrest.Matchers;
7+
8+
import static org.junit.jupiter.api.Assertions.assertTrue;
99

1010
/**
1111
* Unit test for simple runnable war.
1212
*/
13-
public class RunnableWarTestIT
14-
{
13+
public class RunnableWarTestIT {
1514
@Test
16-
public void testApp() throws Exception
17-
{
15+
public void testApp() {
1816
String testFilename = System.getProperty("testFilename");
1917
File f = new File(testFilename);
20-
Assert.assertTrue(testFilename + "should exist", f.exists());
18+
assertTrue(f.exists(), testFilename + "should exist");
2119
}
2220
}

integration/simple_rack_test/pom.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
</parent>
1010

1111
<artifactId>simple_rack_test</artifactId>
12-
<packaging>pom</packaging>
13-
1412
<name>simple_rack_test</name>
1513

1614
<build>
@@ -26,7 +24,7 @@
2624
</executions>
2725
</plugin>
2826
<plugin>
29-
<groupId>org.mortbay.jetty</groupId>
27+
<groupId>org.eclipse.jetty</groupId>
3028
<artifactId>jetty-maven-plugin</artifactId>
3129
<executions>
3230
<execution>
Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,33 @@
11
package org.jruby.warbler;
22

3+
import org.junit.jupiter.api.Test;
4+
35
import java.net.*;
46
import java.io.*;
5-
import org.junit.Assert;
6-
import org.junit.Test;
7-
import org.hamcrest.Matcher;
8-
import org.hamcrest.Matchers;
7+
8+
import static org.junit.jupiter.api.Assertions.assertEquals;
9+
910

1011
/**
1112
* Unit test for simple App.
1213
*/
13-
public class AppTestIT
14-
{
15-
private static String appName = "simple_rack_test-1.0";
16-
14+
public class AppTestIT {
1715
/**
1816
* Hit the web app and test the response
1917
*/
2018
@Test
21-
public void testApp() throws Exception
22-
{
23-
URL url = new URL("http://localhost:8080/" + appName);
24-
URLConnection conn = url.openConnection();
25-
BufferedReader in = new BufferedReader( new InputStreamReader( conn.getInputStream()));
26-
27-
String inputLine;
28-
String content = "";
29-
30-
while ((inputLine = in.readLine()) != null)
31-
content = inputLine;
32-
in.close();
19+
public void testApp() throws Exception {
20+
assertEquals("Hello, World", contentFrom("http://localhost:8080/"));
21+
}
3322

34-
Assert.assertEquals("Hello, World", content);
23+
private static String contentFrom(@SuppressWarnings("SameParameterValue") String url) throws IOException {
24+
URL route = new URL(url);
25+
StringBuilder content = new StringBuilder();
26+
try (BufferedReader in = new BufferedReader(new InputStreamReader(route.openStream()))) {
27+
while (in.ready()) {
28+
content.append(in.readLine());
29+
}
30+
}
31+
return content.toString();
3532
}
3633
}

0 commit comments

Comments
 (0)