|
1 | 1 | package io.temporal.workerFactory;
|
2 | 2 |
|
| 3 | +import static org.junit.Assert.assertEquals; |
3 | 4 | import static org.junit.Assert.assertFalse;
|
| 5 | +import static org.junit.Assert.assertThrows; |
4 | 6 | import static org.junit.Assert.assertTrue;
|
5 | 7 |
|
| 8 | +import io.grpc.Status; |
| 9 | +import io.grpc.StatusRuntimeException; |
6 | 10 | import io.temporal.client.WorkflowClient;
|
| 11 | +import io.temporal.client.WorkflowClientOptions; |
7 | 12 | import io.temporal.serviceclient.WorkflowServiceStubs;
|
8 | 13 | import io.temporal.serviceclient.WorkflowServiceStubsOptions;
|
9 | 14 | import io.temporal.worker.WorkerFactory;
|
@@ -128,4 +133,24 @@ public void factoryCanBeShutdownMoreThanOnce() {
|
128 | 133 | factory.shutdown();
|
129 | 134 | factory.awaitTermination(1, TimeUnit.MILLISECONDS);
|
130 | 135 | }
|
| 136 | + |
| 137 | + @Test |
| 138 | + public void startFailsOnNonexistentNamespace() { |
| 139 | + WorkflowServiceStubs serviceLocal = |
| 140 | + WorkflowServiceStubs.newServiceStubs( |
| 141 | + WorkflowServiceStubsOptions.newBuilder().setTarget(serviceAddress).build()); |
| 142 | + WorkflowClient clientLocal = |
| 143 | + WorkflowClient.newInstance( |
| 144 | + serviceLocal, WorkflowClientOptions.newBuilder().setNamespace("i_dont_exist").build()); |
| 145 | + WorkerFactory factoryLocal = WorkerFactory.newInstance(clientLocal); |
| 146 | + factoryLocal.newWorker("task-queue"); |
| 147 | + |
| 148 | + StatusRuntimeException ex = assertThrows(StatusRuntimeException.class, factoryLocal::start); |
| 149 | + assertEquals(Status.Code.NOT_FOUND, ex.getStatus().getCode()); |
| 150 | + |
| 151 | + factoryLocal.shutdownNow(); |
| 152 | + factoryLocal.awaitTermination(5, TimeUnit.SECONDS); |
| 153 | + serviceLocal.shutdownNow(); |
| 154 | + serviceLocal.awaitTermination(5, TimeUnit.SECONDS); |
| 155 | + } |
131 | 156 | }
|
0 commit comments