@Test public void shouldReadNullInteger() throws Exception { Channel channel = new Channel( new byte[] {(byte) 0x00, ':'}, 1 ); EventConsumerThread thread = new EventConsumerThread( "t", channel, new MockEventHandler<Event>(), COUNTDOWN_CLOSEABLE, new MockForkNodeArguments() ); Memento memento = thread.new Memento(); memento.bb.position( 0 ).limit( 0 ); assertThat( thread.readInteger( memento ) ) .isNull(); }
protected Integer readInteger( Memento memento ) throws IOException, MalformedFrameException { read( memento, BYTE_LENGTH ); boolean isNullObject = memento.bb.get() == 0; if ( isNullObject ) { read( memento, DELIMITER_LENGTH ); checkDelimiter( memento ); return null; } return readInt( memento ); }
EventConsumerThread extends CloseableDaemonThread { protected Integer readInteger( Memento memento ) throws IOException, MalformedFrameException { read( memento, BYTE_LENGTH ); boolean isNullObject = memento.bb.get() == 0; if ( isNullObject ) { read( memento, DELIMITER_LENGTH ); checkDelimiter( memento ); return null; } return readInt( memento ); } }
EventConsumerThread extends CloseableDaemonThread { protected Integer readInteger( Memento memento ) throws IOException, MalformedFrameException { read( memento, BYTE_LENGTH ); boolean isNullObject = memento.bb.get() == 0; if ( isNullObject ) { read( memento, DELIMITER_LENGTH ); checkDelimiter( memento ); return null; } return readInt( memento ); } EventConsumerThread( @Nonnull String threadName,
                                @Nonnull ReadableByteChannel channel,
                                @Nonnull EventHandler<Event> eventHandler,
                                @Nonnull CountdownCloseable countdownCloseable,
                                @Nonnull ForkNodeArguments arguments ); }
EventConsumerThread extends CloseableDaemonThread { protected Integer readInteger( Memento memento ) throws IOException, MalformedFrameException { read( memento, BYTE_LENGTH ); boolean isNullObject = memento.bb.get() == 0; if ( isNullObject ) { read( memento, DELIMITER_LENGTH ); checkDelimiter( memento ); return null; } return readInt( memento ); } 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 { protected Integer readInteger( Memento memento ) throws IOException, MalformedFrameException { read( memento, BYTE_LENGTH ); boolean isNullObject = memento.bb.get() == 0; if ( isNullObject ) { read( memento, DELIMITER_LENGTH ); checkDelimiter( memento ); return null; } return readInt( memento ); } 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();  }