本文整理了Java中org.testifyproject.TestContext.getName()
方法的一些代码示例,展示了TestContext.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TestContext.getName()
方法的具体详情如下:
包路径:org.testifyproject.TestContext
类名称:TestContext
方法名:getName
[英]Get a unique name to identify the test context.
[中]获取唯一的名称以标识测试上下文。
代码示例来源:origin: org.testifyproject.resources/hsql
@Override
public JDBCDataSource configure(TestContext testContext, LocalResource localResource,
PropertiesReader configReader) {
JDBCDataSource dataSource = new JDBCDataSource();
dataSource.setUrl(format("jdbc:hsqldb:mem:%s?default_schema=public", testContext
.getName()));
dataSource.setUser("sa");
dataSource.setPassword("");
return dataSource;
}
代码示例来源:origin: org.testifyproject.local-resources/hsql
@Override
public JDBCDataSource configure(TestContext testContext, LocalResource localResource,
PropertiesReader configReader) {
JDBCDataSource dataSource = new JDBCDataSource();
dataSource.setUrl(format("jdbc:hsqldb:mem:%s?default_schema=public", testContext
.getName()));
dataSource.setUser("sa");
dataSource.setPassword("");
return dataSource;
}
代码示例来源:origin: org.testifyproject.junit4/jersey2-system-test
@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;
}
代码示例来源:origin: org.testifyproject.di/di-hk2
@Override
public ServiceLocator create(TestContext testContext) {
TestConfigurer testConfigurer = testContext.getTestConfigurer();
ServiceLocatorFactory locatorFactory = ServiceLocatorFactory.getInstance();
ServiceLocator serviceLocator = locatorFactory.create(testContext.getName());
return testConfigurer.configure(testContext, serviceLocator);
}
代码示例来源:origin: org.testifyproject.junit4/spring-boot-system-test
@Override
public ServerInstance<EmbeddedServletContainer> start(TestContext testContext,
Application application, SpringApplicationBuilder configuration) {
LoggingUtil.INSTANCE.debug("Starting Spring Boot application '{}'", testContext
.getName());
SpringApplication springApplication = configuration.build();
springApplication.run();
Optional<ServletContext> servletContext =
testContext.findProperty(SERVLET_CONTEXT);
Optional<EmbeddedServletContainer> servletContainer =
testContext.findProperty(SERVER);
if (servletContext.isPresent() && servletContainer.isPresent()) {
EmbeddedServletContainer server = servletContainer.get();
ServletContext context = servletContext.get();
String uri = format(DEFAULT_URI_FORMAT, server.getPort(), context
.getContextPath());
URI baseURI = URI.create(uri);
return ServerInstanceBuilder.builder()
.baseURI(baseURI)
.server(server)
.property(APP, springApplication)
.property(APP_NAME, testContext.getName())
.property(SERVER, server)
.build("springboot", application);
}
throw ExceptionUtil.INSTANCE.propagate(
"Could not start springboot application due to missing servlet container");
}
代码示例来源:origin: org.testifyproject.junit4/jersey2-system-test
@Override
public ServerInstance<HttpServer> start(TestContext testContext,
Application application, ResourceConfig resourceConfig) {
URI uri = URI.create(format(DEFAULT_URI_FORMAT, DEFAULT_SCHEME, DEFAULT_HOST,
DEFAULT_PORT, DEFAULT_PATH));
// create and start a new instance of grizzly http server
HttpServer server =
GrizzlyHttpServerFactory.createHttpServer(uri, resourceConfig, true);
Optional<NetworkListener> foundListener = server.getListeners()
.stream()
.findFirst();
ServerInstance serverInstance = null;
if (foundListener.isPresent()) {
NetworkListener networkListener = foundListener.get();
String host = networkListener.getHost();
int port = networkListener.getPort();
URI baseURI = URI.create(
format(DEFAULT_URI_FORMAT, DEFAULT_SCHEME, host, port, DEFAULT_PATH));
serverInstance = ServerInstanceBuilder.builder()
.baseURI(baseURI)
.server(server)
.property(APP, resourceConfig)
.property(APP_NAME, testContext.getName())
.property(SERVER, server)
.build("jersey", application);
}
return serverInstance;
}
代码示例来源:origin: org.testifyproject.virtual-resources/docker
? String.format("%s-%s", testContext.getName(), UUID
.randomUUID().toString())
: String.format("%s-%s", virtualResource.name(), UUID
} else {
containerName = virtualResource.name().isEmpty()
? String.format("%s-%d-%s", testContext.getName(), i, UUID
.randomUUID().toString())
: String.format("%s-%d-%s", virtualResource.name(), i,
代码示例来源:origin: org.testifyproject.server/undertow
String name = testContext.getName();
代码示例来源:origin: org.testifyproject.junit4/junit4-core
@Override
protected void runChild(final FrameworkMethod method, RunNotifier runNotifier) {
Description methodDescription = describeChild(method);
TestClass testClass = getTestClass();
Class<?> javaClass = testClass.getJavaClass();
TestifyJUnit4RunNotifier notifier = (TestifyJUnit4RunNotifier) runNotifier;
MDC.put(TEST_CLASS_KEY, javaClass.getSimpleName());
MDC.put(TEST_METHOD_KEY, method.getName());
if (isIgnored(method)) {
notifier.fireTestIgnored(methodDescription);
} else {
try {
runLeaf(methodBlock(method), methodDescription, notifier);
} catch (Exception e) {
notifier.addFailure(e);
notifier.pleaseStop();
} finally {
if (!isIgnored(method)) {
TestContextHolder.INSTANCE.command(testContext -> {
LoggingUtil.INSTANCE.debug("performing cleanup of '{}'",
testContext.getName());
TestRunner testRunner = testContext.getTestRunner();
testRunner.stop(testContext);
TestContextHolder.INSTANCE.remove();
});
}
}
}
}
代码示例来源:origin: org.testifyproject.di/di-spring
AnnotationConfigApplicationContext configContext =
(AnnotationConfigApplicationContext) applicationContext;
configContext.setId(testContext.getName());
configContext.setDisplayName(testContext.getName());
configContext.setAllowCircularReferences(false);
configContext.setAllowBeanDefinitionOverriding(true);
代码示例来源:origin: org.testifyproject.container/docker
void pullImage(VirtualResource virtualResource, String image, String imageName, String imageTag, TestContext testContext) {
RetryPolicy retryPolicy = new RetryPolicy()
.retryOn(Throwable.class)
.withBackoff(virtualResource.delay(), virtualResource.maxDelay(), virtualResource.unit())
.withMaxRetries(virtualResource.maxRetries());
Failsafe.with(retryPolicy)
.onRetry(throwable
-> LoggingUtil.INSTANCE.warn("Retrying pull request of image '{}'",
image, throwable)
)
.onFailure(throwable
-> LoggingUtil.INSTANCE.error("Image image '{}' could not be pulled: ", image, throwable))
.run(() -> {
try {
CountDownLatch latch = new CountDownLatch(1);
client.pullImageCmd(imageName)
.withTag(imageTag)
.exec(new PullCallback(virtualResource, latch));
ExceptionUtil.INSTANCE.raise(!latch.await(virtualResource.timeout(), virtualResource.unit()),
"Could not start virtual resource '{}' for test '{}'", imageName, testContext.getName()
);
} catch (InterruptedException e) {
LoggingUtil.INSTANCE.warn("Image '{}' pull request interrupted", image);
Thread.currentThread().interrupt();
}
});
}
代码示例来源:origin: org.testifyproject.junit4/spring-system-test
configuredContext.setId(testContext.getName());
configuredContext.setDisplayName(testContext.getName());
configuredContext.setAllowCircularReferences(false);
configuredContext.setAllowBeanDefinitionOverriding(true);
代码示例来源:origin: org.testifyproject.di/di-hk2
if (testContext.getName().equals(locatorName)) {
testContext.computeIfAbsent(SERVICE_INSTANCE, key -> {
TestDescriptor testDescriptor = testContext.getTestDescriptor();
内容来源于网络,如有侵权,请联系作者删除!