This repository has been archived by the owner on May 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add more exception info on synchronous APIs (#62)
- Loading branch information
Wu Tao
authored
Nov 4, 2019
1 parent
cce3f89
commit 592bcde
Showing
4 changed files
with
90 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/test/java/com/xiaomi/infra/pegasus/client/TestPException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// 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 java.util.concurrent.TimeoutException; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class TestPException { | ||
@Test | ||
public void testThreadInterrupted() throws Exception { | ||
PException ex = PException.threadInterrupted("test", new InterruptedException("intxxx")); | ||
Assert.assertEquals( | ||
"com.xiaomi.infra.pegasus.rpc.ReplicationException: ERR_THREAD_INTERRUPTED: [table=test] Thread was interrupted: intxxx", | ||
ex.getMessage()); | ||
} | ||
|
||
@Test | ||
public void testTimeout() throws Exception { | ||
PException ex = PException.timeout("test", 1000, new TimeoutException("tmxxx")); | ||
Assert.assertEquals( | ||
"com.xiaomi.infra.pegasus.rpc.ReplicationException: ERR_TIMEOUT: [table=test, timeout=1000ms] Timeout on Future await: tmxxx", | ||
ex.getMessage()); | ||
} | ||
} |