Package de.freaklamarsch.systarest.tests
Class SystaRESTAPITest
java.lang.Object
org.glassfish.jersey.test.JerseyTest
de.freaklamarsch.systarest.tests.SystaRESTAPITest
@TestInstance(PER_CLASS)
class SystaRESTAPITest
extends org.glassfish.jersey.test.JerseyTest
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringeffectiveLogPathprivate static intIDX_DATA00_09_00private static intIDX_DATA01_09_00private static intIDX_DATA02_09_01private static intIDX_DATA03_09_02private static intIDX_DATA04_09_03private static intIDX_DATA05_09_00private static intIDX_DATA06_09_01private static intIDX_DATA07_09_02private static intIDX_DATA08_09_03java.nio.file.PathtempDirprivate static java.util.List<java.nio.ByteBuffer>testData -
Constructor Summary
Constructors Constructor Description SystaRESTAPITest() -
Method Summary
Modifier and Type Method Description voidafter()voidbefore()jakarta.ws.rs.core.Applicationconfigure()private static voiddeleteDirectoryRecursively(java.nio.file.Path path)private voidfeedDataToFakeSystaWeb(java.nio.ByteBuffer dataBuffer)Feeds the provided ByteBuffer to the FakeSystaWeb instance's processDatagram method.private FakeSystaWebgetFakeSystaWebInstance()Retrieves the FakeSystaWeb instance from the SystaRESTAPI using reflection.private static java.lang.StringgetIPv4Address(java.lang.String interfaceName)Helper function to get the IPv4 address for a given interface namestatic voidinitializeTestData()private static voidreadHexTextIntoByteBuffer(java.nio.ByteBuffer byteBuffer, java.lang.String hexTextFile)loads a hexText file into a ByteBuffer.(package private) voidtestDeleteAllLogs()voidtestDisablelogging()voidtestEnablelogging()(package private) voidtestEnableLogging_DefaultParameters()(package private) voidtestEnableLogging_EmptyParameters()(package private) voidtestEnableLogging_InvalidParameters()(package private) voidtestFindSystaComfort_ReturnsJson()(package private) voidtestGetAllLogs_NoLogs()(package private) voidtestGetAllLogs_WithLogs()(package private) voidtestGetDashboardHTML()(package private) voidtestGetMonitorRawDataHTML_DefaultTheme()(package private) voidtestGetMonitorRawDataHTML_OtherTheme()(package private) voidtestGetMonitorRawDataHTML_SystaWebTheme()(package private) voidtestGetRawData_ReturnsJson()(package private) voidtestGetStatus_ReturnsJson()(package private) voidtestGetWaterHeater_ReturnsJson()(package private) voidtestInvalidEndpoint()(package private) voidtestLogFileCreation()voidtestStart()Use reflection to change the hardcoded directory used for the location of log files.voidtestStop()Methods inherited from class org.glassfish.jersey.test.JerseyTest
client, close, closeIfNotNull, configureClient, configureDeployment, disable, enable, forceDisable, forceEnable, forceSet, getAsyncTimeoutMultiplier, getBaseUri, getClient, getLastLoggedRecord, getLoggedRecords, getPort, getSslContext, getSslParameters, getTestContainerFactory, isEnabled, set, set, setClient, setUp, target, target, tearDownMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
testData
private static final java.util.List<java.nio.ByteBuffer> testData -
IDX_DATA00_09_00
private static final int IDX_DATA00_09_00- See Also:
- Constant Field Values
-
IDX_DATA01_09_00
private static final int IDX_DATA01_09_00- See Also:
- Constant Field Values
-
IDX_DATA02_09_01
private static final int IDX_DATA02_09_01- See Also:
- Constant Field Values
-
IDX_DATA03_09_02
private static final int IDX_DATA03_09_02- See Also:
- Constant Field Values
-
IDX_DATA04_09_03
private static final int IDX_DATA04_09_03- See Also:
- Constant Field Values
-
IDX_DATA05_09_00
private static final int IDX_DATA05_09_00- See Also:
- Constant Field Values
-
IDX_DATA06_09_01
private static final int IDX_DATA06_09_01- See Also:
- Constant Field Values
-
IDX_DATA07_09_02
private static final int IDX_DATA07_09_02- See Also:
- Constant Field Values
-
IDX_DATA08_09_03
private static final int IDX_DATA08_09_03- See Also:
- Constant Field Values
-
tempDir
@TempDir public java.nio.file.Path tempDir -
effectiveLogPath
private java.lang.String effectiveLogPath
-
-
Constructor Details
-
SystaRESTAPITest
SystaRESTAPITest()
-
-
Method Details
-
initializeTestData
@BeforeAll public static void initializeTestData() -
before
@BeforeAll public void before() throws java.lang.Exception- Throws:
java.lang.Exception
-
after
@AfterAll public void after() throws java.lang.Exception- Throws:
java.lang.Exception
-
deleteDirectoryRecursively
private static void deleteDirectoryRecursively(java.nio.file.Path path) throws java.io.IOException- Throws:
java.io.IOException
-
configure
public jakarta.ws.rs.core.Application configure()- Overrides:
configurein classorg.glassfish.jersey.test.JerseyTest
-
testInvalidEndpoint
@Test void testInvalidEndpoint() -
testStart
@Test public void testStart()Use reflection to change the hardcoded directory used for the location of log files. As DEFAULT_ROOT_PATH is static final in DataLogger, it is officially a security risk to change this value. This function might not work with future Java versions. -
testStop
@Test public void testStop() -
testEnablelogging
@Test public void testEnablelogging() -
testLogFileCreation
@Test void testLogFileCreation() -
testDisablelogging
@Test public void testDisablelogging() -
testEnableLogging_DefaultParameters
@Test void testEnableLogging_DefaultParameters() -
testEnableLogging_InvalidParameters
@Test void testEnableLogging_InvalidParameters() -
testEnableLogging_EmptyParameters
@Test void testEnableLogging_EmptyParameters() -
getIPv4Address
private static java.lang.String getIPv4Address(java.lang.String interfaceName)Helper function to get the IPv4 address for a given interface name- Parameters:
interfaceName-- Returns:
- the configured IPv4 address as
String, e.g. "127.0.0.1", or null if no configured IPv4 address was found
-
testGetAllLogs_NoLogs
@Test void testGetAllLogs_NoLogs() throws java.io.IOException- Throws:
java.io.IOException
-
testGetAllLogs_WithLogs
@Test void testGetAllLogs_WithLogs() throws java.io.IOException- Throws:
java.io.IOException
-
testDeleteAllLogs
@Test void testDeleteAllLogs() throws java.io.IOException- Throws:
java.io.IOException
-
testGetRawData_ReturnsJson
@Test void testGetRawData_ReturnsJson() -
testGetWaterHeater_ReturnsJson
@Test void testGetWaterHeater_ReturnsJson() -
testGetStatus_ReturnsJson
@Test void testGetStatus_ReturnsJson() -
testFindSystaComfort_ReturnsJson
@Test void testFindSystaComfort_ReturnsJson() -
testGetMonitorRawDataHTML_DefaultTheme
@Test void testGetMonitorRawDataHTML_DefaultTheme() -
testGetMonitorRawDataHTML_SystaWebTheme
@Test void testGetMonitorRawDataHTML_SystaWebTheme() -
testGetMonitorRawDataHTML_OtherTheme
@Test void testGetMonitorRawDataHTML_OtherTheme() -
testGetDashboardHTML
@Test void testGetDashboardHTML() -
readHexTextIntoByteBuffer
private static void readHexTextIntoByteBuffer(java.nio.ByteBuffer byteBuffer, java.lang.String hexTextFile)loads a hexText file into a ByteBuffer. A hexText file is a file, that has the Hex Stream of a captured packet as a single line. The size of the ByteBuffer has to match the Hex Stream in the file. No checks are done.- Parameters:
byteBuffer- the buffer in which the bytes from the hexText file should be storedhexTextFile- path to the hexText file
-
getFakeSystaWebInstance
Retrieves the FakeSystaWeb instance from the SystaRESTAPI using reflection.- Returns:
- The FakeSystaWeb instance.
-
feedDataToFakeSystaWeb
private void feedDataToFakeSystaWeb(java.nio.ByteBuffer dataBuffer)Feeds the provided ByteBuffer to the FakeSystaWeb instance's processDatagram method.- Parameters:
dataBuffer- The ByteBuffer containing the data to be fed.
-