Search in sources :

Example 31 with CalledMethod

use of biz.xsoftware.mock.CalledMethod in project webpieces by deanhiller.

the class TestDatagramChannel method verifyPacket.

/**
     * @param clientAddr
     * @param localHost
     * @param payload
     */
private void verifyPacket(InetSocketAddress clientAddr, InetAddress localHost, String payload) {
    CalledMethod m = svrHandler.expect("incomingData");
    InetSocketAddress remoteAddr = (InetSocketAddress) m.getAllParams()[1];
    ByteBuffer buf1 = (ByteBuffer) m.getAllParams()[2];
    assertEquals(localHost, remoteAddr.getAddress());
    assertEquals(clientAddr.getPort(), remoteAddr.getPort());
    String actual = HELPER.readString(buf1, buf1.remaining());
    //log.info("payload='"+payload+"' act='"+actual+"'");
    assertEquals(payload, actual);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) CloneByteBuffer(org.webpieces.nio.api.testutil.CloneByteBuffer) ByteBuffer(java.nio.ByteBuffer) CalledMethod(biz.xsoftware.mock.CalledMethod)

Aggregations

CalledMethod (biz.xsoftware.mock.CalledMethod)31 ByteBuffer (java.nio.ByteBuffer)27 CloneByteBuffer (org.webpieces.nio.api.testutil.CloneByteBuffer)27 TCPChannel (org.webpieces.nio.api.channels.TCPChannel)8 MockObject (biz.xsoftware.mock.MockObject)5 InetSocketAddress (java.net.InetSocketAddress)4 FutureOperation (org.webpieces.nio.api.handlers.FutureOperation)4 SelectionKey (java.nio.channels.SelectionKey)3 HashSet (java.util.HashSet)3 DataListener (org.webpieces.nio.api.handlers.DataListener)2 PerfTimer (org.webpieces.nio.test.PerfTimer)2 InetAddress (java.net.InetAddress)1 PortUnreachableException (java.net.PortUnreachableException)1 HashMap (java.util.HashMap)1 ChannelServiceFactory (org.webpieces.nio.api.deprecated.ChannelServiceFactory)1 OperationCallback (org.webpieces.nio.api.handlers.OperationCallback)1 FactoryCreator (org.webpieces.nio.api.libs.FactoryCreator)1 SocketChannel (org.webpieces.nio.api.testutil.chanapi.SocketChannel)1 ChannelRegistrationListener (org.webpieces.nio.api.testutil.nioapi.ChannelRegistrationListener)1 Select (org.webpieces.nio.api.testutil.nioapi.Select)1