[teleinfo] Try to make tests more stable (#9303)

Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
This commit is contained in:
Fabian Wolter 2020-12-13 16:26:12 +01:00 committed by GitHub
parent b5e13041dd
commit b8721aa7b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,11 +36,12 @@ import org.openhab.binding.teleinfo.util.TestUtils;
*/ */
@NonNullByDefault @NonNullByDefault
public class TeleinfoInputStreamTest { public class TeleinfoInputStreamTest {
private static final int TIMEOUT_US = 5000000;
@Test @Test
public void testReadNextFrameCbetmBase1() throws Exception { public void testReadNextFrameCbetmBase1() throws Exception {
try (TeleinfoInputStream in = new TeleinfoInputStream( try (TeleinfoInputStream in = new TeleinfoInputStream(
new FileInputStream(TestUtils.getTestFile("cbetm-base-option-1.raw")))) { new FileInputStream(TestUtils.getTestFile("cbetm-base-option-1.raw")), TIMEOUT_US, TIMEOUT_US, false)) {
Frame frame = in.readNextFrame(); Frame frame = in.readNextFrame();
assertNotNull(frame); assertNotNull(frame);
@ -65,7 +66,8 @@ public class TeleinfoInputStreamTest {
@Test @Test
public void testReadNextFrameCbemmEvoIccHc1() throws Exception { public void testReadNextFrameCbemmEvoIccHc1() throws Exception {
try (TeleinfoInputStream in = new TeleinfoInputStream( try (TeleinfoInputStream in = new TeleinfoInputStream(
new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-hc-option-1.raw")))) { new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-hc-option-1.raw")), TIMEOUT_US, TIMEOUT_US,
false)) {
Frame frame = in.readNextFrame(); Frame frame = in.readNextFrame();
assertNotNull(frame); assertNotNull(frame);
@ -87,7 +89,7 @@ public class TeleinfoInputStreamTest {
@Test @Test
public void testReadNextFrameCbetmEjp1() throws Exception { public void testReadNextFrameCbetmEjp1() throws Exception {
try (TeleinfoInputStream in = new TeleinfoInputStream( try (TeleinfoInputStream in = new TeleinfoInputStream(
new FileInputStream(TestUtils.getTestFile("cbetm-ejp-option-1.raw")))) { new FileInputStream(TestUtils.getTestFile("cbetm-ejp-option-1.raw")), TIMEOUT_US, TIMEOUT_US, false)) {
Frame frame = in.readNextFrame(); Frame frame = in.readNextFrame();
assertNotNull(frame); assertNotNull(frame);
@ -114,7 +116,8 @@ public class TeleinfoInputStreamTest {
@Test @Test
public void testReadNextFrameCbemmEvoIccTempo1() throws Exception { public void testReadNextFrameCbemmEvoIccTempo1() throws Exception {
try (TeleinfoInputStream in = new TeleinfoInputStream( try (TeleinfoInputStream in = new TeleinfoInputStream(
new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-tempo-option-1.raw")))) { new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-tempo-option-1.raw")), TIMEOUT_US, TIMEOUT_US,
false)) {
Frame frame = in.readNextFrame(); Frame frame = in.readNextFrame();
assertNotNull(frame); assertNotNull(frame);
@ -143,7 +146,8 @@ public class TeleinfoInputStreamTest {
@Test @Test
public void testReadNextFrameCbemmEvoIccBase1() throws Exception { public void testReadNextFrameCbemmEvoIccBase1() throws Exception {
try (TeleinfoInputStream in = new TeleinfoInputStream( try (TeleinfoInputStream in = new TeleinfoInputStream(
new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-base-option-1.raw")))) { new FileInputStream(TestUtils.getTestFile("cbemm-evo-icc-base-option-1.raw")), TIMEOUT_US, TIMEOUT_US,
false)) {
Frame frame = in.readNextFrame(); Frame frame = in.readNextFrame();
assertNotNull(frame); assertNotNull(frame);
assertEquals(FrameCbemmEvolutionIccBaseOption.class, frame.getClass()); assertEquals(FrameCbemmEvolutionIccBaseOption.class, frame.getClass());
@ -162,7 +166,8 @@ public class TeleinfoInputStreamTest {
@Test @Test
public void testInvalidADPSgrouplineWithAutoRepairActivated() throws Exception { public void testInvalidADPSgrouplineWithAutoRepairActivated() throws Exception {
try (TeleinfoInputStream in = new TeleinfoInputStream( try (TeleinfoInputStream in = new TeleinfoInputStream(
new FileInputStream(TestUtils.getTestFile("invalid-adps-groupline.raw")), true)) { new FileInputStream(TestUtils.getTestFile("invalid-adps-groupline.raw")), TIMEOUT_US, TIMEOUT_US,
true)) {
Frame frame = in.readNextFrame(); Frame frame = in.readNextFrame();
assertNotNull(frame); assertNotNull(frame);