IDE warnings fixes

pull/81/head
Dmitriy Dumanskiy 2018-07-29 17:51:16 +03:00 committed by Richard Körber
parent 8488bbf6dd
commit ff57bc224d
21 changed files with 42 additions and 54 deletions

View File

@ -105,7 +105,7 @@ public class Account extends AcmeJsonResource {
* fetched from the server. Each {@link Iterator} instance may provide the
* {@link Order} objects in a different order.
*/
public Iterator<Order> getOrders() throws AcmeException {
public Iterator<Order> getOrders() {
URL ordersUrl = getJSON().get(KEY_ORDERS).asURL();
return new ResourceIterator<>(getLogin(), KEY_ORDERS, ordersUrl, Login::bindOrder);
}
@ -127,7 +127,7 @@ public class Account extends AcmeJsonResource {
*
* @return {@link OrderBuilder} object
*/
public OrderBuilder newOrder() throws AcmeException {
public OrderBuilder newOrder() {
return new OrderBuilder(getLogin());
}

View File

@ -42,7 +42,7 @@ public enum RevocationReason {
private final int reasonCode;
private RevocationReason(int reasonCode) {
RevocationReason(int reasonCode) {
this.reasonCode = reasonCode;
}

View File

@ -32,7 +32,7 @@ public enum Resource {
private final String path;
private Resource(String path) {
Resource(String path) {
this.path = path;
}

View File

@ -59,7 +59,7 @@ public class AccountTest {
* Test that a account can be updated.
*/
@Test
public void testUpdateAccount() throws AcmeException, IOException, URISyntaxException {
public void testUpdateAccount() throws AcmeException, IOException {
TestableConnectionProvider provider = new TestableConnectionProvider() {
private JSON jsonResponse;

View File

@ -36,7 +36,7 @@ public class AcmeJsonResourceTest {
* Test {@link AcmeJsonResource#AcmeJsonResource(Login, URL)}.
*/
@Test
public void testLoginConstructor() throws Exception {
public void testLoginConstructor() {
Login login = TestUtils.login();
AcmeJsonResource resource = new DummyJsonResource(login, LOCATION_URL);
@ -55,7 +55,7 @@ public class AcmeJsonResourceTest {
* Test {@link AcmeJsonResource#setJSON(JSON)}.
*/
@Test
public void testSetJson() throws Exception {
public void testSetJson() {
Login login = TestUtils.login();
JSON jsonData2 = getJSON("requestOrderResponse");
@ -79,7 +79,7 @@ public class AcmeJsonResourceTest {
* Test {@link AcmeJsonResource#invalidate()}.
*/
@Test
public void testInvalidate() throws Exception {
public void testInvalidate() {
Login login = TestUtils.login();
AcmeJsonResource resource = new DummyJsonResource(login, LOCATION_URL);

View File

@ -63,7 +63,7 @@ public class AcmeResourceTest {
assertThat(challenge.getLogin(), is(login));
// Serialize it
byte[] serialized = null;
byte[] serialized;
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
try (ObjectOutputStream out = new ObjectOutputStream(baos)) {
out.writeObject(challenge);
@ -78,7 +78,7 @@ public class AcmeResourceTest {
}
// Deserialize to new object
DummyResource restored = null;
DummyResource restored;
try (ByteArrayInputStream bais = new ByteArrayInputStream(serialized);
ObjectInputStream in = new ObjectInputStream(bais)) {
Object obj = in.readObject();

View File

@ -101,7 +101,7 @@ public class AuthorizationTest {
}
@Override
public void handleRetryAfter(String message) throws AcmeException {
public void handleRetryAfter(String message) {
// Just do nothing
}
};
@ -146,7 +146,7 @@ public class AuthorizationTest {
}
@Override
public void handleRetryAfter(String message) throws AcmeException {
public void handleRetryAfter(String message) {
// Just do nothing
}
};
@ -190,7 +190,7 @@ public class AuthorizationTest {
}
@Override
public void handleRetryAfter(String message) throws AcmeException {
public void handleRetryAfter(String message) {
// Just do nothing
}
};

View File

@ -61,7 +61,7 @@ public class CertificateTest {
}
@Override
public List<X509Certificate> readCertificates() throws AcmeException {
public List<X509Certificate> readCertificates() {
return originalCert;
}
@ -140,7 +140,7 @@ public class CertificateTest {
}
@Override
public List<X509Certificate> readCertificates() throws AcmeException {
public List<X509Certificate> readCertificates() {
assertThat(certRequested, is(true));
return originalCert;
}
@ -187,7 +187,7 @@ public class CertificateTest {
}
@Override
public List<X509Certificate> readCertificates() throws AcmeException {
public List<X509Certificate> readCertificates() {
assertThat(certRequested, is(true));
return originalCert;
}

View File

@ -130,7 +130,7 @@ public class LoginTest {
Login login = new Login(location, keypair, session);
Challenge challenge = login.createChallenge(data);
assertThat(challenge, is(instanceOf(Http01Challenge.class)));
assertThat(challenge, is(sameInstance((Challenge) mockChallenge)));
assertThat(challenge, is(sameInstance(mockChallenge)));
verify(mockProvider).createChallenge(login, data);
}

View File

@ -26,7 +26,6 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Test;
import org.shredzone.acme4j.exception.AcmeException;
import org.shredzone.acme4j.provider.TestableConnectionProvider;
import org.shredzone.acme4j.toolbox.JSON;
import org.shredzone.acme4j.toolbox.JSONBuilder;
@ -57,7 +56,7 @@ public class OrderTest {
}
@Override
public void handleRetryAfter(String message) throws AcmeException {
public void handleRetryAfter(String message) {
assertThat(message, not(nullValue()));
}
};
@ -111,7 +110,7 @@ public class OrderTest {
}
@Override
public void handleRetryAfter(String message) throws AcmeException {
public void handleRetryAfter(String message) {
assertThat(message, not(nullValue()));
}
};
@ -165,7 +164,7 @@ public class OrderTest {
}
@Override
public void handleRetryAfter(String message) throws AcmeException {
public void handleRetryAfter(String message) {
assertThat(message, not(nullValue()));
}
};

View File

@ -43,7 +43,7 @@ public class SessionTest {
* Test constructor
*/
@Test
public void testConstructor() throws IOException {
public void testConstructor() {
URI serverUri = URI.create(TestUtils.ACME_SERVER_URI);
try {
@ -73,7 +73,7 @@ public class SessionTest {
* Test getters and setters.
*/
@Test
public void testGettersAndSetters() throws IOException {
public void testGettersAndSetters() {
URI serverUri = URI.create(TestUtils.ACME_SERVER_URI);
Session session = new Session(serverUri);

View File

@ -21,12 +21,10 @@ import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.time.Duration;
import java.time.Instant;
import org.jose4j.lang.JoseException;
import org.junit.Test;
import org.shredzone.acme4j.Login;
import org.shredzone.acme4j.Problem;
@ -50,7 +48,7 @@ public class ChallengeTest {
* Test that after unmarshaling, the challenge properties are set correctly.
*/
@Test
public void testUnmarshal() throws URISyntaxException {
public void testUnmarshal() {
Challenge challenge = new Challenge(TestUtils.login(), getJSON("genericChallenge"));
// Test unmarshalled values
@ -72,7 +70,7 @@ public class ChallengeTest {
* Test that {@link Challenge#prepareResponse(JSONBuilder)} contains the type.
*/
@Test
public void testRespond() throws JoseException {
public void testRespond() {
Challenge challenge = new Challenge(TestUtils.login(), getJSON("genericChallenge"));
JSONBuilder response = new JSONBuilder();
@ -85,7 +83,7 @@ public class ChallengeTest {
* Test that an exception is thrown on challenge type mismatch.
*/
@Test(expected = AcmeProtocolException.class)
public void testNotAcceptable() throws URISyntaxException {
public void testNotAcceptable() {
new Http01Challenge(TestUtils.login(), getJSON("dnsChallenge"));
}
@ -138,7 +136,7 @@ public class ChallengeTest {
}
@Override
public void handleRetryAfter(String message) throws AcmeException {
public void handleRetryAfter(String message) {
// Just do nothing
}
};

View File

@ -18,8 +18,6 @@ import static org.junit.Assert.assertThat;
import static org.shredzone.acme4j.toolbox.TestUtils.getJSON;
import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
import java.io.IOException;
import org.junit.Test;
import org.shredzone.acme4j.Login;
import org.shredzone.acme4j.Status;
@ -37,7 +35,7 @@ public class DnsChallengeTest {
* Test that {@link Dns01Challenge} generates a correct authorization key.
*/
@Test
public void testDnsChallenge() throws IOException {
public void testDnsChallenge() {
Dns01Challenge challenge = new Dns01Challenge(login, getJSON("dnsChallenge"));
assertThat(challenge.getType(), is(Dns01Challenge.TYPE));

View File

@ -18,8 +18,6 @@ import static org.junit.Assert.assertThat;
import static org.shredzone.acme4j.toolbox.TestUtils.getJSON;
import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
import java.io.IOException;
import org.junit.Test;
import org.shredzone.acme4j.Login;
import org.shredzone.acme4j.Status;
@ -42,7 +40,7 @@ public class HttpChallengeTest {
* Test that {@link Http01Challenge} generates a correct authorization key.
*/
@Test
public void testHttpChallenge() throws IOException {
public void testHttpChallenge() {
Http01Challenge challenge = new Http01Challenge(login, getJSON("httpChallenge"));
assertThat(challenge.getType(), is(Http01Challenge.TYPE));

View File

@ -18,8 +18,6 @@ import static org.junit.Assert.assertThat;
import static org.shredzone.acme4j.toolbox.TestUtils.getJSON;
import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
import java.io.IOException;
import org.junit.Test;
import org.shredzone.acme4j.Login;
import org.shredzone.acme4j.Status;
@ -42,7 +40,7 @@ public class TlsAlpn01ChallengeTest {
* Test that {@link TlsAlpn01Challenge} generates a correct authorization key.
*/
@Test
public void testTlsAlpn01Challenge() throws IOException {
public void testTlsAlpn01Challenge() {
TlsAlpn01Challenge challenge = new TlsAlpn01Challenge(login, getJSON("tlsAlpnChallenge"));
assertThat(challenge.getType(), is(TlsAlpn01Challenge.TYPE));

View File

@ -99,7 +99,7 @@ public class DefaultConnectionTest {
* {@code Replay-Nonce} header.
*/
@Test
public void testNoNonceFromHeader() throws AcmeException {
public void testNoNonceFromHeader() {
when(mockUrlConnection.getHeaderField("Replay-Nonce")).thenReturn(null);
assertThat(session.getNonce(), is(nullValue()));
@ -301,7 +301,7 @@ public class DefaultConnectionTest {
* Test that no Location header returns {@code null}.
*/
@Test
public void testNoLocation() throws Exception {
public void testNoLocation() {
try (DefaultConnection conn = new DefaultConnection(mockHttpConnection)) {
conn.conn = mockUrlConnection;
URL location = conn.getLocation();
@ -562,7 +562,7 @@ public class DefaultConnectionTest {
result.put("type", "urn:zombie:error:apocalypse");
result.put("detail", "Zombie apocalypse in progress");
return result.toJSON();
};
}
}) {
conn.sendSignedRequest(requestUrl, new JSONBuilder(), login);
fail("Expected to fail");
@ -598,7 +598,7 @@ public class DefaultConnectionTest {
@Override
public JSON readJsonResponse() {
return JSON.empty();
};
}
}) {
conn.sendSignedRequest(requestUrl, new JSONBuilder(), login);
fail("Expected to fail");
@ -676,7 +676,7 @@ public class DefaultConnectionTest {
try (DefaultConnection conn = new DefaultConnection(mockHttpConnection) {
@Override
public void resetNonce(Session session) throws AcmeException {
public void resetNonce(Session session) {
assertThat(session, is(sameInstance(DefaultConnectionTest.this.session)));
if (session.getNonce() == null) {
session.setNonce(nonce1);
@ -751,7 +751,7 @@ public class DefaultConnectionTest {
try (DefaultConnection conn = new DefaultConnection(mockHttpConnection) {
@Override
public void resetNonce(Session session) throws AcmeException {
public void resetNonce(Session session) {
assertThat(session, is(sameInstance(DefaultConnectionTest.this.session)));
if (session.getNonce() == null) {
session.setNonce(nonce1);

View File

@ -21,7 +21,6 @@ import static org.mockito.Mockito.*;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URISyntaxException;
import java.net.URL;
import org.junit.Test;
@ -38,7 +37,7 @@ public class HttpConnectorTest {
* This is just a mock to check that the parameters are properly set.
*/
@Test
public void testMockOpenConnection() throws IOException, URISyntaxException {
public void testMockOpenConnection() {
HttpURLConnection conn = mock(HttpURLConnection.class);
HttpConnector connector = new HttpConnector();

View File

@ -24,7 +24,6 @@ import org.junit.Test;
import org.shredzone.acme4j.Login;
import org.shredzone.acme4j.Session;
import org.shredzone.acme4j.challenge.Challenge;
import org.shredzone.acme4j.exception.AcmeException;
import org.shredzone.acme4j.provider.AcmeProvider;
import org.shredzone.acme4j.toolbox.JSON;
@ -88,7 +87,7 @@ public class SessionProviderTest {
}
@Override
public JSON directory(Session session, URI serverUri) throws AcmeException {
public JSON directory(Session session, URI serverUri) {
throw new UnsupportedOperationException();
}
@ -116,7 +115,7 @@ public class SessionProviderTest {
}
@Override
public JSON directory(Session session, URI serverUri) throws AcmeException {
public JSON directory(Session session, URI serverUri) {
throw new UnsupportedOperationException();
}

View File

@ -109,7 +109,7 @@ public class TestableConnectionProvider extends DummyConnection implements AcmeP
}
@Override
public JSON directory(Session session, URI serverUri) throws AcmeException {
public JSON directory(Session session, URI serverUri) {
if (directory.toMap().isEmpty()) {
throw new UnsupportedOperationException();
}

View File

@ -84,7 +84,7 @@ public class JSONBuilderTest {
JSONBuilder cb = new JSONBuilder();
cb.put("fooDate", date);
cb.put("fooNull", (Instant) null);
cb.put("fooNull", null);
assertThat(cb.toString(), is("{\"fooDate\":\"2016-06-01T03:13:46Z\",\"fooNull\":null}"));
}
@ -109,7 +109,7 @@ public class JSONBuilderTest {
*/
@Test
@SuppressWarnings("unchecked")
public void testKey() throws IOException, NoSuchAlgorithmException, JoseException {
public void testKey() throws IOException, JoseException {
KeyPair keyPair = TestUtils.createKeyPair();
JSONBuilder res;

View File

@ -36,7 +36,6 @@ import org.bouncycastle.asn1.x509.Extensions;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.asn1.x509.GeneralNames;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openssl.PEMException;
import org.bouncycastle.openssl.PEMParser;
import org.bouncycastle.pkcs.PKCS10CertificationRequest;
import org.hamcrest.BaseMatcher;
@ -158,7 +157,7 @@ public class CSRBuilderTest {
* Checks if the {@link CSRBuilder#write(java.io.Writer)} method generates a correct
* CSR PEM file.
*/
private void writerTest(CSRBuilder builder) throws IOException, PEMException {
private void writerTest(CSRBuilder builder) throws IOException {
// Write CSR to PEM
String pem;
try (StringWriter out = new StringWriter()) {