Migrate tests to JUnit 5 (#8519)

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born
2020-09-21 18:21:26 +02:00
committed by GitHub
parent 6df6783b60
commit bd82ca82df
478 changed files with 3996 additions and 4419 deletions

View File

@@ -12,7 +12,7 @@
*/
package org.openhab.binding.fmiweather;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.*;
import java.io.BufferedReader;
import java.io.IOException;
@@ -30,7 +30,7 @@ import org.eclipse.jdt.annotation.Nullable;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import org.openhab.binding.fmiweather.internal.client.Client;
import org.openhab.binding.fmiweather.internal.client.Data;
import org.openhab.binding.fmiweather.internal.client.FMIResponse;
@@ -47,7 +47,7 @@ public class AbstractFMIResponseParsingTest {
@NonNullByDefault({})
protected Client client;
@Before
@BeforeEach
public void setUpClient() {
client = new Client();
}

View File

@@ -13,7 +13,7 @@
package org.openhab.binding.fmiweather;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import java.math.BigDecimal;
import java.util.AbstractMap;
@@ -22,7 +22,7 @@ import java.util.List;
import java.util.Map.Entry;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openhab.binding.fmiweather.internal.client.FMISID;
import org.openhab.binding.fmiweather.internal.client.ForecastRequest;
import org.openhab.binding.fmiweather.internal.client.LatLon;

View File

@@ -13,12 +13,13 @@
package org.openhab.binding.fmiweather;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.nio.file.Path;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openhab.binding.fmiweather.internal.client.Client;
import org.openhab.binding.fmiweather.internal.client.FMIResponse;
@@ -33,7 +34,7 @@ public class FMIResponseParsingEmptyTest extends AbstractFMIResponseParsingTest
private FMIResponse observationsResponse;
@Before
@BeforeEach
public void setUp() {
client = new Client();
try {

View File

@@ -13,12 +13,13 @@
package org.openhab.binding.fmiweather;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.fail;
import java.nio.file.Path;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openhab.binding.fmiweather.internal.client.exception.FMIResponseException;
/**

View File

@@ -12,11 +12,12 @@
*/
package org.openhab.binding.fmiweather;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.nio.file.Path;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openhab.binding.fmiweather.internal.client.exception.FMIResponseException;
import org.xml.sax.SAXParseException;
@@ -30,13 +31,15 @@ public class FMIResponseParsingInvalidOrUnexpectedXmlTest extends AbstractFMIRes
private Path observations1 = getTestResource("observations_single_place.xml");
@Test(expected = SAXParseException.class)
public void testInvalidXml() throws IOException, Throwable {
parseMultiPointCoverageXml(readTestResourceUtf8(observations1).replace("276.0", "<<"));
@Test
public void testInvalidXml() {
assertThrows(SAXParseException.class,
() -> parseMultiPointCoverageXml(readTestResourceUtf8(observations1).replace("276.0", "<<")));
}
@Test(expected = FMIResponseException.class)
public void testUnexpectedXml() throws IOException, Throwable {
parseMultiPointCoverageXml(readTestResourceUtf8(observations1).replace("276.0", "<foo>4</foo>"));
@Test
public void testUnexpectedXml() {
assertThrows(FMIResponseException.class,
() -> parseMultiPointCoverageXml(readTestResourceUtf8(observations1).replace("276.0", "<foo>4</foo>")));
}
}

View File

@@ -13,7 +13,7 @@
package org.openhab.binding.fmiweather;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import java.math.BigDecimal;
import java.nio.file.Path;
@@ -21,8 +21,8 @@ import java.util.Optional;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openhab.binding.fmiweather.internal.client.Data;
import org.openhab.binding.fmiweather.internal.client.FMIResponse;
import org.openhab.binding.fmiweather.internal.client.Location;
@@ -60,7 +60,7 @@ public class FMIResponseParsingMultiplePlacesTest extends AbstractFMIResponsePar
private Location pointWithNoName = new Location("19.9,61.0973", "61.09726,19.90000", new BigDecimal("61.09726"),
new BigDecimal("19.90000"));
@Before
@BeforeEach
public void setUp() {
try {
observationsMultiplePlacesResponse = parseMultiPointCoverageXml(

View File

@@ -13,7 +13,8 @@
package org.openhab.binding.fmiweather;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.math.BigDecimal;
import java.nio.file.Path;
@@ -21,8 +22,8 @@ import java.util.Optional;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openhab.binding.fmiweather.internal.client.Data;
import org.openhab.binding.fmiweather.internal.client.FMIResponse;
import org.openhab.binding.fmiweather.internal.client.Location;
@@ -46,7 +47,7 @@ public class FMIResponseParsingSinglePlaceTest extends AbstractFMIResponseParsin
private Location emasalo = new Location("Porvoo Emäsalo", "101023", new BigDecimal("60.20382"),
new BigDecimal("25.62546"));
@Before
@BeforeEach
public void setUp() {
try {
observationsResponse1 = parseMultiPointCoverageXml(readTestResourceUtf8(observations1));

View File

@@ -13,14 +13,15 @@
package org.openhab.binding.fmiweather;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.math.BigDecimal;
import java.nio.file.Path;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openhab.binding.fmiweather.internal.client.Location;
/**