ServiceInstance createService(TestContext testContext, TestDescriptor testDescriptor, TestConfigurer testConfigurer) { ServiceInstance serviceInstance; Optional<ServiceInstance> foundServiceInstance = testContext.<ServiceInstance>findProperty(SERVICE_INSTANCE); if (foundServiceInstance.isPresent()) { serviceInstance = foundServiceInstance.get(); } else { ServiceProvider serviceProvider = serviceLocatorUtil.getFromHintOrDefault( testContext, ServiceProvider.class, DefaultServiceProvider.class, Hint::serviceProvider); Object serviceContext = serviceProvider.create(testContext); testConfigurer.configure(testContext, serviceContext); serviceInstance = serviceProvider.configure(testContext, serviceContext); testContext.addProperty(SERVICE_INSTANCE, serviceInstance); serviceProvider.postConfigure(testContext, serviceInstance); } return serviceInstance; }
public void refresh(@SuperCall Callable<Void> zuper, @Argument(0) ApplicationContext applicationContext) throws Exception { ConfigurableApplicationContext configurableApplicationContext = (ConfigurableApplicationContext) applicationContext; TestContextHolder.INSTANCE.command(testContext -> { testContext.computeIfAbsent(SERVICE_INSTANCE, key -> { ServiceProvider<ConfigurableApplicationContext> serviceProvider = ServiceLocatorUtil.INSTANCE.getOne(ServiceProvider.class, SpringServiceProvider.class); return serviceProvider.configure(testContext, configurableApplicationContext); }); }); zuper.call(); }
public void initialize(@SuperCall Callable<Void> zuper, @Argument(0) Object applicationConfigurator, @Argument(1) InjectionManager injectionManager, @Argument(2) Binder customBinder) throws Exception { zuper.call(); TestContextHolder.INSTANCE.command(testContext -> { if (SystemCategory.class.equals(testContext.getTestCategory())) { testContext.computeIfAbsent(SERVICE_INSTANCE, key -> { ServiceProvider<InjectionManager> serviceProvider = ServiceLocatorUtil.INSTANCE.getOne(ServiceProvider.class, JerseyServiceProvider.class); return serviceProvider.configure(testContext, injectionManager); }); } }); }
Hint::serviceProvider); Object serviceContext = serviceProvider.create(testContext); testConfigurer.configure(testContext, serviceContext); serviceProvider.configure(testContext, serviceContext); testContext.addProperty(SERVICE_INSTANCE, serviceInstance); serviceProvider.postConfigure(testContext, serviceInstance);
SpringServiceProvider.class); return serviceProvider.configure(testContext, configuredApplicationContext); }); });
.getOne(ServiceProvider.class, HK2ServiceProvider.class); return serviceProvider.configure(testContext, serviceLocator); });
SpringServiceProvider.class); return serviceProvider.configure(testContext, configuredApplicationContext); }); });