Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
JdkRequest instead of ApacheResquest
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed Oct 24, 2017
1 parent 219f16e commit f23e2f1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 23 deletions.
10 changes: 0 additions & 10 deletions pom.xml
Expand Up @@ -42,16 +42,6 @@
<artifactId>jcabi-http</artifactId>
<version>1.16</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.1</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
Expand Down
Expand Up @@ -27,6 +27,7 @@
import javax.ws.rs.core.HttpHeaders;
import com.jcabi.http.Request;
import com.jcabi.http.request.ApacheRequest;
import com.jcabi.http.request.JdkRequest;
import com.jcabi.http.wire.TrustedWire;

/**
Expand Down Expand Up @@ -54,7 +55,7 @@ public abstract class AuthorizedRequest {
* @param originalEndpoint Original url for this request.
*/
public AuthorizedRequest(Authorization atz, String originalEndpoint) {
this.req = new ApacheRequest(originalEndpoint);
this.req = new JdkRequest(originalEndpoint);
this.atz = atz;
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/amihaiemil/charles/github/NtPost.java
Expand Up @@ -89,11 +89,11 @@ public void send() throws IOException {
)
).status();
if(status == HttpURLConnection.HTTP_OK) {
log.info("Notifications sent successfully! Marking notifications as read...");
log.info(notifications.size() + " notifications sent successfully! Marking notifications as read...");
this.notifications.markAsRead();
log.info("Notifications marked as read!");
log.info(notifications.size() + " notifications marked as read!");
} else {
log.error("Could not send, got response status: " + status);
log.error("Could not send notifications, got response status: " + status);
}
} else {
log.info("No notifications to send");
Expand Down
Expand Up @@ -30,16 +30,12 @@
import com.jcabi.http.mock.MkContainer;
import com.jcabi.http.mock.MkGrizzlyContainer;
import com.jcabi.http.mock.MkQuery;

import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.ServerSocket;
import java.util.List;

import javax.json.JsonObject;

import org.apache.http.HttpStatus;
import org.junit.Test;

/**
Expand Down Expand Up @@ -83,7 +79,7 @@ public void fetchesNotifications() throws Exception {
public void fetchesNotificationsWithError() throws Exception {
int port = this.port();
MkContainer server = new MkGrizzlyContainer()
.next(new MkAnswer.Simple(HttpStatus.SC_BAD_REQUEST)).start(port);
.next(new MkAnswer.Simple(HttpURLConnection.HTTP_BAD_REQUEST)).start(port);
try {
Notifications notifications = new RtNotifications(
new Reason.Fake(),
Expand Down Expand Up @@ -126,7 +122,7 @@ public void nothingFetched() throws Exception {
public void markAsReadOk() throws Exception {
int port = this.port();
MkContainer server = new MkGrizzlyContainer()
.next(new MkAnswer.Simple(HttpStatus.SC_OK)).start(port);
.next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK)).start(port);
try {
Notifications notifications = new RtNotifications(
new Reason.Fake(),
Expand All @@ -151,7 +147,7 @@ public void markAsReadOk() throws Exception {
public void markAsReadReset() throws Exception {
int port = this.port();
MkContainer server = new MkGrizzlyContainer()
.next(new MkAnswer.Simple(HttpStatus.SC_RESET_CONTENT)).start(port);
.next(new MkAnswer.Simple(HttpURLConnection.HTTP_RESET)).start(port);
try {
Notifications notifications = new RtNotifications(
new Reason.Fake(),
Expand All @@ -177,7 +173,7 @@ public void markAsReadReset() throws Exception {
public void markAsReadServerNotOk() throws Exception {
int port = this.port();
MkContainer server = new MkGrizzlyContainer()
.next(new MkAnswer.Simple(HttpStatus.SC_INTERNAL_SERVER_ERROR)).start(port);
.next(new MkAnswer.Simple(HttpURLConnection.HTTP_INTERNAL_ERROR)).start(port);
try {
Notifications notifications = new RtNotifications(
new Reason.Fake(),
Expand Down

0 comments on commit f23e2f1

Please sign in to comment.