/**
 * <p>Title: FastJsonProviderTest.java</p>
 * <p>Description: FastJsonProviderTest</p>
 * <p>Package: com.alibaba.json.bvt.support.jaxrs.mock.testcase</p>
 * <p>Company: www.github.com/DarkPhoenixs</p>
 * <p>Copyright: Dark Phoenixs (Open-Source Organization) 2016</p>
 */
package com.alibaba.json.bvt.support.jaxrs.mock.testcase;

import javax.ws.rs.core.Application;
import javax.ws.rs.core.Response;

import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.web.context.ContextLoaderListener;

import com.alibaba.fastjson.JSONObject;

/**
 * <p>Title: FastJsonProviderTest</p>
 * <p>Description: </p>
 *
 * @since 2016年4月20日
 * @author Victor.Zxy
 * @version 1.0
 */
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(classes = Application.class)
public class FastJsonProviderTest {

	public final String REST_SERVICE_URL = "http://localhost:8088/rest";

	static {

		Server server = new Server(8088);

		// Register and map the dispatcher servlet
		final ServletHolder servletHolder = new ServletHolder(new CXFServlet());
		final ServletContextHandler context = new ServletContextHandler();
		context.setContextPath("/");
		context.addServlet(servletHolder, "/rest/*");
		context.addEventListener(new ContextLoaderListener());
		context.setInitParameter(
				"contextConfigLocation",
				"classpath*:/com/alibaba/json/bvt/support/jaxrs/mock/resource/applicationContext-rest.xml");
		server.setHandler(context);
		try {
			server.start();
//			server.join();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@Test
	public void test0() throws Exception {
		
		JSONObject json = new JSONObject();
		
		json.put("id", 123);
		
		json.put("name", "哈哈哈");
		
		WebClient client = WebClient.create(REST_SERVICE_URL);
		
		Response response = client.path("/fastjson/test1").accept("application/json").type("application/json; charset=UTF-8").post(json.toJSONString());
		
		System.out.println(response.readEntity(String.class));
	}
	
	@Test
	public void test1() throws Exception {
		
		JSONObject json = new JSONObject();
		
		json.put("id", 123);
		
		json.put("name", "哈哈哈");
		
		WebClient client = WebClient.create(REST_SERVICE_URL);
		
		Response response = client.path("/fastjson/test1").replaceQuery("pretty").accept("application/json").type("application/json; charset=UTF-8").post(json.toJSONString());
		
		System.out.println(response.readEntity(String.class));
	}
	
	@Test
	public void test2() throws Exception {
		
		String jsonStr = "[{\"name\":\"p1\",\"sonList\":[{\"name\":\"s1\"}]},{\"name\":\"p2\",\"sonList\":[{\"name\":\"s2\"},{\"name\":\"s3\"}]}]";
		
		WebClient client = WebClient.create(REST_SERVICE_URL);
		
		Response response = client.path("/fastjson/test2").accept("application/json").type("application/json; charset=UTF-8").post(jsonStr);
		
		System.out.println(response.readEntity(String.class));
	}
}

@@ -664,34 +664,8 @@
 r;%0D%0A
-import org.junit.Before;%0D%0A
 impo
@@ -1857,57 +1857,65 @@
 th*:
-/com/
+%5C%5Ccom%5C%5C
 alibaba
-/
+%5C%5C
 json
-/bvt/
+%5C%5Cbvt%5C%5C
 support
-/
+%5C%5C
 jaxrs
-/
+%5C%5C
 mock
-/
+%5C%5C
 resource
 /app
@@ -1910,17 +1910,18 @@
 resource
-/
+%5C%5C
 applicat

refactor testcase