@Test public void shouldDecodeHappyCase() throws Exception { CharsetDecoder decoder = UTF_8.newDecoder() .onMalformedInput( REPLACE ) .onUnmappableCharacter( REPLACE ); ByteBuffer input = ByteBuffer.allocate( 1024 ); input.put( PATTERN2_BYTES ) .flip(); int bytesToDecode = PATTERN2_BYTES.length; CharBuffer output = CharBuffer.allocate( 1024 ); int readBytes = invokeMethod( EventConsumerThread.class, "decodeString", decoder, input, output, bytesToDecode, true, 0 ); assertThat( readBytes ) .isEqualTo( bytesToDecode ); assertThat( output.flip().toString() ) .isEqualTo( PATTERN2 ); }
private static String toString( List<String> strings ) { if ( strings.size() == 1 ) { return strings.get( 0 ); } StringBuilder concatenated = new StringBuilder( strings.size() * BUFFER_SIZE ); for ( String s : strings ) { concatenated.append( s ); } return concatenated.toString(); }
EventConsumerThread extends CloseableDaemonThread { private static String toString( List<String> strings ) { if ( strings.size() == 1 ) { return strings.get( 0 ); } StringBuilder concatenated = new StringBuilder( strings.size() * BUFFER_SIZE ); for ( String s : strings ) { concatenated.append( s ); } return concatenated.toString(); } }
EventConsumerThread extends CloseableDaemonThread { private static String toString( List<String> strings ) { if ( strings.size() == 1 ) { return strings.get( 0 ); } StringBuilder concatenated = new StringBuilder( strings.size() * BUFFER_SIZE ); for ( String s : strings ) { concatenated.append( s ); } return concatenated.toString(); } EventConsumerThread( @Nonnull String threadName,
                                @Nonnull ReadableByteChannel channel,
                                @Nonnull EventHandler<Event> eventHandler,
                                @Nonnull CountdownCloseable countdownCloseable,
                                @Nonnull ForkNodeArguments arguments ); }
EventConsumerThread extends CloseableDaemonThread { private static String toString( List<String> strings ) { if ( strings.size() == 1 ) { return strings.get( 0 ); } StringBuilder concatenated = new StringBuilder( strings.size() * BUFFER_SIZE ); for ( String s : strings ) { concatenated.append( s ); } return concatenated.toString(); } EventConsumerThread( @Nonnull String threadName,
                                @Nonnull ReadableByteChannel channel,
                                @Nonnull EventHandler<Event> eventHandler,
                                @Nonnull CountdownCloseable countdownCloseable,
                                @Nonnull ForkNodeArguments arguments ); @Override void run(); @Override void disable(); @Override void close(); }
EventConsumerThread extends CloseableDaemonThread { private static String toString( List<String> strings ) { if ( strings.size() == 1 ) { return strings.get( 0 ); } StringBuilder concatenated = new StringBuilder( strings.size() * BUFFER_SIZE ); for ( String s : strings ) { concatenated.append( s ); } return concatenated.toString(); } EventConsumerThread( @Nonnull String threadName,
                                @Nonnull ReadableByteChannel channel,
                                @Nonnull EventHandler<Event> eventHandler,
                                @Nonnull CountdownCloseable countdownCloseable,
                                @Nonnull ForkNodeArguments arguments ); @Override void run(); @Override void disable(); @Override void close();  }