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[]dataprivate FakeSystaWebfswprivate java.lang.reflect.FieldintDataprivate static java.lang.StringlogDirprivate java.io.FilenameFilterlogfileFilterprivate java.lang.StringlogFileFilterStringprivate java.lang.reflect.FieldlogFileFilterStringFieldprivate DataLogger<java.lang.Integer>logIntprivate CircularBuffer<java.lang.Integer>logIntDataBufferprivate java.lang.reflect.FieldlogIntDataBufferFieldprivate DataLogger<java.lang.Byte>logRawprivate java.lang.reflect.FieldreadIndexprivate java.lang.reflect.FieldRING_BUFFER_SIZEprivate java.net.DatagramSocketsocketprivate java.lang.reflect.FieldsocketFieldprivate java.lang.reflect.Fieldtimestampprivate java.lang.reflect.FieldwriteIndex -
Constructor Summary
Constructors Constructor Description FakeSystaWebTest() -
Method Summary
Modifier and Type Method Description private voidchangeDefaultLogDir(java.lang.String newDir)Use reflection to change the hardcoded directory used for the location of log files.(package private) voidfindSC()private booleaninitialize()initialize components for access via reflectionprivate voidinitializeData()private java.lang.reflect.MethodprepareInvokeMethod(java.lang.String methodName, java.lang.Class<?>... parameters)private voidreadHexTextIntoByteBuffer(java.nio.ByteBuffer byteBuffer, java.lang.String hexTextFile)loads a hexText file into a ByteBuffer.(package private) voidtestGetAllLogs()(package private) voidtestProcessDatagram()(package private) voidtestProcessDataType1()private booleanupdateWriteIndexAndTimestamp(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.NoSuchFieldExceptionjava.lang.SecurityExceptionjava.lang.IllegalArgumentExceptionjava.lang.IllegalAccessExceptionjava.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.NoSuchFieldExceptionjava.lang.SecurityExceptionjava.lang.IllegalArgumentExceptionjava.lang.IllegalAccessExceptionjava.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
-