Skip to content

Commit

Permalink
Use travis to enforce code format (#1061)
Browse files Browse the repository at this point in the history
* Use travis to enforce code format

* Use travis to enforce that should be no local changes after build

* Seems hard to break a build on travis

* Format code

* Create log files on temp dir
  • Loading branch information
velo authored Sep 3, 2019
1 parent c5dccf3 commit e9543a6
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 134 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ jdk:

before_install: ./travis/sign.sh

script:
- ./mvnw clean install -B
# fail build if there are any local changes to sources
- ./travis/no-git-changes.sh

jobs:
include:
- stage: snapshot
Expand Down
3 changes: 0 additions & 3 deletions core/src/main/java/feign/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import static feign.Util.isBlank;
import static feign.Util.isNotBlank;
import static java.lang.String.format;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand All @@ -37,11 +36,9 @@
import java.util.Map;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.GZIPOutputStream;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocketFactory;

import feign.Request.Options;

/**
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/feign/FeignException.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
*/
public class FeignException extends RuntimeException {

private static final String EXCEPTION_MESSAGE_TEMPLATE_NULL_REQUEST = "request should not be null";
private static final String EXCEPTION_MESSAGE_TEMPLATE_NULL_REQUEST =
"request should not be null";
private static final long serialVersionUID = 0;
private int status;
private byte[] content;
Expand Down
64 changes: 32 additions & 32 deletions core/src/test/java/feign/FeignExceptionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,43 @@

public class FeignExceptionTest {

@Test(expected = NullPointerException.class)
public void nullRequestShouldThrowNPEwThrowable() {
new Derived(404, "message", null, new Throwable());
@Test(expected = NullPointerException.class)
public void nullRequestShouldThrowNPEwThrowable() {
new Derived(404, "message", null, new Throwable());
}

@Test(expected = NullPointerException.class)
public void nullRequestShouldThrowNPEwThrowableAndBytes() {
new Derived(404, "message", null, new Throwable(), new byte[1]);
}

@Test(expected = NullPointerException.class)
public void nullRequestShouldThrowNPE() {
new Derived(404, "message", null);
}

@Test(expected = NullPointerException.class)
public void nullRequestShouldThrowNPEwBytes() {
new Derived(404, "message", null, new byte[1]);
}

static class Derived extends FeignException {

public Derived(int status, String message, Request request, Throwable cause) {
super(status, message, request, cause);
}

@Test(expected = NullPointerException.class)
public void nullRequestShouldThrowNPEwThrowableAndBytes() {
new Derived(404, "message", null, new Throwable(), new byte[1]);
public Derived(int status, String message, Request request, Throwable cause, byte[] content) {
super(status, message, request, cause, content);
}

@Test(expected = NullPointerException.class)
public void nullRequestShouldThrowNPE() {
new Derived(404, "message", null);
public Derived(int status, String message, Request request) {
super(status, message, request);
}

@Test(expected = NullPointerException.class)
public void nullRequestShouldThrowNPEwBytes() {
new Derived(404, "message", null, new byte[1]);
public Derived(int status, String message, Request request, byte[] content) {
super(status, message, request, content);
}
}

static class Derived extends FeignException {

public Derived(int status, String message, Request request, Throwable cause) {
super(status, message, request, cause);
}

public Derived(int status, String message, Request request, Throwable cause, byte[] content) {
super(status, message, request, cause, content);
}

public Derived(int status, String message, Request request) {
super(status, message, request);
}

public Derived(int status, String message, Request request, byte[] content) {
super(status, message, request, content);
}
}

}
}
21 changes: 16 additions & 5 deletions core/src/test/java/feign/MultipleLoggerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@
*/
package feign;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.lang.reflect.Field;

public class MultipleLoggerTest {

@Rule
public TemporaryFolder tmp = new TemporaryFolder();

private static java.util.logging.Logger getInnerLogger(Logger.JavaLogger logger)
throws Exception {
Field inner = logger.getClass().getDeclaredField("logger");
Expand All @@ -27,15 +32,19 @@ private static java.util.logging.Logger getInnerLogger(Logger.JavaLogger logger)

@Test
public void testAppendSeveralFilesToOneJavaLogger() throws Exception {
Logger.JavaLogger logger = new Logger.JavaLogger().appendToFile("1.log").appendToFile("2.log");
Logger.JavaLogger logger = new Logger.JavaLogger()
.appendToFile(tmp.newFile("1.log").getAbsolutePath())
.appendToFile(tmp.newFile("2.log").getAbsolutePath());
java.util.logging.Logger inner = getInnerLogger(logger);
assert (inner.getHandlers().length == 2);
}

@Test
public void testJavaLoggerInstantationWithLoggerName() throws Exception {
Logger.JavaLogger l1 = new Logger.JavaLogger("First client").appendToFile("1.log");
Logger.JavaLogger l2 = new Logger.JavaLogger("Second client").appendToFile("2.log");
Logger.JavaLogger l1 = new Logger.JavaLogger("First client")
.appendToFile(tmp.newFile("1.log").getAbsolutePath());
Logger.JavaLogger l2 = new Logger.JavaLogger("Second client")
.appendToFile(tmp.newFile("2.log").getAbsolutePath());
java.util.logging.Logger logger1 = getInnerLogger(l1);
assert (logger1.getHandlers().length == 1);
java.util.logging.Logger logger2 = getInnerLogger(l2);
Expand All @@ -44,8 +53,10 @@ public void testJavaLoggerInstantationWithLoggerName() throws Exception {

@Test
public void testJavaLoggerInstantationWithClazz() throws Exception {
Logger.JavaLogger l1 = new Logger.JavaLogger(String.class).appendToFile("1.log");
Logger.JavaLogger l2 = new Logger.JavaLogger(Integer.class).appendToFile("2.log");
Logger.JavaLogger l1 = new Logger.JavaLogger(String.class)
.appendToFile(tmp.newFile("1.log").getAbsolutePath());
Logger.JavaLogger l2 = new Logger.JavaLogger(Integer.class)
.appendToFile(tmp.newFile("2.log").getAbsolutePath());
java.util.logging.Logger logger1 = getInnerLogger(l1);
assert (logger1.getHandlers().length == 1);
java.util.logging.Logger logger2 = getInnerLogger(l2);
Expand Down
6 changes: 3 additions & 3 deletions core/src/test/java/feign/RetryerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import java.util.Collections;
import java.util.Date;
import feign.Retryer.Default;
Expand All @@ -29,7 +28,7 @@ public class RetryerTest {
public final ExpectedException thrown = ExpectedException.none();

private final static Request REQUEST = Request
.create(Request.HttpMethod.GET, "/", Collections.emptyMap(), null, Util.UTF_8);
.create(Request.HttpMethod.GET, "/", Collections.emptyMap(), null, Util.UTF_8);

@Test
public void only5TriesAllowedAndExponentialBackoff() throws Exception {
Expand Down Expand Up @@ -83,7 +82,8 @@ public void defaultRetryerFailsOnInterruptedException() {

Thread.currentThread().interrupt();
RetryableException expected =
new RetryableException(-1, null, null, new Date(System.currentTimeMillis() + 5000), REQUEST);
new RetryableException(-1, null, null, new Date(System.currentTimeMillis() + 5000),
REQUEST);
try {
retryer.continueOrPropagate(expected);
Thread.interrupted(); // reset interrupted flag in case it wasn't
Expand Down
7 changes: 3 additions & 4 deletions core/src/test/java/feign/client/DefaultClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.core.Is.isA;
import static org.junit.Assert.assertEquals;

import feign.Client.Proxied;
import java.io.IOException;
import java.net.HttpURLConnection;
Expand Down Expand Up @@ -116,9 +115,9 @@ public void canOverrideHostnameVerifier() throws IOException, InterruptedExcepti
new InetSocketAddress("proxy.example.com", 8080);

/**
* Test that the proxy is being used, but don't check the credentials. Credentials can still
* be used, but they must be set using the appropriate system properties and testing that is
* not what we are looking to do here.
* Test that the proxy is being used, but don't check the credentials. Credentials can still be
* used, but they must be set using the appropriate system properties and testing that is not what
* we are looking to do here.
*/
@Test
public void canCreateWithImplicitOrNoCredentials() throws Exception {
Expand Down
Loading

0 comments on commit e9543a6

Please sign in to comment.