|
10 | 10 | import java.util.Collections; |
11 | 11 |
|
12 | 12 | import static org.junit.Assert.assertEquals; |
| 13 | +import static org.junit.Assert.assertThrows; |
| 14 | +import org.junit.function.ThrowingRunnable; |
13 | 15 |
|
14 | 16 | public class OAuth1AccessTokenExtractorTest { |
15 | 17 |
|
@@ -65,34 +67,50 @@ public void shouldExtractTokenWithEmptySecret() throws IOException { |
65 | 67 | assertEquals("", extracted.getTokenSecret()); |
66 | 68 | } |
67 | 69 |
|
68 | | - @Test(expected = OAuthException.class) |
69 | 70 | public void shouldThrowExceptionIfTokenIsAbsent() throws IOException { |
70 | 71 | final String responseBody = "oauth_secret=hh5s93j4hdidpola&callback_confirmed=true"; |
71 | 72 | try (Response response = ok(responseBody)) { |
72 | | - extractor.extract(response); |
| 73 | + assertThrows(OAuthException.class, new ThrowingRunnable() { |
| 74 | + @Override |
| 75 | + public void run() throws Throwable { |
| 76 | + extractor.extract(response); |
| 77 | + } |
| 78 | + }); |
73 | 79 | } |
74 | 80 | } |
75 | 81 |
|
76 | | - @Test(expected = OAuthException.class) |
77 | 82 | public void shouldThrowExceptionIfSecretIsAbsent() throws IOException { |
78 | 83 | final String responseBody = "oauth_token=hh5s93j4hdidpola&callback_confirmed=true"; |
79 | 84 | try (Response response = ok(responseBody)) { |
80 | | - extractor.extract(response); |
| 85 | + assertThrows(OAuthException.class, new ThrowingRunnable() { |
| 86 | + @Override |
| 87 | + public void run() throws Throwable { |
| 88 | + extractor.extract(response); |
| 89 | + } |
| 90 | + }); |
81 | 91 | } |
82 | 92 | } |
83 | 93 |
|
84 | | - @Test(expected = IllegalArgumentException.class) |
85 | 94 | public void shouldThrowExceptionIfResponseIsNull() throws IOException { |
86 | 95 | try (Response response = ok(null)) { |
87 | | - extractor.extract(response); |
| 96 | + assertThrows(IllegalArgumentException.class, new ThrowingRunnable() { |
| 97 | + @Override |
| 98 | + public void run() throws Throwable { |
| 99 | + extractor.extract(response); |
| 100 | + } |
| 101 | + }); |
88 | 102 | } |
89 | 103 | } |
90 | 104 |
|
91 | | - @Test(expected = IllegalArgumentException.class) |
92 | 105 | public void shouldThrowExceptionIfResponseIsEmptyString() throws IOException { |
93 | 106 | final String responseBody = ""; |
94 | 107 | try (Response response = ok(responseBody)) { |
95 | | - extractor.extract(response); |
| 108 | + assertThrows(IllegalArgumentException.class, new ThrowingRunnable() { |
| 109 | + @Override |
| 110 | + public void run() throws Throwable { |
| 111 | + extractor.extract(response); |
| 112 | + } |
| 113 | + }); |
96 | 114 | } |
97 | 115 | } |
98 | 116 |
|
|
0 commit comments