<T> T getFieldValue(Field field, Object instance) { return AccessController.doPrivileged((PrivilegedAction<T>) () -> { try { field.setAccessible(true); return (T) field.get(instance); } catch (IllegalAccessException | IllegalArgumentException | SecurityException e) { throw ExceptionUtil.INSTANCE.propagate(e); } }); }
Optional<Field> findField(Class<?> type, String name) { try { return of(type.getDeclaredField(name)); } catch (NoSuchFieldException | SecurityException e) { LoggingUtil.INSTANCE.debug("Could not find field '{}' in type '{}'", name, type.getSimpleName(), e); return empty(); } }
@Override public void fireTestIgnored(Description description) { LoggingUtil.INSTANCE.warn("Test ignored"); runNotifier.fireTestIgnored(description); }
ClientProvider createClientProvider(TestContext testContext, Application application) { //create client supplier instance Class<? extends ClientProvider> clientProviderType = application.clientProvider(); ClientProvider clientProvider; if (clientProviderType.equals(ClientProvider.class)) { clientProvider = serviceLocatorUtil.getOne(clientProviderType); } else { clientProvider = reflectionUtil.newInstance(clientProviderType); } testContext.addProperty(TestContextProperties.CLIENT_PROVIDER, clientProvider); return clientProvider; }
@Override public void verify(TestContext testContext) { String className = "org.springframework.context.ApplicationContext"; Optional<Class> foundClass = ReflectionUtil.INSTANCE.load(className); testContext.addError( !foundClass.isPresent(), "Please insure Spring Application Context class '{}' is in the classpath", className ); }
@Override public void onError(Throwable throwable) { LoggingUtil.INSTANCE.error("Image '{}:{}' pull failed: ", virtualResource.value(), virtualResource.version(), throwable); latch.countDown(); }
@Override public void onStart(Closeable closeable) { LoggingUtil.INSTANCE.info("Pulling '{}:{}' image", virtualResource.value(), virtualResource.version()); }
TestRunner getTestRunner() throws AssertionError { return ServiceLocatorUtil.INSTANCE .getOneWithFilter(TestRunner.class, testSettings.getTestCategory()); }
@Override public void fireTestFinished(Description description) { LoggingUtil.INSTANCE.debug("Test finished"); runNotifier.fireTestFinished(description); }
@Override public void verify(TestContext testContext) { String className = "org.glassfish.jersey.server.ResourceConfig"; Optional<Class> foundClass = ReflectionUtil.INSTANCE.load(className); testContext.addError( !foundClass.isPresent(), "Please insure Jersey 2 class '{}' is in the classpath", className ); }
@Override public void onComplete() { LoggingUtil.INSTANCE.info("Image '{}:{}' pulled", virtualResource.value(), virtualResource.version()); latch.countDown(); }
@Override public void fireTestStarted(Description description) { LoggingUtil.INSTANCE.debug("Test started"); runNotifier.fireTestStarted(description); }
@Override public void verify(TestContext testContext) { String className = "org.glassfish.jersey.inject.hk2.AbstractHk2InjectionManager"; Optional<Class> foundClass = ReflectionUtil.INSTANCE.load(className); testContext.addError( !foundClass.isPresent(), "Please insure Jersey HK2 class '{}' is in the classpath", className ); }
@Override public void close() throws IOException { LoggingUtil.INSTANCE.debug("Closing pull of '{}:{}' image", virtualResource.value(), virtualResource.version()); }
@Override public void verify(TestContext testContext) { String className = "com.google.inject.Guice"; Optional<Class> foundClass = ReflectionUtil.INSTANCE.load(className); testContext.addError( !foundClass.isPresent(), "Please insure Guice class '{}' is in the classpath", className ); }
@Override public void stop(ServerInstance<EmbeddedServletContainer> serverInstance) { if (serverInstance != null) { serverInstance.command((container, baseURI) -> { LoggingUtil.INSTANCE.debug("Stopping Spring Boot server"); container.stop(); }); } }
@Override public void verify(TestContext testContext) { String className = "org.springframework.web.WebApplicationInitializer"; Optional<Class> foundClass = ReflectionUtil.INSTANCE.load(className); testContext.addError( !foundClass.isPresent(), "Please insure Spring Web MVC class '{}' is in the classpath", className ); }
public void awaitTermination(@SuperCall Callable<?> zuper, @AllArguments Object[] args) throws InterruptedException { //for testing purpose trap calls for waitawaitTermination and do nothing LoggingUtil.INSTANCE.debug("awaitTermination intercepted and trapped"); } }
@Override public void verify(TestContext testContext) { String className = "org.glassfish.hk2.api.ServiceLocator"; Optional<Class> foundClass = ReflectionUtil.INSTANCE.load(className); testContext.addError( !foundClass.isPresent(), "Please insure HK2 class '{}' is in the classpath", className ); }
@Override public void verify(TestContext testContext) { String className = "org.springframework.boot.env.EnvironmentPostProcessor"; Optional<Class> foundClass = ReflectionUtil.INSTANCE.load(className); testContext.addError( !foundClass.isPresent(), "Please insure SpringBoot class '{}' is in the classpath", className ); }