|  | 
| 2 | 2 | 
 | 
| 3 | 3 | import io.vertx.core.Vertx; | 
| 4 | 4 | import io.vertx.core.buffer.Buffer; | 
|  | 5 | +import io.vertx.core.eventbus.DeliveryOptions; | 
| 5 | 6 | import io.vertx.core.eventbus.MessageConsumer; | 
| 6 | 7 | import io.vertx.core.http.HttpHeaders; | 
| 7 | 8 | import io.vertx.core.http.HttpMethod; | 
|  | 9 | +import io.vertx.core.http.impl.headers.HeadersMultiMap; | 
| 8 | 10 | import io.vertx.core.json.JsonArray; | 
| 9 | 11 | import io.vertx.core.json.JsonObject; | 
| 10 | 12 | import io.vertx.core.json.pointer.JsonPointer; | 
|  | 
| 26 | 28 | import java.net.URI; | 
| 27 | 29 | import java.nio.file.Files; | 
| 28 | 30 | import java.nio.file.Paths; | 
|  | 31 | +import java.util.Arrays; | 
| 29 | 32 | 
 | 
| 30 | 33 | import static io.vertx.ext.web.validation.builder.Bodies.json; | 
| 31 | 34 | import static io.vertx.ext.web.validation.builder.Parameters.param; | 
| 32 |  | -import static io.vertx.ext.web.validation.testutils.TestRequest.bodyResponse; | 
| 33 |  | -import static io.vertx.ext.web.validation.testutils.TestRequest.emptyResponse; | 
| 34 |  | -import static io.vertx.ext.web.validation.testutils.TestRequest.jsonBodyResponse; | 
| 35 |  | -import static io.vertx.ext.web.validation.testutils.TestRequest.statusCode; | 
| 36 |  | -import static io.vertx.ext.web.validation.testutils.TestRequest.statusMessage; | 
| 37 |  | -import static io.vertx.ext.web.validation.testutils.TestRequest.testRequest; | 
|  | 35 | +import static io.vertx.ext.web.validation.testutils.TestRequest.*; | 
| 38 | 36 | import static io.vertx.json.schema.common.dsl.Schemas.anyOf; | 
| 39 | 37 | import static io.vertx.json.schema.common.dsl.Schemas.arraySchema; | 
| 40 | 38 | import static io.vertx.json.schema.common.dsl.Schemas.intSchema; | 
| @@ -122,7 +120,7 @@ public void serviceProxyDataObjectTest(Vertx vertx, VertxTestContext testContext | 
| 122 | 120 |         "src", "test", | 
| 123 | 121 |         "resources", "filter.json"))))); | 
| 124 | 122 |     schemaRepo.dereference("app://filter.json", filterSchema); | 
| 125 |  | -     | 
|  | 123 | + | 
| 126 | 124 |     router | 
| 127 | 125 |       .post("/test") | 
| 128 | 126 |       .handler(BodyHandler.create()) | 
| @@ -217,6 +215,35 @@ public void extraPayloadTest(Vertx vertx, VertxTestContext testContext) { | 
| 217 | 215 |       .send(testContext, checkpoint); | 
| 218 | 216 |   } | 
| 219 | 217 | 
 | 
|  | 218 | +  @Test | 
|  | 219 | +  void headersTest(Vertx vertx, VertxTestContext testContext) { | 
|  | 220 | +    Checkpoint checkpoint = testContext.checkpoint(); | 
|  | 221 | + | 
|  | 222 | +    TestService service = new TestServiceImpl(vertx); | 
|  | 223 | +    final ServiceBinder serviceBinder = new ServiceBinder(vertx).setAddress("someAddress"); | 
|  | 224 | +    consumer = serviceBinder.register(TestService.class, service); | 
|  | 225 | + | 
|  | 226 | +    HeadersMultiMap headers = HeadersMultiMap.headers(); | 
|  | 227 | +    headers.add("Set-Cookie", "cookie1=cookie1"); | 
|  | 228 | +    headers.add("Set-Cookie", "cookie2=cookie2"); | 
|  | 229 | + | 
|  | 230 | +    DeliveryOptions deliveryOptions = new DeliveryOptions(); | 
|  | 231 | +    deliveryOptions.setHeaders(headers); | 
|  | 232 | + | 
|  | 233 | +    router | 
|  | 234 | +      .get("/test") | 
|  | 235 | +      .handler( | 
|  | 236 | +        ValidationHandlerBuilder.create(schemaRepo).build() | 
|  | 237 | +      ).handler( | 
|  | 238 | +        RouteToEBServiceHandler.build(vertx.eventBus(), "someAddress", "testHeaders", deliveryOptions) | 
|  | 239 | +      ); | 
|  | 240 | + | 
|  | 241 | +    testRequest(client, HttpMethod.GET, "/test") | 
|  | 242 | +      .expect(statusCode(200), statusMessage("OK"), responseHeaders("Set-Cookie", Arrays.asList("cookie1=cookie1", "cookie2=cookie2"))) | 
|  | 243 | +      .expect(emptyResponse()) | 
|  | 244 | +      .send(testContext, checkpoint); | 
|  | 245 | +  } | 
|  | 246 | + | 
| 220 | 247 |   @Test | 
| 221 | 248 |   public void serviceProxyManualFailureTest(Vertx vertx, VertxTestContext testContext) { | 
| 222 | 249 |     Checkpoint checkpoint = testContext.checkpoint(2); | 
|  | 
0 commit comments