Skip to content

Commit

Permalink
TEST: Fix java.net.spy.memcached.protocol.ascii.BaseOpTest to ensur…
Browse files Browse the repository at this point in the history
…e it tests correctly.
  • Loading branch information
uhm0311 committed Aug 12, 2024
1 parent e4bc524 commit d1c9870
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions src/test/java/net/spy/memcached/protocol/ascii/BaseOpTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,44 +27,31 @@

import net.spy.memcached.compat.BaseMockCase;

import static org.junit.Assert.assertThrows;

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

public void testAssertions() {
try {
assert false;
fail("Assertions are not enabled.");
} catch (AssertionError e) {
// OK
}
assertThrows(AssertionError.class, () -> { assert false; });
}

public void testDataReadType() throws Exception {
public void testDataReadType() {
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");
} catch (AssertionError e) {
// ok
}
assertThrows(AssertionError.class, () -> op.handleLine("x"));
op.setBytesToRead(2);
op.handleRead(ByteBuffer.wrap("hi".getBytes()));
}

public void testLineReadType() throws Exception {
public void testLineReadType() {
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");
} catch (AssertionError e) {
// ok
}
assertThrows(AssertionError.class, () -> op.handleRead(ByteBuffer.allocate(3)));
op.handleLine("x");
}

Expand Down

0 comments on commit d1c9870

Please sign in to comment.