|
25 | 25 | import static org.testng.Assert.assertNotEquals;
|
26 | 26 | import static org.testng.Assert.assertNull;
|
27 | 27 | import static org.testng.Assert.assertTrue;
|
| 28 | +import static org.testng.Assert.expectThrows; |
28 | 29 | import static org.testng.Assert.fail;
|
29 | 30 | import com.google.common.base.Utf8;
|
30 | 31 | import java.util.Base64;
|
31 | 32 | import lombok.Cleanup;
|
32 | 33 | import lombok.extern.slf4j.Slf4j;
|
33 | 34 | import org.apache.commons.lang3.StringUtils;
|
34 | 35 | import org.apache.pulsar.client.admin.PulsarAdmin;
|
| 36 | +import org.apache.pulsar.client.admin.PulsarAdminException; |
35 | 37 | import org.apache.pulsar.client.api.Consumer;
|
36 | 38 | import org.apache.pulsar.client.api.Message;
|
37 | 39 | import org.apache.pulsar.client.api.Producer;
|
@@ -144,6 +146,14 @@ public void testSourceState() throws Exception {
|
144 | 146 | assertEquals(functionState.getStringValue(), "val1");
|
145 | 147 | }
|
146 | 148 |
|
| 149 | + // query a non-exist key should get a 404 error |
| 150 | + { |
| 151 | + PulsarAdminException e = expectThrows(PulsarAdminException.class, () -> { |
| 152 | + admin.functions().getFunctionState("public", "default", sourceName, "non-exist"); |
| 153 | + }); |
| 154 | + assertEquals(e.getStatusCode(), 404); |
| 155 | + } |
| 156 | + |
147 | 157 | Awaitility.await().ignoreExceptions().untilAsserted(() -> {
|
148 | 158 | FunctionState functionState = admin.functions().getFunctionState("public", "default", sourceName, "now");
|
149 | 159 | assertTrue(functionState.getStringValue().matches("val1-.*"));
|
@@ -186,6 +196,14 @@ public void testSinkState() throws Exception {
|
186 | 196 | assertEquals(functionState.getStringValue(), "val1");
|
187 | 197 | }
|
188 | 198 |
|
| 199 | + // query a non-exist key should get a 404 error |
| 200 | + { |
| 201 | + PulsarAdminException e = expectThrows(PulsarAdminException.class, () -> { |
| 202 | + admin.functions().getFunctionState("public", "default", sinkName, "non-exist"); |
| 203 | + }); |
| 204 | + assertEquals(e.getStatusCode(), 404); |
| 205 | + } |
| 206 | + |
189 | 207 | for (int i = 0; i < numMessages; i++) {
|
190 | 208 | producer.send("foo");
|
191 | 209 | }
|
|
0 commit comments