-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17dcd5f
commit d5a0bc1
Showing
5 changed files
with
110 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
ethereumj-core/src/test/java/org/ethereum/net/NettyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.ethereum.net; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import io.netty.buffer.Unpooled; | ||
import io.netty.channel.Channel; | ||
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.channel.embedded.EmbeddedChannel; | ||
import io.netty.handler.codec.ByteToMessageDecoder; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by Anton Nashatyrev on 16.10.2015. | ||
*/ | ||
@Ignore | ||
public class NettyTest { | ||
@Test | ||
public void pipelineTest() { | ||
|
||
ByteToMessageDecoder decoder1 = new ByteToMessageDecoder() { | ||
@Override | ||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { | ||
int i = in.readInt(); | ||
System.out.println("decoder1 read int (4 bytes). Needs no more: " + Integer.toHexString(i)); | ||
ctx.pipeline().remove(this); | ||
} | ||
}; | ||
|
||
ByteToMessageDecoder decoder2 = new ByteToMessageDecoder() { | ||
@Override | ||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { | ||
int i = in.readInt(); | ||
System.out.println("decoder2 read int (4 bytes): " + Integer.toHexString(i)); | ||
} | ||
}; | ||
|
||
EmbeddedChannel channel = new EmbeddedChannel(decoder1, decoder2); | ||
ByteBuf buffer = Unpooled.buffer(); | ||
buffer.writeInt(0x12345678); | ||
buffer.writeInt(0xabcdefff); | ||
channel.writeInbound(buffer); | ||
|
||
} | ||
|
||
} |