/**
* Tests that parameterized bindings from one request aren't available in subsequent ones
*/
@Test
public void testBindingsDontStickAroundAfterRequests() throws Exception {
final RexsterClient client = getClient();
//create a session
for (Map.Entry<String, Map<String,String>> entry : getAvailableGraphs(client).entrySet()) {
final SessionRequestMessage outMsg = new SessionRequestMessage();
outMsg.setRequestAsUUID(UUID.randomUUID());
outMsg.metaSetGraphName(entry.getKey());
RexProMessage inMsg = client.execute(outMsg);
Assert.assertNotNull(inMsg.Session);
Assert.assertTrue(inMsg instanceof SessionResponseMessage);
UUID sessionKey = BitWorks.convertByteArrayToUUID(inMsg.Session);
SimpleBindings b = new SimpleBindings();
b.put("o", 5);
final ScriptRequestMessage scriptMessage = new ScriptRequestMessage();
scriptMessage.Script = "o";
scriptMessage.Bindings.put("o", 5);
scriptMessage.LanguageName = "groovy";
scriptMessage.metaSetInSession(true);
scriptMessage.setRequestAsUUID(UUID.randomUUID());
scriptMessage.setSessionAsUUID(sessionKey);
inMsg = client.execute(scriptMessage);
Assert.assertTrue(inMsg instanceof ScriptResponseMessage);
Assert.assertTrue(((ScriptResponseMessage) inMsg).Results.get() != null);
final ScriptRequestMessage scriptMessage2 = new ScriptRequestMessage();
scriptMessage2.Script = "o";
scriptMessage2.LanguageName = "groovy";
scriptMessage2.metaSetInSession(true);
scriptMessage2.setRequestAsUUID(UUID.randomUUID());
scriptMessage2.setSessionAsUUID(sessionKey);
inMsg = client.execute(scriptMessage2);
Assert.assertNotNull(inMsg.Session);
Assert.assertTrue(inMsg instanceof ErrorResponseMessage);
Assert.assertEquals(((ErrorResponseMessage) inMsg).metaGetFlag(), ErrorResponseMessage.SCRIPT_FAILURE_ERROR);
}
}