-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
107 additions
and
1 deletion.
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
47 changes: 47 additions & 0 deletions
47
src/test/java/net/spy/memcached/internal/CompositeExceptionTest.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,47 @@ | ||
package net.spy.memcached.internal; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import net.spy.memcached.ops.OperationErrorType; | ||
import net.spy.memcached.ops.OperationException; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
class CompositeExceptionTest { | ||
|
||
|
||
|
||
@Test | ||
void printStackTraceOfAllExceptions() { | ||
List<Exception> exceptions = new ArrayList<>(); | ||
exceptions.add(new OperationException(OperationErrorType.SERVER, "msg1")); | ||
exceptions.add(new OperationException(OperationErrorType.CLIENT, "msg2")); | ||
Exception e = throwError1(); | ||
exceptions.add(e); | ||
CompositeException compositeException = new CompositeException(exceptions); | ||
String message = compositeException.getCause().getMessage(); | ||
|
||
compositeException.printStackTrace(); | ||
assertTrue(message | ||
.contains("OperationException: SERVER: msg1")); | ||
assertTrue(message | ||
.contains("OperationException: CLIENT: msg2")); | ||
assertTrue(message | ||
.contains("OperationException: SERVER: msg3")); | ||
assertTrue(message | ||
.contains("at net.spy.memcached.internal.CompositeExceptionTest.throwError2")); | ||
assertTrue(message | ||
.contains("at net.spy.memcached.internal.CompositeExceptionTest.throwError1")); | ||
} | ||
|
||
private Exception throwError1() { | ||
return throwError2(); | ||
} | ||
|
||
private Exception throwError2() { | ||
return new OperationException(OperationErrorType.SERVER, "msg3"); | ||
} | ||
} |