use of com.ibm.streamsx.rest.build.Toolkit in project streamsx.topology by IBMStreams.
the class ToolkitAPITest method testGetDependencies.
// Test getting the dependencies of a toolkit.
@Test
public void testGetDependencies() throws Exception {
// Games depends on both cards and bingo.
Toolkit bingo = connection.uploadToolkit(bingo0Path);
assertNotNull(bingo);
Toolkit cards = connection.uploadToolkit(cardsPath);
assertNotNull(cards);
Toolkit games = connection.uploadToolkit(gamesPath);
assertNotNull(games);
// bingo and cards have no dependencies
assertEquals(0, bingo.getDependencies().size());
assertEquals(0, cards.getDependencies().size());
List<Toolkit.Dependency> gamesDependencies = games.getDependencies();
assertEquals(2, gamesDependencies.size());
assertEquals(bingoToolkitName, gamesDependencies.get(0).getName());
assertEquals("[1.0.0,2.0.0)", gamesDependencies.get(0).getVersion());
assertEquals(cardsToolkitName, gamesDependencies.get(1).getName());
assertEquals("[1.0.0,1.1.0)", gamesDependencies.get(1).getVersion());
assertTrue(games.delete());
assertTrue(cards.delete());
assertTrue(bingo.delete());
}
use of com.ibm.streamsx.rest.build.Toolkit in project streamsx.topology by IBMStreams.
the class ToolkitAPITest method testPostMultipleVersions.
// Test posting different versions of a toolkit. Posting a version
// equal to one that is currently deployed should fail,
// but posting a different version should succeed.
@Test
public void testPostMultipleVersions() throws Exception {
List<Toolkit> toolkits = connection.getToolkits();
// First post version 1.0.1
Toolkit bingo1 = connection.uploadToolkit(bingo1Path);
assertNotNull(bingo1);
waitForToolkit(bingoToolkitName, Optional.of(bingo1Version));
// Post version 1.0.1 again. It should return Null
assertNull(connection.uploadToolkit(bingo1Path));
// Post verison 1.0.0. It should succeed as it does not match any
// existing version.
Toolkit bingo0 = connection.uploadToolkit(bingo0Path);
assertNotNull(bingo0);
waitForToolkit(bingoToolkitName, Optional.of(bingo0Version));
// Version 1.0.1 should still exist
assertToolkitExists(bingoToolkitName, Optional.of(bingo1Version));
assertToolkitNotExists(bingoToolkitName, Optional.of(bingo2Version));
// Post version 1.0.2. All three version continue to exist.
Toolkit bingo2 = connection.uploadToolkit(bingo2Path);
assertNotNull(bingo2);
waitForToolkit(bingoToolkitName, Optional.of(bingo2Version));
assertToolkitExists(bingoToolkitName, Optional.of(bingo0Version));
assertToolkitExists(bingoToolkitName, Optional.of(bingo1Version));
assertTrue(bingo0.delete());
assertTrue(bingo1.delete());
assertTrue(bingo2.delete());
}
use of com.ibm.streamsx.rest.build.Toolkit in project streamsx.topology by IBMStreams.
the class ToolkitAPITest method testDeleteToolkit.
@Test
public void testDeleteToolkit() throws Exception {
Toolkit bingo = connection.uploadToolkit(bingo0Path);
assertNotNull(bingo);
assertEquals(bingo.getName(), bingoToolkitName);
assertEquals(bingo.getVersion(), bingo0Version);
waitForToolkit(bingo.getName(), Optional.of(bingo.getVersion()));
// deleting once should succeed.
assertTrue(bingo.delete());
// Verify that it has been removed
assertToolkitNotExists(bingoToolkitName);
// deleting again should fail.
assertFalse(bingo.delete());
// RESTException if we try to get index on a deleted toolkit.
try {
bingo.getIndex();
fail("Expected RESTException");
} catch (RESTException e) {
}
// Post it again, then find it in the list of toolkits and delete
// it from the Toolkit object from the list.
bingo = connection.uploadToolkit(bingo0Path);
assertNotNull(bingo);
assertEquals(bingo.getName(), bingoToolkitName);
assertEquals(bingo.getVersion(), bingo0Version);
List<Toolkit> foundToolkits = findMatchingToolkits(bingoToolkitName, Optional.of(bingo0Version));
assertEquals(foundToolkits.size(), 1);
assertTrue(foundToolkits.get(0).delete());
}
use of com.ibm.streamsx.rest.build.Toolkit in project streamsx.topology by IBMStreams.
the class ToolkitAPITest method testGetTookit.
// Test getting a toolkit by id.
@Test
public void testGetTookit() throws Exception {
Toolkit bingo = connection.uploadToolkit(bingo1Path);
assertNotNull(bingo);
waitForToolkit(bingoToolkitName, Optional.of(bingo1Version));
Toolkit found = connection.getToolkit(bingo.getId());
assertNotNull(found);
assertEquals(bingoToolkitName, found.getName());
assertEquals(bingo1Version, found.getVersion());
assertEquals("4.2", found.getRequiredProductVersion());
assertEquals("toolkit", found.getResourceType());
// We don't know what value this attribute will have, but it should
// have a value
assertNotNull(found.getPath());
// The ID is 'streams-toolkits'/name-version
String toolkitId = "streams-toolkits/" + bingoToolkitName + "-" + bingo1Version;
found = connection.getToolkit(toolkitId);
assertNotNull(found);
// Using just the name fails
toolkitId = "streams-toolkits/" + bingoToolkitName;
try {
found = connection.getToolkit(toolkitId);
fail("Expected RESTException");
} catch (RESTException e) {
}
}
use of com.ibm.streamsx.rest.build.Toolkit in project streamsx.topology by IBMStreams.
the class ToolkitAPITest method testGetIndex.
@Test
public void testGetIndex() throws Exception {
Toolkit bingo = connection.uploadToolkit(bingo0Path);
assertNotNull(bingo);
assertEquals(bingoToolkitName, bingo.getName());
assertEquals(bingo0Version, bingo.getVersion());
String index = bingo.getIndex();
assertNotNull(index);
// try parsing the xml, and verify some of the content.
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
assertTrue(factory.isNamespaceAware());
DocumentBuilder builder = factory.newDocumentBuilder();
InputStream is = new ByteArrayInputStream(index.getBytes("UTF-8"));
Document doc = builder.parse(is);
NodeList toolkitModelElementList = doc.getDocumentElement().getElementsByTagNameNS("http://www.ibm.com/xmlns/prod/streams/spl/toolkit", "toolkit");
assertNotNull(toolkitModelElementList);
assertEquals(1, toolkitModelElementList.getLength());
Node toolkitElementNode = toolkitModelElementList.item(0);
assertTrue(toolkitElementNode.hasAttributes());
NamedNodeMap attributes = toolkitElementNode.getAttributes();
assertNotNull(attributes);
Node nameNode = attributes.getNamedItem("name");
assertNotNull(nameNode);
assertEquals(bingoToolkitName, nameNode.getNodeValue());
Node versionNode = attributes.getNamedItem("version");
assertNotNull(versionNode);
assertEquals(bingo0Version, versionNode.getNodeValue());
assertTrue(bingo.delete());
}
Aggregations