use of com.ibm.streamsx.rest.Instance in project streamsx.topology by IBMStreams.
the class StreamsOnlyConnectionTest method testGetInstances.
@Test
public void testGetInstances() throws Exception {
assumeNotNull(System.getenv("STREAMS_REST_URL"));
StreamsConnection connection = StreamsConnection.createInstance(null, null, null);
connection.allowInsecureHosts(true);
// get all instances in the domain
List<Instance> instances = connection.getInstances();
// there should be at least one instance
assertTrue(instances.size() > 0);
Instance i2;
String instanceName = System.getenv("STREAMS_INSTANCE_ID");
if (instanceName != null) {
i2 = connection.getInstance(instanceName);
assertEquals(instanceName, i2.getId());
i2.refresh();
assertEquals(instanceName, i2.getId());
} else {
i2 = instances.get(0);
}
List<ProcessingElement> instancePes = i2.getPes();
for (ProcessingElement pe : instancePes) {
assertNotNull(pe);
}
for (Instance instance : instances) StreamsConnectionTest.checkDomainFromInstance(instance);
try {
// try a fake instance name
connection.getInstance("fakeName");
fail("the connection.getInstance call should have thrown an exception");
} catch (RESTException r) {
// not a failure, this is the expected result
assertEquals(r.toString(), 404, r.getStatusCode());
}
}
Aggregations