@@ -24,6 +24,9 @@ public static void main(String[] args) {
2424 testInitValExtractsSimtime ();
2525 testInitValReturnsRemainingValues ();
2626 testOutputFileMatchesPythonWireFormat ();
27+ testReadFileNotFound ();
28+ testReadRetriesExceeded ();
29+ testReadParseError ();
2730
2831 System .out .println ("\n === Results: " + passed + " passed, " + failed + " failed out of " + (passed + failed ) + " tests ===" );
2932 if (failed > 0 ) {
@@ -102,10 +105,11 @@ static void testReadParsesFileAndStripsSimtime() {
102105 concoredocker .setInPath (tmp .toString ());
103106 writeFile (tmp , 1 , "sensor" , "[0.0, 42.0, 99.0]" );
104107
105- List <Object > result = concoredocker .read (1 , "sensor" , "[0.0, 0.0, 0.0]" );
106- check ("read: strips simtime, size=2" , 2 , result .size ());
107- check ("read: val1 correct" , 42.0 , result .get (0 ));
108- check ("read: val2 correct" , 99.0 , result .get (1 ));
108+ concoredocker .ReadResult result = concoredocker .read (1 , "sensor" , "[0.0, 0.0, 0.0]" );
109+ check ("read: status SUCCESS" , concoredocker .ReadStatus .SUCCESS , result .status );
110+ check ("read: strips simtime, size=2" , 2 , result .data .size ());
111+ check ("read: val1 correct" , 42.0 , result .data .get (0 ));
112+ check ("read: val2 correct" , 99.0 , result .data .get (1 ));
109113 }
110114
111115 static void testReadWriteRoundtrip () {
@@ -119,10 +123,11 @@ static void testReadWriteRoundtrip() {
119123 outVals .add (8.0 );
120124 concoredocker .write (1 , "data" , outVals , 1 );
121125
122- List <Object > inVals = concoredocker .read (1 , "data" , "[0.0, 0.0, 0.0]" );
123- check ("roundtrip: size" , 2 , inVals .size ());
124- check ("roundtrip: val1" , 7.0 , inVals .get (0 ));
125- check ("roundtrip: val2" , 8.0 , inVals .get (1 ));
126+ concoredocker .ReadResult inVals = concoredocker .read (1 , "data" , "[0.0, 0.0, 0.0]" );
127+ check ("roundtrip: status" , concoredocker .ReadStatus .SUCCESS , inVals .status );
128+ check ("roundtrip: size" , 2 , inVals .data .size ());
129+ check ("roundtrip: val1" , 7.0 , inVals .data .get (0 ));
130+ check ("roundtrip: val2" , 8.0 , inVals .data .get (1 ));
126131 }
127132
128133 static void testSimtimeAdvancesWithDelta () {
@@ -195,4 +200,34 @@ static void testOutputFileMatchesPythonWireFormat() {
195200 Object reparsed = concoredocker .literalEval (raw );
196201 check ("wire format: re-parseable as list" , true , reparsed instanceof List );
197202 }
203+
204+ static void testReadFileNotFound () {
205+ Path tmp = makeTempDir ();
206+ concoredocker .resetState ();
207+ concoredocker .setInPath (tmp .toString ());
208+ // no file written, port 1/missing does not exist
209+ concoredocker .ReadResult result = concoredocker .read (1 , "missing" , "[0.0, 0.0]" );
210+ check ("read file not found: status" , concoredocker .ReadStatus .FILE_NOT_FOUND , result .status );
211+ check ("read file not found: data is default" , 1 , result .data .size ());
212+ }
213+
214+ static void testReadRetriesExceeded () {
215+ Path tmp = makeTempDir ();
216+ concoredocker .resetState ();
217+ concoredocker .setInPath (tmp .toString ());
218+ writeFile (tmp , 1 , "empty" , "" ); // always empty, exhausts retries
219+ concoredocker .ReadResult result = concoredocker .read (1 , "empty" , "[0.0, 0.0]" );
220+ check ("read retries exceeded: status" , concoredocker .ReadStatus .RETRIES_EXCEEDED , result .status );
221+ check ("read retries exceeded: data is default" , 1 , result .data .size ());
222+ }
223+
224+ static void testReadParseError () {
225+ Path tmp = makeTempDir ();
226+ concoredocker .resetState ();
227+ concoredocker .setInPath (tmp .toString ());
228+ writeFile (tmp , 1 , "bad" , "not_a_valid_list" );
229+ concoredocker .ReadResult result = concoredocker .read (1 , "bad" , "[0.0, 0.0]" );
230+ check ("read parse error: status" , concoredocker .ReadStatus .PARSE_ERROR , result .status );
231+ check ("read parse error: data is default" , 1 , result .data .size ());
232+ }
198233}
0 commit comments