|
|
|
@ -149,10 +149,6 @@ import org.thingsboard.server.service.security.auth.rest.LoginRequest; |
|
|
|
import org.thingsboard.server.service.security.model.token.JwtTokenFactory; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.lang.invoke.MethodHandles; |
|
|
|
import java.lang.invoke.VarHandle; |
|
|
|
import java.lang.reflect.Field; |
|
|
|
import java.lang.reflect.Modifier; |
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.util.ArrayList; |
|
|
|
@ -1053,33 +1049,6 @@ public abstract class AbstractWebTest extends AbstractInMemoryStorageTest { |
|
|
|
throw new AssertionError("Unexpected status " + mvcResult.getResponse().getStatus()); |
|
|
|
} |
|
|
|
|
|
|
|
protected static <T> T getFieldValue(Object target, String fieldName) throws Exception { |
|
|
|
Field field = target.getClass().getDeclaredField(fieldName); |
|
|
|
field.setAccessible(true); |
|
|
|
return (T) field.get(target); |
|
|
|
} |
|
|
|
|
|
|
|
protected static void setStaticFieldValue(Class<?> targetCls, String fieldName, Object value) throws Exception { |
|
|
|
Field field = targetCls.getDeclaredField(fieldName); |
|
|
|
field.setAccessible(true); |
|
|
|
field.set(null, value); |
|
|
|
} |
|
|
|
|
|
|
|
protected static void setStaticFinalFieldValue(Class<?> targetCls, String fieldName, Object value) throws Exception { |
|
|
|
Field field = targetCls.getDeclaredField(fieldName); |
|
|
|
field.setAccessible(true); |
|
|
|
// Get the VarHandle for the 'modifiers' field in the Field class
|
|
|
|
MethodHandles.Lookup lookup = MethodHandles.privateLookupIn(Field.class, MethodHandles.lookup()); |
|
|
|
VarHandle modifiersHandle = lookup.findVarHandle(Field.class, "modifiers", int.class); |
|
|
|
|
|
|
|
// Remove the final modifier from the field
|
|
|
|
int currentModifiers = field.getModifiers(); |
|
|
|
modifiersHandle.set(field, currentModifiers & ~Modifier.FINAL); |
|
|
|
|
|
|
|
// Set the new value
|
|
|
|
field.set(null, value); |
|
|
|
} |
|
|
|
|
|
|
|
protected int getDeviceActorSubscriptionCount(DeviceId deviceId, FeatureType featureType) { |
|
|
|
DeviceActorMessageProcessor processor = getDeviceActorProcessor(deviceId); |
|
|
|
Map<UUID, SessionInfo> subscriptions = (Map<UUID, SessionInfo>) ReflectionTestUtils.getField(processor, getMapName(featureType)); |
|
|
|
|