Package de.freaklamarsch.systarest.tests
Class FakeSystaWebTest
java.lang.Object
de.freaklamarsch.systarest.tests.FakeSystaWebTest
class FakeSystaWebTest
extends java.lang.Object
-
Field Summary
Fields Modifier and Type Field Description (package private) java.nio.ByteBuffer[]
data
private FakeSystaWeb
fsw
private java.lang.reflect.Field
intData
private static java.lang.String
logDir
private java.io.FilenameFilter
logfileFilter
private java.lang.String
logFileFilterString
private java.lang.reflect.Field
logFileFilterStringField
private DataLogger<java.lang.Integer>
logInt
private CircularBuffer<java.lang.Integer>
logIntDataBuffer
private java.lang.reflect.Field
logIntDataBufferField
private DataLogger<java.lang.Byte>
logRaw
private java.lang.reflect.Field
readIndex
private java.lang.reflect.Field
RING_BUFFER_SIZE
private java.net.DatagramSocket
socket
private java.lang.reflect.Field
socketField
private java.lang.reflect.Field
timestamp
private java.lang.reflect.Field
writeIndex
-
Constructor Summary
Constructors Constructor Description FakeSystaWebTest()
-
Method Summary
Modifier and Type Method Description private void
changeDefaultLogDir(java.lang.String newDir)
Use reflection to change the hardcoded directory used for the location of log files.(package private) void
findSC()
private boolean
initialize()
initialize components for access via reflectionprivate void
initializeData()
private java.lang.reflect.Method
prepareInvokeMethod(java.lang.String methodName, java.lang.Class<?>... parameters)
private void
readHexTextIntoByteBuffer(java.nio.ByteBuffer byteBuffer, java.lang.String hexTextFile)
loads a hexText file into a ByteBuffer.(package private) void
testGetAllLogs()
(package private) void
testProcessDatagram()
(package private) void
testProcessDataType1()
private boolean
updateWriteIndexAndTimestamp(FakeSystaWeb fsw)
update the writeIndex and timestamp as it is done inside the FakeSystaWeb run methodMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
data
java.nio.ByteBuffer[] data -
logDir
private static final java.lang.String logDir- See Also:
- Constant Field Values
-
logfileFilter
private java.io.FilenameFilter logfileFilter -
logFileFilterStringField
private java.lang.reflect.Field logFileFilterStringField -
logFileFilterString
private java.lang.String logFileFilterString -
fsw
-
RING_BUFFER_SIZE
private java.lang.reflect.Field RING_BUFFER_SIZE -
readIndex
private java.lang.reflect.Field readIndex -
writeIndex
private java.lang.reflect.Field writeIndex -
timestamp
private java.lang.reflect.Field timestamp -
socketField
private java.lang.reflect.Field socketField -
socket
private java.net.DatagramSocket socket -
intData
private java.lang.reflect.Field intData -
logInt
-
logIntDataBufferField
private java.lang.reflect.Field logIntDataBufferField -
logIntDataBuffer
-
logRaw
-
-
Constructor Details
-
FakeSystaWebTest
FakeSystaWebTest() throws java.lang.NoSuchFieldException, java.lang.SecurityException, java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.NoSuchMethodException- Throws:
java.lang.NoSuchFieldException
java.lang.SecurityException
java.lang.IllegalArgumentException
java.lang.IllegalAccessException
java.lang.NoSuchMethodException
-
-
Method Details
-
initialize
private boolean initialize()initialize components for access via reflection -
findSC
@Test void findSC() -
testProcessDataType1
@Test void testProcessDataType1() -
testProcessDatagram
@Test void testProcessDatagram() -
testGetAllLogs
@Test void testGetAllLogs() -
prepareInvokeMethod
private java.lang.reflect.Method prepareInvokeMethod(java.lang.String methodName, java.lang.Class<?>... parameters) throws java.lang.NoSuchFieldException, java.lang.SecurityException, java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.NoSuchMethodException- Parameters:
methodName
- the name of the method, that should be retrieved from FakeSystaWeb- Returns:
- Method processDatagram from fsw
- Throws:
java.lang.NoSuchFieldException
java.lang.SecurityException
java.lang.IllegalArgumentException
java.lang.IllegalAccessException
java.lang.NoSuchMethodException
-
updateWriteIndexAndTimestamp
update the writeIndex and timestamp as it is done inside the FakeSystaWeb run method- Parameters:
fsw
-- Returns:
- true if everything worked fine, false if an error occurred
-
changeDefaultLogDir
private void changeDefaultLogDir(java.lang.String newDir)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. -
initializeData
private void initializeData() -
readHexTextIntoByteBuffer
private 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
-