use of com.consol.citrus.exceptions.CitrusRuntimeException in project camelinaction2 by camelinaction.
the class CitrusIT method stopAndWaitForGracefulShutdown.
/**
* Stop and wait for graceful shutdown of Camel context before closing the test.
*/
private void stopAndWaitForGracefulShutdown() {
// stop the Camel context with custom test action.
action(new AbstractTestAction() {
@Override
public void doExecute(TestContext context) {
try {
orderService.stop();
} catch (Exception e) {
throw new CitrusRuntimeException("Failed to stop Camel context");
}
}
});
waitFor().condition(new AbstractCondition() {
@Override
public boolean isSatisfied(TestContext context) {
return orderService.isStopped();
}
@Override
public String getSuccessMessage(TestContext context) {
return "Successfully stopped Camel context";
}
@Override
public String getErrorMessage(TestContext context) {
return "Failed to stop Camel context";
}
});
}
use of com.consol.citrus.exceptions.CitrusRuntimeException in project syndesis by syndesisio.
the class FtpTestSupport method setupFtpUserHome.
@BeforeClass
public static void setupFtpUserHome() {
try {
Path publicUserDir = getFtpUserHome().resolve("public");
if (Files.exists(publicUserDir)) {
try (Stream<Path> files = Files.walk(publicUserDir)) {
files.forEach(path -> {
try {
Files.delete(path);
} catch (IOException e) {
LOG.warn("Failed to delete file", e);
}
});
}
} else {
Files.createDirectories(publicUserDir);
}
Files.copy(new ClassPathResource("todo.json", FtpToDB_IT.class).getFile().toPath(), publicUserDir.resolve("todo.json"));
} catch (IOException e) {
throw new CitrusRuntimeException("Failed to setup files in ftp user home directory", e);
}
}
use of com.consol.citrus.exceptions.CitrusRuntimeException in project citrus-samples by christophd.
the class ClearUserHomeDirAction method doExecute.
@Override
public void doExecute(TestContext context) {
try {
if (Files.exists(Paths.get(new FileSystemResource(userHomePath).getURI()))) {
Files.walkFileTree(Paths.get(new FileSystemResource(userHomePath).getURI()), new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.deleteIfExists(file);
return FileVisitResult.CONTINUE;
}
});
Files.deleteIfExists(Paths.get(new FileSystemResource(userHomePath).getURI()));
}
} catch (IOException e) {
throw new CitrusRuntimeException("Failed to delete user home directory", e);
}
}
use of com.consol.citrus.exceptions.CitrusRuntimeException in project yaks by citrusframework.
the class VerifyIntegrationAction method verifyIntegrationPod.
/**
* Wait for given pod to be in given state.
* @param name
* @param phase
* @param namespace
* @return
*/
private Pod verifyIntegrationPod(String name, String phase, String namespace) {
for (int i = 0; i < maxAttempts; i++) {
Pod pod = getIntegrationPod(name, phase, namespace);
if (pod != null) {
LOG.info(String.format("Verified integration pod '%s' state '%s'!", name, phase));
return pod;
}
LOG.warn(String.format("Waiting for integration '%s' in state '%s'- retry in %s ms", name, phase, delayBetweenAttempts));
try {
Thread.sleep(delayBetweenAttempts);
} catch (InterruptedException e) {
LOG.warn("Interrupted while waiting for integration pod state", e);
}
}
throw new ActionTimeoutException((maxAttempts * delayBetweenAttempts), new CitrusRuntimeException(String.format("Failed to verify integration '%s' - " + "is not in state '%s' after %d attempts", name, phase, maxAttempts)));
}
use of com.consol.citrus.exceptions.CitrusRuntimeException in project yaks by citrusframework.
the class CreateKameletAction method createKamelet.
private void createKamelet(TestContext context) {
final Kamelet kamelet;
if (resource != null) {
try {
String resolvedSource;
if (supportVariables) {
resolvedSource = context.replaceDynamicContentInString(FileUtils.readToString(resource));
} else {
resolvedSource = FileUtils.readToString(resource);
}
kamelet = KubernetesSupport.yaml().loadAs(resolvedSource, Kamelet.class);
} catch (IOException e) {
throw new CitrusRuntimeException(String.format("Failed to load Kamelet from resource %s", name + ".kamelet.yaml"));
}
} else {
if (definition.getTitle() != null) {
definition.setTitle(context.replaceDynamicContentInString(definition.getTitle()));
}
if (definition.getDescription() != null) {
definition.setDescription(context.replaceDynamicContentInString(definition.getDescription()));
}
definition.setProperties(context.resolveDynamicValuesInMap(definition.getProperties()));
definition.setRequired(context.resolveDynamicValuesInList(definition.getRequired()));
final Kamelet.Builder builder = new Kamelet.Builder().name(context.replaceDynamicContentInString(name)).definition(definition);
if (template != null) {
builder.template(context.replaceDynamicContentInString(template));
}
if (source != null) {
builder.source(source.getName(), context.replaceDynamicContentInString(source.getContent()));
}
if (dependencies != null && !dependencies.isEmpty()) {
builder.dependencies(context.resolveDynamicValuesInList(dependencies));
}
if (types != null && !types.isEmpty()) {
builder.types(context.resolveDynamicValuesInMap(types));
}
kamelet = builder.build();
}
if (LOG.isDebugEnabled()) {
try {
LOG.debug(KubernetesSupport.json().writeValueAsString(kamelet));
} catch (JsonProcessingException e) {
LOG.warn("Unable to dump Kamelet data", e);
}
}
CustomResourceDefinitionContext ctx = CamelKSupport.kameletCRDContext(CamelKSettings.getKameletApiVersion());
getKubernetesClient().customResources(ctx, Kamelet.class, KameletList.class).inNamespace(namespace(context)).createOrReplace(kamelet);
LOG.info(String.format("Successfully created Kamelet '%s'", kamelet.getMetadata().getName()));
}
Aggregations