@@ -714,13 +714,13 @@ public void Test_ReadLine()
714714 * @tests java.io.BufferedReader#ready()
715715 */
716716 [ Test , LuceneNetSpecific ]
717- [ AwaitsFix ( BugUrl = "https://github.com/apache/lucenenet/issues/1102" ) ] // LUCENENET TODO: fix test
718717 public void Test_Ready ( )
719718 {
720719 // Test for method boolean java.io.BufferedReader.ready()
721720 try
722721 {
723- br = new BufferedCharFilter ( new StringReader ( testString ) ) ;
722+ // LUCENENET specific: use TestStringReaderCharFilterAdapter to adapt StringReader to be IsReady-aware.
723+ br = new BufferedCharFilter ( new TestStringReaderCharFilterAdapter ( new StringReader ( testString ) ) ) ;
724724 assertTrue ( "IsReady returned false" , br . IsReady ) ;
725725 }
726726 catch ( Exception e ) when ( e . IsIOException ( ) )
@@ -729,6 +729,30 @@ public void Test_Ready()
729729 }
730730 }
731731
732+ /// <summary>
733+ /// LUCENENET specific class for <see cref="TestBufferedCharFilter.Test_Ready"/> to test that
734+ /// <see cref="BufferedCharFilter.IsReady"/> cascades its call to the underlying
735+ /// <see cref="CharFilter.IsReady"/>. Rationale: IsReady indicates that a call to
736+ /// <see cref="TextReader.Read()"/> is guaranteed not to block. <see cref="StringReader"/> does not block,
737+ /// because there is no I/O. Therefore, if the underlying reader is a <see cref="StringReader"/>, then
738+ /// <see cref="CharFilter.IsReady"/> must return true.
739+ /// </summary>
740+ private class TestStringReaderCharFilterAdapter : CharFilter
741+ {
742+ public TestStringReaderCharFilterAdapter ( StringReader input ) // Enforces the input reader is a StringReader
743+ : base ( input )
744+ {
745+ }
746+
747+ protected override int Correct ( int currentOff )
748+ => throw new NotImplementedException ( ) ;
749+
750+ public override int Read ( char [ ] buffer , int index , int count )
751+ => m_input . Read ( buffer , index , count ) ;
752+
753+ public override bool IsReady => true ; // StringReaders do not block
754+ }
755+
732756 /**
733757 * @tests java.io.BufferedReader#reset()
734758 */
0 commit comments