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.String
effectiveLogPath
private static int
IDX_DATA00_09_00
private static int
IDX_DATA01_09_00
private static int
IDX_DATA02_09_01
private static int
IDX_DATA03_09_02
private static int
IDX_DATA04_09_03
private static int
IDX_DATA05_09_00
private static int
IDX_DATA06_09_01
private static int
IDX_DATA07_09_02
private static int
IDX_DATA08_09_03
java.nio.file.Path
tempDir
private static java.util.List<java.nio.ByteBuffer>
testData
-
Constructor Summary
Constructors Constructor Description SystaRESTAPITest()
-
Method Summary
Modifier and Type Method Description void
after()
void
before()
jakarta.ws.rs.core.Application
configure()
private static void
deleteDirectoryRecursively(java.nio.file.Path path)
private void
feedDataToFakeSystaWeb(java.nio.ByteBuffer dataBuffer)
Feeds the provided ByteBuffer to the FakeSystaWeb instance's processDatagram method.private FakeSystaWeb
getFakeSystaWebInstance()
Retrieves the FakeSystaWeb instance from the SystaRESTAPI using reflection.private static java.lang.String
getIPv4Address(java.lang.String interfaceName)
Helper function to get the IPv4 address for a given interface namestatic void
initializeTestData()
private static void
readHexTextIntoByteBuffer(java.nio.ByteBuffer byteBuffer, java.lang.String hexTextFile)
loads a hexText file into a ByteBuffer.(package private) void
testDeleteAllLogs()
void
testDisablelogging()
void
testEnablelogging()
(package private) void
testEnableLogging_DefaultParameters()
(package private) void
testEnableLogging_EmptyParameters()
(package private) void
testEnableLogging_InvalidParameters()
(package private) void
testFindSystaComfort_ReturnsJson()
(package private) void
testGetAllLogs_NoLogs()
(package private) void
testGetAllLogs_WithLogs()
(package private) void
testGetDashboardHTML()
(package private) void
testGetMonitorRawDataHTML_DefaultTheme()
(package private) void
testGetMonitorRawDataHTML_OtherTheme()
(package private) void
testGetMonitorRawDataHTML_SystaWebTheme()
(package private) void
testGetRawData_ReturnsJson()
(package private) void
testGetStatus_ReturnsJson()
(package private) void
testGetWaterHeater_ReturnsJson()
(package private) void
testInvalidEndpoint()
(package private) void
testLogFileCreation()
void
testStart()
Use reflection to change the hardcoded directory used for the location of log files.void
testStop()
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, tearDown
Methods 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:
configure
in 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.
-