Fix Java and Jetty deprecations (#10349)

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born
2021-03-19 10:40:14 +01:00
committed by GitHub
parent 580f293766
commit fe0c35d22f
43 changed files with 98 additions and 80 deletions

View File

@@ -14,6 +14,7 @@ package org.openhab.binding.robonect.internal;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@@ -25,7 +26,6 @@ import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.util.B64Code;
import org.openhab.binding.robonect.internal.model.ErrorList;
import org.openhab.binding.robonect.internal.model.ModelParser;
import org.openhab.binding.robonect.internal.model.MowerInfo;
@@ -177,8 +177,9 @@ public class RobonectClient {
private void addPreemptiveAuthentication(HttpClient httpClient, RobonectEndpoint endpoint) {
AuthenticationStore auth = httpClient.getAuthenticationStore();
URI uri = URI.create(baseUrl);
auth.addAuthenticationResult(new BasicResult(HttpHeader.AUTHORIZATION, uri, "Basic "
+ B64Code.encode(endpoint.getUser() + ":" + endpoint.getPassword(), StandardCharsets.ISO_8859_1)));
auth.addAuthenticationResult(
new BasicResult(HttpHeader.AUTHORIZATION, uri, "Basic " + Base64.getEncoder().encodeToString(
(endpoint.getUser() + ":" + endpoint.getPassword()).getBytes(StandardCharsets.ISO_8859_1))));
}
/**

View File

@@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test;
/**
* The goal of this class is to test the model parser to make sure the structures
* returned from the module can be handled.
*
*
* @author Marco Meyer - Initial contribution
*/
public class ModelParserTest {
@@ -48,12 +48,12 @@ public class ModelParserTest {
String correctModel = "{\"successful\": false, \"error_code\": 7, \"error_message\": \"Automower already stopped\"}";
RobonectAnswer answer = subject.parse(correctModel, RobonectAnswer.class);
assertFalse(answer.isSuccessful());
assertEquals(new Integer(7), answer.getErrorCode());
assertEquals(Integer.valueOf(7), answer.getErrorCode());
assertEquals("Automower already stopped", answer.getErrorMessage());
MowerInfo info = subject.parse(correctModel, MowerInfo.class);
assertFalse(info.isSuccessful());
assertEquals(new Integer(7), info.getErrorCode());
assertEquals(Integer.valueOf(7), info.getErrorCode());
assertEquals("Automower already stopped", info.getErrorMessage());
}
@@ -143,7 +143,7 @@ public class ModelParserTest {
assertTrue(mowerInfo.getStatus().isStopped());
assertNotNull(mowerInfo.getError());
assertEquals("Mein Automower ist angehoben", mowerInfo.getError().getErrorMessage());
assertEquals(new Integer(15), mowerInfo.getError().getErrorCode());
assertEquals(Integer.valueOf(15), mowerInfo.getError().getErrorCode());
assertEquals("02.05.2017", mowerInfo.getError().getDate());
assertEquals("20:36:43", mowerInfo.getError().getTime());
assertEquals("1493757403", mowerInfo.getError().getUnix());
@@ -155,7 +155,7 @@ public class ModelParserTest {
ErrorList errorList = subject.parse(errorsListResponse, ErrorList.class);
assertTrue(errorList.isSuccessful());
assertEquals(10, errorList.getErrors().size());
assertEquals(new Integer(15), errorList.getErrors().get(0).getErrorCode());
assertEquals(Integer.valueOf(15), errorList.getErrors().get(0).getErrorCode());
assertEquals("Grasi ist angehoben", errorList.getErrors().get(0).getErrorMessage());
assertEquals("02.05.2017", errorList.getErrors().get(0).getDate());
assertEquals("20:36:43", errorList.getErrors().get(0).getTime());