本文整理了Java中org.arquillian.cube.HostPort.value()
方法的一些代码示例,展示了HostPort.value()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HostPort.value()
方法的具体详情如下:
包路径:org.arquillian.cube.HostPort
类名称:HostPort
方法名:value
暂无
代码示例来源:origin: org.arquillian.cube/arquillian-cube-docker
private static int findEnrichedValueForFieldWithHostPortAnnotation(HostPort hostPort, HasPortBindings portBindings) {
int hostPortValue = hostPort.value();
if (hostPortValue == 0) {
throw new IllegalArgumentException(
String.format("%s annotation does not specify any exposed port", HostPort.class.getSimpleName()));
}
final HasPortBindings.PortAddress bindingForExposedPort = portBindings.getMappedAddress(hostPortValue);
if (bindingForExposedPort == null) {
throw new IllegalArgumentException(
String.format("exposed port %s is not exposed on container object.", hostPortValue));
}
return bindingForExposedPort.getPort();
}
代码示例来源:origin: arquillian/arquillian-cube
private static int findEnrichedValueForFieldWithHostPortAnnotation(HostPort hostPort, HasPortBindings portBindings) {
int hostPortValue = hostPort.value();
if (hostPortValue == 0) {
throw new IllegalArgumentException(
String.format("%s annotation does not specify any exposed port", HostPort.class.getSimpleName()));
}
final HasPortBindings.PortAddress bindingForExposedPort = portBindings.getMappedAddress(hostPortValue);
if (bindingForExposedPort == null) {
throw new IllegalArgumentException(
String.format("exposed port %s is not exposed on container object.", hostPortValue));
}
return bindingForExposedPort.getPort();
}
代码示例来源:origin: org.arquillian.cube/arquillian-cube-core
@Override
public void enrich(Object testCase) {
if (cubeRegistryInstance.get() != null) {
List<Field> fieldsWithAnnotation =
ReflectionUtil.getFieldsWithAnnotation(testCase.getClass(), HostPort.class);
for (Field dockerHostPortField : fieldsWithAnnotation) {
if (!dockerHostPortField.isAccessible()) {
dockerHostPortField.setAccessible(true);
}
if (int.class.isAssignableFrom(dockerHostPortField.getType()) || Integer.class.isAssignableFrom(
dockerHostPortField.getType())) {
try {
final HostPort hostPortAnnotation = dockerHostPortField.getAnnotation(HostPort.class);
String containerName = hostPortAnnotation.containerName();
int exposedPort = hostPortAnnotation.value();
int bindPort = getBindingPort(containerName, exposedPort);
if (bindPort > 0) {
dockerHostPortField.set(testCase, bindPort);
} else {
logger.log(Level.WARNING, String.format("There is no container with id %s.", containerName));
}
} catch (IllegalAccessException e) {
throw new IllegalArgumentException(e);
}
}
}
}
}
代码示例来源:origin: arquillian/arquillian-cube
@Override
public void enrich(Object testCase) {
if (cubeRegistryInstance.get() != null) {
List<Field> fieldsWithAnnotation =
ReflectionUtil.getFieldsWithAnnotation(testCase.getClass(), HostPort.class);
for (Field dockerHostPortField : fieldsWithAnnotation) {
if (!dockerHostPortField.isAccessible()) {
dockerHostPortField.setAccessible(true);
}
if (int.class.isAssignableFrom(dockerHostPortField.getType()) || Integer.class.isAssignableFrom(
dockerHostPortField.getType())) {
try {
final HostPort hostPortAnnotation = dockerHostPortField.getAnnotation(HostPort.class);
String containerName = hostPortAnnotation.containerName();
int exposedPort = hostPortAnnotation.value();
int bindPort = getBindingPort(containerName, exposedPort);
if (bindPort > 0) {
dockerHostPortField.set(testCase, bindPort);
} else {
logger.log(Level.WARNING, String.format("There is no container with id %s.", containerName));
}
} catch (IllegalAccessException e) {
throw new IllegalArgumentException(e);
}
}
}
}
}
代码示例来源:origin: arquillian/arquillian-cube
@Override
public Object[] resolve(Method method) {
Object[] values = new Object[method.getParameterTypes().length];
if (cubeRegistryInstance.get() != null) {
Integer[] annotatedParameters = annotatedParameters(method);
Class<?>[] parameterTypes = method.getParameterTypes();
for (Integer i : annotatedParameters) {
if (int.class.isAssignableFrom(parameterTypes[i]) || Integer.class.isAssignableFrom(parameterTypes[i])) {
final Annotation[] parameterAnnotations = method.getParameterAnnotations()[i];
final HostPort hostPortAnnotation = findHostPort(parameterAnnotations);
String containerName = hostPortAnnotation.containerName();
int exposedPort = hostPortAnnotation.value();
int bindPort = getBindingPort(containerName, exposedPort);
if (bindPort > 0) {
values[i] = bindPort;
} else {
logger.log(Level.WARNING, String.format("There is no container with id %s.", containerName));
}
}
}
}
return values;
}
代码示例来源:origin: org.arquillian.cube/arquillian-cube-core
@Override
public Object[] resolve(Method method) {
Object[] values = new Object[method.getParameterTypes().length];
if (cubeRegistryInstance.get() != null) {
Integer[] annotatedParameters = annotatedParameters(method);
Class<?>[] parameterTypes = method.getParameterTypes();
for (Integer i : annotatedParameters) {
if (int.class.isAssignableFrom(parameterTypes[i]) || Integer.class.isAssignableFrom(parameterTypes[i])) {
final Annotation[] parameterAnnotations = method.getParameterAnnotations()[i];
final HostPort hostPortAnnotation = findHostPort(parameterAnnotations);
String containerName = hostPortAnnotation.containerName();
int exposedPort = hostPortAnnotation.value();
int bindPort = getBindingPort(containerName, exposedPort);
if (bindPort > 0) {
values[i] = bindPort;
} else {
logger.log(Level.WARNING, String.format("There is no container with id %s.", containerName));
}
}
}
}
return values;
}
内容来源于网络,如有侵权,请联系作者删除!