cvs commit: spice/sandbox/packet/src/test/org/realityforge/packet/protocol MessageConstraint.java ProtocolWriterTestCase.java
Peter Donald <[email protected]> Wed, 12 Nov 2003 03:09:09 -0800
| Newsgroups | gmane.comp.java.spice.cvs |
|---|---|
| Message-ID | <[email protected]> |
donaldp 03/11/12 03:09:09
Added: sandbox/packet/src/test/org/realityforge/packet/protocol
MessageConstraint.java ProtocolWriterTestCase.java
Log:
add in dummy tests
Revision Changes Path
1.1 spice/sandbox/packet/src/test/org/realityforge/packet/protocol/MessageConstraint.java
Index: MessageConstraint.java
===================================================================
/*
* Copyright (C) The Spice Group. All rights reserved.
*
* This software is published under the terms of the Spice
* Software License version 1.1, a copy of which has been included
* with this distribution in the LICENSE.txt file.
*/
package org.realityforge.packet.protocol;
import com.mockobjects.constraint.Constraint;
import java.nio.ByteBuffer;
/**
*
* @author <a href="mailto:peter at realityforge.org">Peter Donald</a>
* @version $Revision: 1.1 $ $Date: 2003/11/12 11:09:09 $
*/
class MessageConstraint
implements Constraint
{
private final byte[] m_data;
MessageConstraint( final byte[] data )
{
m_data = data;
}
public boolean eval( Object o )
{
if( o instanceof ByteBuffer )
{
final ByteBuffer byteBuffer = (ByteBuffer)o;
//byteBuffer.limit()
}
return false;
}
}
1.1 spice/sandbox/packet/src/test/org/realityforge/packet/protocol/ProtocolWriterTestCase.java
Index: ProtocolWriterTestCase.java
===================================================================
/*
* Copyright (C) The Spice Group. All rights reserved.
*
* This software is published under the terms of the Spice
* Software License version 1.1, a copy of which has been included
* with this distribution in the LICENSE.txt file.
*/
package org.realityforge.packet.protocol;
import com.mockobjects.dynamic.C;
import com.mockobjects.dynamic.Mock;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
import java.nio.channels.WritableByteChannel;
import junit.framework.TestCase;
/**
*
* @author <a href="mailto:peter at realityforge.org">Peter Donald</a>
* @version $Revision: 1.1 $ $Date: 2003/11/12 11:09:09 $
*/
public class ProtocolWriterTestCase
extends TestCase
{
public void testForceWriteMessage()
throws Exception
{
final byte[] data = new byte[]{1, 2, 3};
final ByteBuffer message = ByteBuffer.wrap( data );
final Mock channelMock = new Mock( WritableByteChannel.class );
channelMock.matchAndReturn( "forceWriteMessage", C.args( C.eq( message ) ), 3 );
final WritableByteChannel channel =
(WritableByteChannel)channelMock.proxy();
final ProtocolWriter writer = new ProtocolWriter();
writer.forceWriteMessage( message, channel );
channelMock.verify();
}
public void testForceWriteMessageThatOverflows()
throws Exception
{
final byte[] data = new byte[]{1, 2, 3};
final ByteBuffer message = ByteBuffer.wrap( data );
final Mock channelMock = new Mock( WritableByteChannel.class );
channelMock.matchAndReturn( "forceWriteMessage", C.args( C.eq( message ) ), 2 );
final WritableByteChannel channel =
(WritableByteChannel)channelMock.proxy();
final ProtocolWriter writer = new ProtocolWriter();
try
{
writer.forceWriteMessage( message, channel );
fail( "Expected to get a BufferOverflow Exception" );
}
catch( final BufferOverflowException boe )
{
return;
}
channelMock.verify();
}
}
-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/