From 08ef979a4f7dcfd39dc89b1069edb770aede82b4 Mon Sep 17 00:00:00 2001 From: wutao1 Date: Sat, 2 Nov 2019 12:57:51 +0800 Subject: [PATCH] add unit tests --- .../infra/pegasus/client/TestPException.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/test/java/com/xiaomi/infra/pegasus/client/TestPException.java diff --git a/src/test/java/com/xiaomi/infra/pegasus/client/TestPException.java b/src/test/java/com/xiaomi/infra/pegasus/client/TestPException.java new file mode 100644 index 00000000..20dd8b15 --- /dev/null +++ b/src/test/java/com/xiaomi/infra/pegasus/client/TestPException.java @@ -0,0 +1,26 @@ +// Copyright (c) 2019, Xiaomi, Inc. All rights reserved. +// This source code is licensed under the Apache License Version 2.0, which +// can be found in the LICENSE file in the root directory of this source tree. + +package com.xiaomi.infra.pegasus.client; + +import org.junit.Assert; +import org.junit.Test; + +public class TestPException { + @Test + public void testThreadInterrupted() throws Exception { + PException ex = PException.threadInterrupted("test"); + Assert.assertEquals( + "com.xiaomi.infra.pegasus.rpc.ReplicationException: ERR_THREAD_INTERRUPTED: [table=test] Thread is interrupted!", + ex.getMessage()); + } + + @Test + public void testTimeout() throws Exception { + PException ex = PException.timeout("test", 1000); + Assert.assertEquals( + "com.xiaomi.infra.pegasus.rpc.ReplicationException: ERR_TIMEOUT: [table=test, timeout=1000ms] Timeout on Future await!", + ex.getMessage()); + } +}