use of com.ibm.streamsx.rest.StreamsConnection in project streamsx.topology by IBMStreams.
the class AppBundleTest method getInstance.
protected Instance getInstance() throws IOException {
assumeNotNull(System.getenv("STREAMS_REST_URL"));
StreamsConnection sc = StreamsConnection.createInstance(null, null, null);
sc.allowInsecureHosts(true);
List<Instance> instances = sc.getInstances();
if (instances.size() == 1)
return instances.get(0);
return sc.getInstance(System.getenv("STREAMS_INSTANCE_ID"));
}
use of com.ibm.streamsx.rest.StreamsConnection 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