Fix Java 17 compilation and test issues (#12353)
* Adds --add-opens to the surefire-maven-plugin config required for deserialization using Gson/XStream * Upgrades plugin dependencies to JDK 17 compatible versions * Replaces some reflection that no longer works on JDK 17 * Fixes issues when mocking Random * Run Nashorn dependant tests only on JDK < 15 Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
@@ -27,7 +27,6 @@ import org.openhab.binding.mielecloud.internal.handler.MieleBridgeHandler;
|
||||
import org.openhab.binding.mielecloud.internal.handler.MieleHandlerFactory;
|
||||
import org.openhab.binding.mielecloud.internal.util.AbstractConfigFlowTest;
|
||||
import org.openhab.binding.mielecloud.internal.util.MieleCloudBindingIntegrationTestConstants;
|
||||
import org.openhab.binding.mielecloud.internal.util.ReflectionUtil;
|
||||
import org.openhab.binding.mielecloud.internal.util.Website;
|
||||
import org.openhab.binding.mielecloud.internal.util.WebsiteCrawler;
|
||||
import org.openhab.binding.mielecloud.internal.webservice.MieleWebservice;
|
||||
@@ -124,7 +123,7 @@ public class ConfigFlowTest extends AbstractConfigFlowTest {
|
||||
public void configFlowWaitTimeoutExpiresWhenBridgeDoesNotComeOnline() throws Exception {
|
||||
// given:
|
||||
setUpAuthorizationHandler();
|
||||
ReflectionUtil.setPrivateStaticFinal(CreateBridgeServlet.class, "ONLINE_WAIT_TIMEOUT_IN_MILLISECONDS", 0);
|
||||
getCreateBridgeServlet().setOnlineWaitTimeoutInMilliseconds(0);
|
||||
|
||||
// when:
|
||||
configureBridgeWithConfigFlow();
|
||||
|
||||
@@ -15,7 +15,6 @@ package org.openhab.binding.mielecloud.internal.util;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
@@ -80,29 +79,6 @@ public final class ReflectionUtil {
|
||||
field.set(object, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an attribute declared as {@code private static final}.
|
||||
*
|
||||
* @param clazz The class owning the static attribute.
|
||||
* @param fieldName The name of the attribute.
|
||||
* @param value The new value.
|
||||
* @throws NoSuchFieldException if no field with the given name exists.
|
||||
* @throws SecurityException if the operation is not allowed.
|
||||
* @throws IllegalArgumentException if one of the passed parameters is invalid.
|
||||
* @throws IllegalAccessException if the field is enforcing Java language access control and is inaccessible.
|
||||
*/
|
||||
public static void setPrivateStaticFinal(Class<?> clazz, String fieldName, @Nullable Object value)
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
Field field = clazz.getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
|
||||
Field modifiersField = Field.class.getDeclaredField("modifiers");
|
||||
modifiersField.setAccessible(true);
|
||||
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
|
||||
|
||||
field.set(null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes a private method on an object.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user