/*
 * Copyright 2014 Red Hat, Inc.
 *
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  and Apache License v2.0 which accompanies this distribution.
 *
 *  The Eclipse Public License is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 *
 *  The Apache License v2.0 is available at
 *  http://www.opensource.org/licenses/apache2.0.php
 *
 *  You may elect to redistribute this code under either of these licenses.
 */
package io.vertx.ext.web.handler;

import io.vertx.core.http.HttpMethod;
import io.vertx.ext.web.WebTestBase;
import org.junit.Test;

/**
 * @author Paulo Lopes
 */
public class RerouteTest extends WebTestBase {

  @Test
  public void testReroute() throws Exception {
    router.get("/users/:name").handler(ctx -> {
      ctx.response().end("/users/:name");
    });
    router.get("/me").handler(ctx -> {
      ctx.reroute("/users/paulo");
    });

    testRequest(HttpMethod.GET, "/me", 200, "OK", "/users/:name");
  }

  @Test
  public void testRerouteReparse() throws Exception {
    router.get("/users/:name").handler(ctx -> {
      ctx.response().end(ctx.request().getParam("name"));
    });
    router.get("/me").handler(ctx -> {
      ctx.reroute("/users/paulo");
    });

    testRequest(HttpMethod.GET, "/me", 200, "OK", "paulo");
  }

  @Test
  public void testRerouteMethod() throws Exception {
    router.post("/me").handler(ctx -> {
      ctx.response().end("POST");
    });
    router.get("/me").handler(ctx -> {
      ctx.reroute(HttpMethod.POST, "/me");
    });

    testRequest(HttpMethod.GET, "/me", 200, "OK", "POST");
  }

  @Test
  public void testRerouteWithBody() throws Exception {
    router.route("/test/*").handler(BodyHandler.create());
    router.route("/test/v1").handler(ctx -> {
      ctx.reroute("/test/v2");
    });
    router.route("/test/v2").handler(ctx -> {
      ctx.response().end();
    });

    testRequest(HttpMethod.POST, "/test/v1", req -> {
      req.setChunked(true);
      req.write("Test HTTP Body");
    }, 200, "OK", null);
  }

//  @Test
//  public void testRerouteWithBody() throws Exception {
//    router.route("/test/*").handler(BodyHandler.create());
//    router.route("/test/v1").handler(ctx -> {
//      ctx.reroute("/test/v2");
//    });
//    router.route("/test/v2").handler(ctx -> {
//      ctx.response().end();
//    });
//
//    testRequest(HttpMethod.POST, "/test/v1", req -> {
//      req.setChunked(true);
//      req.write("Test HTTP Body");
//    }, 200, "OK", null);
//  }
}

@@ -2100,474 +2100,7 @@
 %0A  %7D
-%0A%0A//  @Test%0A//  public void testRerouteWithBody() throws Exception %7B%0A//    router.route(%22/test/*%22).handler(BodyHandler.create());%0A//    router.route(%22/test/v1%22).handler(ctx -%3E %7B%0A//      ctx.reroute(%22/test/v2%22);%0A//    %7D);%0A//    router.route(%22/test/v2%22).handler(ctx -%3E %7B%0A//      ctx.response().end();%0A//    %7D);%0A//%0A//    testRequest(HttpMethod.POST, %22/test/v1%22, req -%3E %7B%0A//      req.setChunked(true);%0A//      req.write(%22Test HTTP Body%22);%0A//    %7D, 200, %22OK%22, null);%0A//  %7D
 %0A%7D%0A

Remove dead code