<commit_before>package org.rapidoid.http;

/*
 * #%L
 * rapidoid-rest
 * %%
 * Copyright (C) 2014 - 2015 <NAME> and contributors
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import java.util.concurrent.TimeUnit;

import org.junit.Test;
import org.rapidoid.annotation.Authors;
import org.rapidoid.annotation.Since;
import org.rapidoid.concurrent.Promise;
import org.rapidoid.concurrent.Promises;
import org.rapidoid.http.fast.On;
import org.rapidoid.http.fast.ReqHandler;
import org.rapidoid.job.Jobs;
import org.rapidoid.test.TestCommons;
import org.rapidoid.u.U;

@Authors("<NAME>")
@Since("4.4.0")
public class DynamicClientTest extends TestCommons {

	private final MyClient client = REST.client(MyClient.class);

	@Test
	public void testDynamic() {
		On.address("127.0.0.1").port(8989).get("/test-abc").html("abc-ok");

		On.get("/nums").json("[1, 2, 3]");

		On.get("/size").json(new ReqHandler() {
			@Override
			public Object handle(Req req) throws Exception {
				return req.param("s").length();
			}
		});

		On.post("/echo").json(new ReqHandler() {
			@Override
			public Object handle(final Req req) throws Exception {
				Jobs.schedule(new Runnable() {
					@Override
					public void run() {
						Reqs.req().response().content(req.data()).done();
					}<commit_msg>Fixed HTTP client + server test.<commit_after>package org.rapidoid.http;

/*
 * #%L
 * rapidoid-rest
 * %%
 * Copyright (C) 2014 - 2015 <NAME> and contributors
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import java.util.concurrent.TimeUnit;

import org.junit.Test;
import org.rapidoid.annotation.Authors;
import org.rapidoid.annotation.Since;
import org.rapidoid.concurrent.Promise;
import org.rapidoid.concurrent.Promises;
import org.rapidoid.http.fast.On;
import org.rapidoid.http.fast.ReqHandler;
import org.rapidoid.job.Jobs;
import org.rapidoid.test.TestCommons;
import org.rapidoid.u.U;

@Authors("<NAME>")
@Since("4.4.0")
public class DynamicClientTest extends TestCommons {

	private final MyClient client = REST.client(MyClient.class);

	@Test
	public void testDynamic() {
		On.address("127.0.0.1").port(8989).get("/test-abc").html("abc-ok");

		On.get("/nums").json("[1, 2, 3]");

		On.get("/size").json(new ReqHandler() {
			@Override
			public Object handle(Req req) throws Exception {
				return req.param("s").length();
			}
		});

		On.post("/echo").json(new ReqHandler() {
			@Override
			public Object handle(final Req req) throws Exception {
				req.async();

				Jobs.schedule(new Runnable() {
					@Override
					public void run() {
						U.must(Reqs.req() == req);
						Response resp = req.response();
						resp.content(req.data()).done();
					}
{'fraction_non_alphanumeric': 0.13573929437112847, 'fraction_numerical': 0.015082143819014274, 'mean_word_length': 3.8359375, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1891068', 'n_tokens_mistral': 1292, 'n_tokens_neox': 1146, 'n_words': 330}