use of io.fabric8.utils.Block in project fabric8 by fabric8io.
the class ExampleTest method testDoubleAttribute.
@Test
public void testDoubleAttribute() throws Exception {
assertThat(client).doubleAttribute("java.lang:type=OperatingSystem", "SystemCpuLoad").isGreaterThanOrEqualTo(0.0);
assertAssertionError(new Block() {
@Override
public void invoke() throws Exception {
assertThat(client).doubleAttribute("java.lang:type=OperatingSystem", "SystemCpuLoad").isLessThan(-2000.0);
}
});
}
use of io.fabric8.utils.Block in project fabric8 by fabric8io.
the class JenkinsAsserts method assertWaitForNoRunningBuilds.
/**
* Asserts that we can trigger the job defined by the given path
*/
public static void assertWaitForNoRunningBuilds(JenkinsServer jenkins, long timeMillis) throws Exception {
LOG.info("Waiting for no running Jenkins jobs");
Asserts.assertWaitFor(timeMillis, new Block() {
@Override
public void invoke() throws Exception {
List<QueueItem> items = jenkins.getQueue().getItems();
assertTrue("Waiting for build queue to be empty but has " + items.size(), items.isEmpty());
}
});
}
use of io.fabric8.utils.Block in project fabric8 by fabric8io.
the class JenkinsAsserts method assertWaitForJobPathExists.
/**
* Waits for the given time period for the given job path to exist in Jenkins
*
* @return the job details
*/
public static JobWithDetails assertWaitForJobPathExists(final JenkinsServer jenkins, long timeMillis, String... jobPath) throws Exception {
final AtomicReference<JobWithDetails> holder = new AtomicReference<>(null);
LOG.info("Waiting for Jenkins job " + fullJobPath(jobPath));
Asserts.assertWaitFor(timeMillis, new Block() {
@Override
public void invoke() throws Exception {
holder.set(assertJobPathExists(jenkins, jobPath));
}
});
return holder.get();
}
use of io.fabric8.utils.Block in project fabric8 by fabric8io.
the class JenkinsAsserts method assertWaitForJobPathNotExist.
public static void assertWaitForJobPathNotExist(final JenkinsServer jenkins, long timeMillis, String... jobPath) throws Exception {
final String fullPath = fullJobPath(jobPath);
LOG.info("Waiting for Jenkins job to no longer exist " + fullPath);
Asserts.assertWaitFor(timeMillis, new Block() {
@Override
public void invoke() throws Exception {
assertTrue("Jenkins job " + fullPath + " should not exist", findJobPath(jenkins, jobPath) == null);
}
});
}
use of io.fabric8.utils.Block in project fabric8 by fabric8io.
the class BrokerProducerConsumerIT method testMQConsumer.
@Test
public void testMQConsumer() throws Exception {
assertThat(client).replicationController(brokerReplicationControllerId).isNotNull();
assertThat(client).replicationController(consumerReplicationControllerId).isNotNull();
assertThat(client).pods().runningStatus().filterNamespace(session.getNamespace()).haveAtLeast(1, new Condition<Pod>() {
@Override
public boolean matches(Pod podSchema) {
return true;
}
});
Asserts.assertWaitFor(10 * 60 * 1000, new Block() {
@Override
public void invoke() throws Exception {
J4pClient brokerClient = jolokiaClients.assertClientForReplicationController(brokerReplicationControllerId);
J4pClient consumerClient = jolokiaClients.assertClientForReplicationController(consumerReplicationControllerId);
assertThat(consumerClient).stringAttribute("org.apache.camel:context=camel-1,type=context,name=\"camel-1\"", "State").isEqualTo("Started");
assertThat(brokerClient).longAttribute("org.apache.activemq:type=Broker,brokerName=default,destinationType=Queue,destinationName=TEST.FOO", "EnqueueCount").isGreaterThan(1000);
assertThat(brokerClient).longAttribute("org.apache.activemq:type=Broker,brokerName=default,destinationType=Queue,destinationName=TEST.FOO", "DequeueCount").isGreaterThan(1000);
}
});
}
Aggregations