Skip to content

Commit

Permalink
send subdialog namelist to server
Browse files Browse the repository at this point in the history
  • Loading branch information
sdiawara authored and sdiawara committed Nov 10, 2011
1 parent c39e1ab commit c3f247d
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 140 deletions.
26 changes: 12 additions & 14 deletions VxmlInterpreter/src/cudl/VoiceXmlNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.mozilla.javascript.EcmaError;
import org.mozilla.javascript.Undefined;
import org.mozilla.javascript.ast.Yield;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
Expand Down Expand Up @@ -949,28 +950,25 @@ public Object interpret(InterpreterContext context) throws InterpreterException,
if (src != null && srcexpr != null) {
throw new EventException("error.badfetch");
}
if(src == null && srcexpr != null)
{
src = context.getDeclaration().evaluateScript(srcexpr, 50)+"";
if (src == null && srcexpr != null) {
src = context.getDeclaration().evaluateScript(srcexpr, 50) + "";
}
InternalInterpreter internalInterpreter = null;
if (src != null) {
String url = Utils.tackWeelFormedUrl(context.getCurrentFileName(), src);

// if remote url, put namelist values in GET parameters
if (!url.startsWith("#")) {
String nameList = getNodeAttributeValue(node, "namelist");
if (nameList != null) {
StringTokenizer tokenizer = new StringTokenizer(nameList);
String urlSuite = "?";
while (tokenizer.hasMoreElements()) {
String data = tokenizer.nextToken();
urlSuite += data + "=" + context.getDeclaration().getValue(data) + "&";
}
url += urlSuite;
String nameList = getNodeAttributeValue(node, "namelist");
if (nameList != null) {
StringTokenizer tokenizer = new StringTokenizer(nameList);
String urlSuite = "?";
while (tokenizer.hasMoreElements()) {
String data = tokenizer.nextToken();
urlSuite += data + "=" + context.getDeclaration().getValue(data) + "&";
}
url += urlSuite;
}

System.err.println("subdialog url" + url);
// TODO put namelist values in child context

// FIXME this is not a viable way to handle subdialogs ;(
Expand Down
19 changes: 14 additions & 5 deletions VxmlInterpreter/test/cudl/InterpreterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -596,16 +596,25 @@ public void subdialogSrcExprIsEvaluateAndExecute() throws IOException, ParserCon
assertEquals(1, interpreter.getLogs().size());
assertEquals("return_value", interpreter.getLogs().get(0));
}

@Test
public void sessionVariableInConstructor() throws IOException, SAXException, ParserConfigurationException{
String sessionVariables ="test = {variable: 'value'}";
public void sessionVariableInConstructor() throws IOException, SAXException, ParserConfigurationException {
String sessionVariables = "test = {variable: 'value'}";

Interpreter interpreter = new Interpreter(url + "sessionVariablesLogger.vxml", sessionVariables);
interpreter.start();


assertEquals(1, interpreter.getLogs().size());
assertEquals("value", interpreter.getLogs().get(0));
}

//trouver un autre moyen de test
// @Test
// public void subdialogNamelistIsSubmitedToServer() throws ParserConfigurationException, SAXException,
// IOException {
// Interpreter interpreter = new Interpreter(url + "subdialogNamelist.vxml");
// interpreter.start();
//
// assertEquals("pass", interpreter.getPrompts().get(0).tts);
// }
}
Loading

0 comments on commit c3f247d

Please sign in to comment.