JAVA-2824 Fix tests in Java 9 and above modules (Update after PR review)

This commit is contained in:
mikr 2020-10-29 22:01:15 +01:00
parent 0e54f859cc
commit 4cac5aa1d8
4 changed files with 35 additions and 32 deletions

View File

@ -18,6 +18,7 @@ import java.security.NoSuchAlgorithmException;
import java.time.Duration;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
public class HttpRequestUnitTest {
@ -52,8 +53,8 @@ public class HttpRequestUnitTest {
* This test will fail as soon as the given URL returns a HTTP 2 response.
* Therefore, let's leave it commented out.
* */
/* @Test
@Test
@Disabled
public void shouldFallbackToHttp1_1WhenWebsiteDoesNotUseHttp2() throws IOException, InterruptedException, URISyntaxException, NoSuchAlgorithmException {
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI("https://postman-echo.com/get"))
@ -65,7 +66,7 @@ public class HttpRequestUnitTest {
.send(request, HttpResponse.BodyHandlers.ofString());
assertThat(response.version(), equalTo(HttpClient.Version.HTTP_1_1));
}*/
}
@Test
public void shouldReturnStatusOKWhenSendGetRequestWithDummyHeaders() throws IOException, InterruptedException, URISyntaxException {

View File

@ -10,6 +10,7 @@ import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import static org.junit.Assert.assertTrue;
@ -40,15 +41,16 @@ public class ScreenshotUnitTest {
assertTrue(imageFile.exists());
}
// This methods needs a component as a parameter and can only be run from an application with a GUI
// @Test
// public void givenComponent_whenTakeScreenshot_thenSaveToFile(Component component) throws Exception {
// Rectangle componentRect = component.getBounds();
// BufferedImage bufferedImage = new BufferedImage(componentRect.width, componentRect.height, BufferedImage.TYPE_INT_ARGB);
// component.paint(bufferedImage.getGraphics());
// File imageFile = File.createTempFile("component-screenshot", "bmp");
// ImageIO.write(bufferedImage, "bmp", imageFile);
// assertTrue(imageFile.exists());
// }
// This methods needs a component as a parameter and can only be run from an application with a GUI
@Test
@Disabled
public void givenComponent_whenTakeScreenshot_thenSaveToFile(Component component) throws Exception {
Rectangle componentRect = component.getBounds();
BufferedImage bufferedImage = new BufferedImage(componentRect.width, componentRect.height, BufferedImage.TYPE_INT_ARGB);
component.paint(bufferedImage.getGraphics());
File imageFile = File.createTempFile("component-screenshot", "bmp");
ImageIO.write(bufferedImage, "bmp", imageFile);
assertTrue(imageFile.exists());
}
}

View File

@ -9,7 +9,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.time.StopWatch;
import org.junit.Test;
public class ElapsedTimeUnitTest {
public class ElapsedTimeManualTest {
@Test
public void givenRunningTask_whenMeasuringTimeWithCurrentTimeMillis_thenGetElapsedTime() throws InterruptedException {
@ -55,7 +55,7 @@ public class ElapsedTimeUnitTest {
The below test depends on the elapsed time, which isn't ideal in a test.
Also, it slows down test execution artificially.
*/
/*@Test
@Test
public void givenRunningTask_whenMeasuringTimeWithInstantClass_thenGetElapsedTime() throws InterruptedException {
Instant start = Instant.now();
System.out.println("start: " + start);
@ -70,7 +70,7 @@ public class ElapsedTimeUnitTest {
System.out.println("elapsed: " + timeElapsed);
assertEquals(true, (2000L <= timeElapsed) && (timeElapsed <= 3000L));
}*/
}
/**
* Simulate task running for 2.5 seconds.

32
pom.xml
View File

@ -1368,21 +1368,21 @@
<modules>
<module>core-java-modules/core-java-9</module>
<module>core-java-modules/core-java-9-improvements</module>
<module>core-java-modules/core-java-9-jigsaw</module> <!-- to be fixed in http://team.baeldung.com/browse/JAVA-2824 -->
<!-- <module>core-java-modules/core-java-9-new-features</module> --> <!-- to be fixed in http://team.baeldung.com/browse/JAVA-2824 -->
<module>core-java-modules/core-java-9-jigsaw</module>
<!-- <module>core-java-modules/core-java-9-new-features</module> --> <!-- uses preview features, to be decided how to handle -->
<module>core-java-modules/core-java-9-streams</module>
<module>core-java-modules/core-java-10</module>
<module>core-java-modules/core-java-11</module> <!-- to be fixed in http://team.baeldung.com/browse/JAVA-2824 -->
<module>core-java-modules/core-java-11</module>
<!-- <module>core-java-modules/core-java-12</module> --> <!-- uses preview features, to be decided how to handle -->
<!-- <module>core-java-modules/core-java-13</module> --> <!-- uses preview features, to be decided how to handle -->
<!-- <module>core-java-modules/core-java-14</module> --> <!-- uses preview features, to be decided how to handle -->
<module>core-java-modules/core-java-collections-set</module>
<module>core-java-modules/core-java-date-operations-1</module> <!-- to be fixed in http://team.baeldung.com/browse/JAVA-2824 -->
<module>core-java-modules/core-java-datetime-conversion</module> <!-- to be fixed in http://team.baeldung.com/browse/JAVA-2824 -->
<module>core-java-modules/core-java-datetime-string</module> <!-- to be fixed in http://team.baeldung.com/browse/JAVA-2824 -->
<module>core-java-modules/core-java-date-operations-1</module>
<module>core-java-modules/core-java-datetime-conversion</module>
<module>core-java-modules/core-java-datetime-string</module>
<module>core-java-modules/core-java-jpms</module>
<module>core-java-modules/core-java-os</module> <!-- to be fixed in http://team.baeldung.com/browse/JAVA-2824 -->
<module>core-java-modules/core-java-time-measurements</module> <!-- to be fixed in http://team.baeldung.com/browse/JAVA-2824 -->
<module>core-java-modules/core-java-os</module>
<module>core-java-modules/core-java-time-measurements</module>
<module>core-java-modules/multimodulemavenproject</module>
</modules>
</profile>
@ -1412,21 +1412,21 @@
<modules>
<module>core-java-modules/core-java-9</module>
<module>core-java-modules/core-java-9-improvements</module>
<module>core-java-modules/core-java-9-jigsaw</module> <!-- to be fixed in http://team.baeldung.com/browse/JAVA-2824 -->
<!-- <module>core-java-modules/core-java-9-new-features</module> --> <!-- to be fixed in http://team.baeldung.com/browse/JAVA-2824 -->
<module>core-java-modules/core-java-9-jigsaw</module>
<!-- <module>core-java-modules/core-java-9-new-features</module> --> <!-- uses preview features, to be decided how to handle -->
<module>core-java-modules/core-java-9-streams</module>
<module>core-java-modules/core-java-10</module>
<module>core-java-modules/core-java-11</module> <!-- to be fixed in http://team.baeldung.com/browse/JAVA-2824 -->
<module>core-java-modules/core-java-11</module>
<!-- <module>core-java-modules/core-java-12</module> --> <!-- uses preview features, to be decided how to handle -->
<!-- <module>core-java-modules/core-java-13</module> --> <!-- uses preview features, to be decided how to handle -->
<!-- <module>core-java-modules/core-java-14</module> --> <!-- uses preview features, to be decided how to handle -->
<module>core-java-modules/core-java-collections-set</module>
<module>core-java-modules/core-java-date-operations-1</module> <!-- to be fixed in http://team.baeldung.com/browse/JAVA-2824 -->
<module>core-java-modules/core-java-datetime-conversion</module> <!-- to be fixed in http://team.baeldung.com/browse/JAVA-2824 -->
<module>core-java-modules/core-java-datetime-string</module> <!-- to be fixed in http://team.baeldung.com/browse/JAVA-2824 -->
<module>core-java-modules/core-java-date-operations-1</module>
<module>core-java-modules/core-java-datetime-conversion</module>
<module>core-java-modules/core-java-datetime-string</module>
<module>core-java-modules/core-java-jpms</module>
<module>core-java-modules/core-java-os</module> <!-- to be fixed in http://team.baeldung.com/browse/JAVA-2824 -->
<module>core-java-modules/core-java-time-measurements</module> <!-- to be fixed in http://team.baeldung.com/browse/JAVA-2824 -->
<module>core-java-modules/core-java-os</module>
<module>core-java-modules/core-java-time-measurements</module>
<module>core-java-modules/multimodulemavenproject</module>
</modules>
</profile>