Skip to content

Commit

Permalink
TEST: Fix net.spy.memcached.protocol.ascii.BaseOpTest to ensure it …
Browse files Browse the repository at this point in the history
…tests correctly.
  • Loading branch information
uhm0311 committed Aug 12, 2024
1 parent 90f3379 commit 6215240
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/test/java/net/spy/memcached/protocol/ascii/BaseOpTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,48 @@

import net.spy.memcached.compat.BaseMockCase;

import static org.junit.Assert.assertNotEquals;

/**
* Test the basic operation buffer handling stuff.
*/
public class BaseOpTest extends BaseMockCase {

public void testAssertions() {
String message = "Assertions are not enabled.";
try {
assert false;
fail("Assertions are not enabled.");
fail(message);
} catch (AssertionError e) {
// OK
assertNotEquals(e.getMessage(), message);
}
}

public void testDataReadType() throws Exception {
public void testDataReadType() {
String message = "Handled a line in data mode";
SimpleOp op = new SimpleOp(OperationReadType.DATA);
assertSame(OperationReadType.DATA, op.getReadType());
// Make sure lines aren't handled
try {
op.handleLine("x");
fail("Handled a line in data mode");
fail(message);
} catch (AssertionError e) {
// ok
assertNotEquals(e.getMessage(), message);
}
op.setBytesToRead(2);
op.handleRead(ByteBuffer.wrap("hi".getBytes()));
}

public void testLineReadType() throws Exception {
public void testLineReadType() {
String message = "Handled data in line mode";
SimpleOp op = new SimpleOp(OperationReadType.LINE);
assertSame(OperationReadType.LINE, op.getReadType());
// Make sure lines aren't handled
try {
op.handleRead(ByteBuffer.allocate(3));
fail("Handled data in line mode");
fail(message);
} catch (AssertionError e) {
// ok
assertNotEquals(e.getMessage(), message);
}
op.handleLine("x");
}
Expand Down

0 comments on commit 6215240

Please sign in to comment.