1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-08 12:01:09 +01:00

[sinttest] Add UnconnectedConnectionSource for low-level tests

Previously low-level tests where run, potentially multiple times, with
the default connection descriptor.

Reported-by: Guus der Kinderen <guus@goodbytes.nl>
This commit is contained in:
Florian Schmaus 2023-02-09 20:36:25 +01:00
parent 92f1fe647b
commit c5bb15c631
5 changed files with 180 additions and 102 deletions

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2019-2020 Florian Schmaus
* Copyright 2019-2023 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,14 +16,16 @@
*/
package org.igniterealtime.smack.inttest;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import java.lang.reflect.Method;
import java.util.List;
import org.jivesoftware.smack.AbstractXMPPConnection;
import org.igniterealtime.smack.inttest.SmackIntegrationTestFramework.TestMethodParameterType;
import org.junit.jupiter.api.Test;
public class SmackIntegrationTestFrameWorkTest {
@ -69,28 +71,42 @@ public class SmackIntegrationTestFrameWorkTest {
@Test
public void testValidLowLevelList() {
Method testMethod = getTestMethod(ValidLowLevelList.class);
assertTrue(SmackIntegrationTestFramework.testMethodParametersIsListOfConnections(testMethod,
AbstractXMPPConnection.class));
TestMethodParameterType determinedParameterType = SmackIntegrationTestFramework.determineTestMethodParameterType(testMethod, AbstractXMPPConnection.class);
assertEquals(TestMethodParameterType.collectionOfConnections, determinedParameterType);
}
@Test
public void testInvalidLowLevelList() {
Method testMethod = getTestMethod(InvalidLowLevelList.class);
assertFalse(SmackIntegrationTestFramework.testMethodParametersIsListOfConnections(testMethod,
AbstractXMPPConnection.class));
TestMethodParameterType determinedParameterType = SmackIntegrationTestFramework.determineTestMethodParameterType(testMethod, AbstractXMPPConnection.class);
assertNull(determinedParameterType);
}
@Test
public void testValidLowLevelVarargs() {
Method testMethod = getTestMethod(ValidLowLevelVarargs.class);
assertTrue(SmackIntegrationTestFramework.testMethodParametersVarargsConnections(testMethod,
AbstractXMPPConnection.class));
TestMethodParameterType determinedParameterType = SmackIntegrationTestFramework.determineTestMethodParameterType(testMethod, AbstractXMPPConnection.class);
assertEquals(TestMethodParameterType.parameterListOfConnections, determinedParameterType);
}
@Test
public void testInvalidLowLevelVargs() {
Method testMethod = getTestMethod(InvalidLowLevelVarargs.class);
assertFalse(SmackIntegrationTestFramework.testMethodParametersVarargsConnections(testMethod,
AbstractXMPPConnection.class));
TestMethodParameterType determinedParameterType = SmackIntegrationTestFramework.determineTestMethodParameterType(testMethod, AbstractXMPPConnection.class);
assertNull(determinedParameterType);
}
private static class ValidUnconnectedConnectionSource {
@SuppressWarnings("unused")
public void test(AbstractSmackLowLevelIntegrationTest.UnconnectedConnectionSource source) {
}
}
@Test
public void testValidUnconnectedConnectionSource() {
Method testMethod = getTestMethod(ValidUnconnectedConnectionSource.class);
TestMethodParameterType determinedParameterType = SmackIntegrationTestFramework.determineTestMethodParameterType(testMethod, AbstractXMPPConnection.class);
assertEquals(TestMethodParameterType.unconnectedConnectionSource, determinedParameterType);
}
}