<commit_before>package io.vertx.webclient;

import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.rxjava.core.Vertx;
import io.vertx.rxjava.core.buffer.Buffer;
import io.vertx.rxjava.core.http.HttpServer;
import io.vertx.test.core.VertxTestBase;
import io.vertx.rxjava.webclient.WebClient;
import io.vertx.rxjava.webclient.HttpResponse;
import org.junit.Test;
import rx.Observable;
import rx.Single;

/**
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 */
public class RxTest extends VertxTestBase {

  private Vertx vertx;
  private WebClient client;

  @Override
  public void setUp() throws Exception {
    super.setUp();
    vertx = new Vertx(super.vertx);

  }

  @Test
  public void testGet() {
    int times = 5;
    waitFor(times);
    HttpServer server = vertx.createHttpServer(new HttpServerOptions().setPort(8080));
    server.requestStream().handler(req -> {
      req.response().setChunked(true).end("some_content");
    });
    try {
      server.listen(ar -> {
        client = WebClient.wrap(vertx.createHttpClient(new HttpClientOptions()));
        Single<HttpResponse<Buffer>> single = client
          .get(8080, "localhost", "/the_uri")
          .rxSend();
        for (int i = 0; i < times; i++) {
          single.subscribe(resp -> {
            assertEquals("some_content", resp.body().toString("UTF-8"));
            complete();
          }, this::fail);
        }
      });
      await();
    } finally {
      server.close();
    }
  }

  @Test
  public void testPost() {
    int times = 5;
    waitFor(times);
    HttpServer server = vertx.createHttpServer(new HttpServerOptions().setPort(8080));
    server.requestStream().handler(req -> {
      req.bodyHandler(buff -> {
        assertEquals("onetwothree", buff.toString());
        req.response().end();
      });
    });
    try {
      server.listen(ar -> {
        client = WebClient.wrap(vertx.createHttpClient(new HttpClientOptions()));
        Observable<Buffer> stream = Observable.just(Buffer.buffer("one"), Buffer.buffer("two"), Buffer.buffer("three"));
        Single<HttpResponse<Buffer>> single = client
          .post(8080, "localhost", "/the_uri")
          .rxSendStream(stream);
        for (int i = 0; i < times; i++) {
          single.subscribe(resp -> {
            complete();
          }, this::fail);
        }
      });
      await();
    } finally {
      server.close();
    }
  }

  @Test
  public void testResponseMissingBody() throws Exception {
    int times = 5;
    waitFor(times);
    HttpServer server = vertx.createHttpServer(new HttpServerOptions().setPort(8080));
    server.requestStream().handler(req -> {
      req.response().setStatusCode(403).end();
    });
    try {
      server.listen(ar -> {
        client = WebClient.wrap(vertx.createHttpClient(new HttpClientOptions()));
        Single<HttpResponse<Buffer>> single = client
          .get(8080, "localhost", "/the_uri")
          .rxSend();
        for (int i = 0; i < times; i++) {
          single.subscribe(resp -> {
            assertEquals(403, resp.statusCode());
            try {
              assertNull(resp.body());
            } catch (Exception e) {
              e.printStackTrace();
            }
            complete();
          }, this::fail);
        }
      });
      await();
    } finally {
      server.close();
    }
  }
}<commit_msg>Remove inapropriate try/catch in RxTest<commit_after>package io.vertx.webclient;

import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.rxjava.core.Vertx;
import io.vertx.rxjava.core.buffer.Buffer;
import io.vertx.rxjava.core.http.HttpServer;
import io.vertx.test.core.VertxTestBase;
import io.vertx.rxjava.webclient.WebClient;
import io.vertx.rxjava.webclient.HttpResponse;
import org.junit.Test;
import rx.Observable;
import rx.Single;

/**
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 */
public class RxTest extends VertxTestBase {

  private Vertx vertx;
  private WebClient client;

  @Override
  public void setUp() throws Exception {
    super.setUp();
    vertx = new Vertx(super.vertx);

  }

  @Test
  public void testGet() {
    int times = 5;
    waitFor(times);
    HttpServer server = vertx.createHttpServer(new HttpServerOptions().setPort(8080));
    server.requestStream().handler(req -> {
      req.response().setChunked(true).end("some_content");
    });
    try {
      server.listen(ar -> {
        client = WebClient.wrap(vertx.createHttpClient(new HttpClientOptions()));
        Single<HttpResponse<Buffer>> single = client
          .get(8080, "localhost", "/the_uri")
          .rxSend();
        for (int i = 0; i < times; i++) {
          single.subscribe(resp -> {
            assertEquals("some_content", resp.body().toString("UTF-8"));
            complete();
          }, this::fail);
        }
      });
      await();
    } finally {
      server.close();
    }
  }

  @Test
  public void testPost() {
    int times = 5;
    waitFor(times);
    HttpServer server = vertx.createHttpServer(new HttpServerOptions().setPort(8080));
    server.requestStream().handler(req -> {
      req.bodyHandler(buff -> {
        assertEquals("onetwothree", buff.toString());
        req.response().end();
      });
    });
    try {
      server.listen(ar -> {
        client = WebClient.wrap(vertx.createHttpClient(new HttpClientOptions()));
        Observable<Buffer> stream = Observable.just(Buffer.buffer("one"), Buffer.buffer("two"), Buffer.buffer("three"));
        Single<HttpResponse<Buffer>> single = client
          .post(8080, "localhost", "/the_uri")
          .rxSendStream(stream);
        for (int i = 0; i < times; i++) {
          single.subscribe(resp -> {
            complete();
          }, this::fail);
        }
      });
      await();
    } finally {
      server.close();
    }
  }

  @Test
  public void testResponseMissingBody() throws Exception {
    int times = 5;
    waitFor(times);
    HttpServer server = vertx.createHttpServer(new HttpServerOptions().setPort(8080));
    server.requestStream().handler(req -> {
      req.response().setStatusCode(403).end();
    });
    try {
      server.listen(ar -> {
        client = WebClient.wrap(vertx.createHttpClient(new HttpClientOptions()));
        Single<HttpResponse<Buffer>> single = client
          .get(8080, "localhost", "/the_uri")
          .rxSend();
        for (int i = 0; i < times; i++) {
          single.subscribe(resp -> {
            assertEquals(403, resp.statusCode());
            assertNull(resp.body());
            complete();
          }, this::fail);
        }
      });
      await();
    } finally {
      server.close();
    }
  }
}
{'fraction_non_alphanumeric': 0.1508279874682978, 'fraction_numerical': 0.011039832910637029, 'mean_word_length': 2.5136268343815513, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '530935', 'n_tokens_mistral': 2062, 'n_tokens_neox': 1997, 'n_words': 369}