本文整理了Java中org.testifyproject.TestContext.addProperty()
方法的一些代码示例,展示了TestContext.addProperty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TestContext.addProperty()
方法的具体详情如下:
包路径:org.testifyproject.TestContext
类名称:TestContext
方法名:addProperty
暂无
代码示例来源:origin: org.testifyproject.junit4/spring-boot-system-test
public EmbeddedServletContainer startEmbeddedServletContainer(
@SuperCall Callable<EmbeddedServletContainer> zuper) throws Exception {
EmbeddedServletContainer servletContainer = zuper.call();
TestContextHolder.INSTANCE.command((Consumer<TestContext>) testContext ->
testContext.addProperty(SERVER, servletContainer)
);
return servletContainer;
}
代码示例来源:origin: org.testifyproject.junit4/spring-boot-system-test
public ConfigurableApplicationContext run(
@SuperCall Callable<ConfigurableApplicationContext> zuper,
@This Object object,
@AllArguments Object[] args) throws Exception {
AnnotationConfigEmbeddedWebApplicationContext applicationContext =
(AnnotationConfigEmbeddedWebApplicationContext) zuper.call();
TestContextHolder.INSTANCE.command(testContext -> {
testContext.addProperty(APP, object);
if (args.length == 2) {
testContext.addProperty(APP_ARGUMENTS, args[1]);
}
});
return applicationContext;
}
代码示例来源:origin: org.testifyproject.junit4/grpc-system-test
@RuntimeType
@BindingPriority(Integer.MAX_VALUE)
public Object anyMethod(@SuperCall Callable<?> zuper,
@Origin Method method,
@This(optional = true) Object object)
throws Exception {
Object result = zuper.call();
if (method.getName().equals("start")) {
TestContextHolder.INSTANCE.command(testContext -> {
int port = ((Server) object).getPort();
testContext.addProperty(TestContextProperties.APP_PORT, port);
testContext.addProperty(TestContextProperties.SERVER, object);
URI baseURI = URI.create(format("grpc://localhost:%d", port));
testContext.addProperty(TestContextProperties.SERVER_BASE_URI, baseURI);
});
}
return result;
}
代码示例来源:origin: org.testifyproject.level/system
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;
}
代码示例来源:origin: org.testifyproject.junit4/spring-boot-system-test
public void prepareEmbeddedWebApplicationContext(@SuperCall Callable<Void> zuper,
@AllArguments Object[] args) throws Exception {
TestContextHolder.INSTANCE.command(testContext -> {
LoggingUtil.INSTANCE.setTextContext(testContext);
testContext.addProperty(SERVLET_CONTEXT, args[0]);
});
zuper.call();
}
代码示例来源:origin: org.testifyproject.level/system
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;
}
代码示例来源:origin: org.testifyproject.level/system
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;
}
代码示例来源:origin: org.testifyproject.level/system
void createClient(TestContext testContext, TestConfigurer testConfigurer,
ClientProvider clientProvider, Application application) {
URI baseURI = testContext.getProperty(TestContextProperties.SERVER_BASE_URI);
//configure and create the client
Object clientConfig = clientProvider.configure(testContext, application, baseURI);
clientConfig = testConfigurer.configure(testContext, clientConfig);
ClientInstance<Object, Object> clientInstance =
clientProvider.create(testContext, application, baseURI, clientConfig);
testContext
.addProperty(TestContextProperties.CLIENT_INSTANCE, clientInstance)
.addProperty(clientInstance.getFqn(), clientInstance.getProperties())
.addProperty(TestContextProperties.CLIENT, clientInstance
.getClient().getValue());
clientInstance.getClientSupplier()
.map(Instance::getValue)
.ifPresent(value -> {
testContext.addProperty(TestContextProperties.CLIENT_SUPPLIER, value);
});
}
代码示例来源:origin: org.testifyproject.di/di-guice
testContext.addProperty(TestContextProperties.SERVICE_INSTANCE, serviceInstance);
代码示例来源:origin: org.testifyproject.server/undertow
.getOne(ApplicationProvider.class);
ApplicationInstance applicationInstance = applicationProvider.start(testContext);
testContext.addProperty(APPLICATION_INSTANCE, applicationInstance);
代码示例来源:origin: org.testifyproject.junit4/junit4-core
SutDescriptor sutDescriptor =
AnalyzerUtil.INSTANCE.analyzeSutField(sutField.get());
testContext.addProperty(TestContextProperties.SUT_DESCRIPTOR, sutDescriptor);
代码示例来源:origin: org.testifyproject.level/unit
testContext.addProperty(SERVICE_INSTANCE, serviceInstance);
代码示例来源:origin: org.testifyproject.level/system
void createServer(TestContext testContext, TestConfigurer testConfigurer,
ServerProvider serverProvider, Application application)
throws Exception {
//configure and start the server
Object serverConfig = serverProvider.configure(testContext);
serverConfig = testConfigurer.configure(testContext, serverConfig);
ServerInstance serverInstance =
serverProvider.start(testContext, application, serverConfig);
testContext
.addProperty(TestContextProperties.SERVER_INSTANCE, serverInstance)
.addProperty(serverInstance.getFqn(), serverInstance.getProperties())
.addProperty(TestContextProperties.SERVER_BASE_URI, serverInstance.getBaseURI())
.addProperty(TestContextProperties.SERVER, serverInstance
.getServer().getValue());
}
代码示例来源:origin: org.testifyproject.level/integration
testConfigurer.configure(testContext, serviceContext);
ServiceInstance serviceInstance = serviceProvider.configure(testContext, serviceContext);
testContext.addProperty(SERVICE_INSTANCE, serviceInstance);
内容来源于网络,如有侵权,请联系作者删除!