@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 ); }
void addModules(InjectionManager injectionManager, TestDescriptor testDescriptor) throws MultiException { testDescriptor.getModules() .stream() .map(p -> ReflectionUtil.INSTANCE.newInstance(p.value())) .forEachOrdered(binder -> { if (binder instanceof Binder) { injectionManager.register((Binder) binder); } else { injectionManager.register(binder); } }); }
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 ); }
void addModules(ServiceLocator serviceLocator, TestDescriptor testDescriptor) throws MultiException { DynamicConfigurationService dcs = serviceLocator.getService(DynamicConfigurationService.class); DynamicConfiguration config = dcs.createDynamicConfiguration(); testDescriptor.getModules().stream() .map(p -> ReflectionUtil.INSTANCE.newInstance(p.value())) .map(Binder.class::cast) .forEachOrdered(binder -> { binder.bind(config); }); config.commit(); }
@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 ); }
ServerProvider createServerProvider(TestContext testContext, Application application) { Class<? extends ServerProvider> serverProviderType = application.serverProvider(); ServerProvider serverProvider; if (ServerProvider.class.equals(serverProviderType)) { String start = application.start(); String stop = application.stop(); if (!start.isEmpty() && !stop.isEmpty()) { serverProvider = new DefaultServerProvider(); } else { serverProvider = serviceLocatorUtil.getOne(serverProviderType); } } else { serverProvider = reflectionUtil.newInstance(serverProviderType); } testContext.addProperty(TestContextProperties.SERVER_PROVIDER, serverProvider); return serverProvider; }
@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 @SuppressWarnings("UseSpecificCatch") public ResourceConfig configure(TestContext testContext) { TestContextHolder.INSTANCE.set(testContext); TestDescriptor testDescriptor = testContext.getTestDescriptor(); Optional<Application> foundApplication = testDescriptor.getApplication(); ResourceConfig resourceConfig = null; if (foundApplication.isPresent()) { Application application = foundApplication.get(); resourceConfig = ReflectionUtil.INSTANCE.newInstance(application.value()); resourceConfig.setApplicationName(testContext.getName()); } return resourceConfig; }
@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 ); }
Module instance = (Module) ReflectionUtil.INSTANCE.newInstance(module.value());
@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 ); }