From 62152407a0d3836a014aebef3ede619547768545 Mon Sep 17 00:00:00 2001 From: uhm0311 Date: Mon, 12 Aug 2024 16:26:01 +0900 Subject: [PATCH] TEST: Fix `net.spy.memcached.protocol.ascii.BaseOpTest` to ensure it tests correctly. --- .../memcached/protocol/ascii/BaseOpTest.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/test/java/net/spy/memcached/protocol/ascii/BaseOpTest.java b/src/test/java/net/spy/memcached/protocol/ascii/BaseOpTest.java index 573eed337..85fb9b07b 100644 --- a/src/test/java/net/spy/memcached/protocol/ascii/BaseOpTest.java +++ b/src/test/java/net/spy/memcached/protocol/ascii/BaseOpTest.java @@ -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"); }