// Path: jflask/src/main/java/net/jflask/Response.java
// public interface Response {
// 
//   void addHeader(String header, String value);
// 
//   /**
//    * Warning: must be called after addHeader().
//    *
//    * @param status
//    * @see java.net.HttpURLConnection
//    */
//   void setStatus(int status);
// 
//   OutputStream getOutputStream();
// 
// }
// 
// Path: jflask/src/main/java/net/jflask/ResponseConverter.java
// public interface ResponseConverter<T> {
// 
//   void convert(T data, Response resp) throws Exception;
// }


import net.jflask.Convert;
import net.jflask.Response;
import net.jflask.ResponseConverter;
import net.jflask.Route;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
package net.jflask.test;



public class ConverterTest extends AbstractAppTest {

  @Convert("STAR")
  @Route("/hello/:name")
  public String hello(String name) {
    return "Hello " + name;
  }

  @Override
  protected void preScan() {
    app.addConverter("FOO", new ResponseConverter<String>() {
      public void convert(String data, Response resp) throws Exception {
        resp.setStatus(200);
        resp.getOutputStream().write(("FOO " + data).getBytes());
      }
    });
  }

  @Route(value = "/hello2/:name", converter = "FOO")
  public String hello2(String name) {
    return "Hello " + name;
  }

  @Test
  public void testConverterAddedAfterStart() throws Exception {
// Path: jflask/src/main/java/net/jflask/Response.java
// public interface Response {
// 
//   void addHeader(String header, String value);
// 
//   /**
//    * Warning: must be called after addHeader().
//    *
//    * @param status
//    * @see java.net.HttpURLConnection
//    */
//   void setStatus(int status);
// 
//   OutputStream getOutputStream();
// 
// }
// 
// Path: jflask/src/main/java/net/jflask/ResponseConverter.java
// public interface ResponseConverter<T> {
// 
//   void convert(T data, Response resp) throws Exception;
// }


// Path: jflask/src/test/java/net/jflask/test/ConverterTest.java
import net.jflask.Convert;
import net.jflask.Response;
import net.jflask.ResponseConverter;
import net.jflask.Route;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

package net.jflask.test;



public class ConverterTest extends AbstractAppTest {

  @Convert("STAR")
  @Route("/hello/:name")
  public String hello(String name) {
    return "Hello " + name;
  }

  @Override
  protected void preScan() {
    app.addConverter("FOO", new ResponseConverter<String>() {
      public void convert(String data, Response resp) throws Exception {
        resp.setStatus(200);
        resp.getOutputStream().write(("FOO " + data).getBytes());
      }
    });
  }

  @Route(value = "/hello2/:name", converter = "FOO")
  public String hello2(String name) {
    return "Hello " + name;
  }

  @Test
  public void testConverterAddedAfterStart() throws Exception {
    app.addConverter("STAR", new ResponseConverter<String>() {