@Test public void testScalarOutputBoolean() throws DMLException { Connection conn = new Connection(); String str = "outBoolean = FALSE;\nwrite(outBoolean, './tmp/outBoolean');"; PreparedScript script = conn.prepareScript(str, new String[] {}, new String[] {"outBoolean"}, false); boolean result = script.executeScript().getBoolean("outBoolean"); Assert.assertEquals(false, result); conn.close(); }
@Test public void testScalarOutputString() throws DMLException { Connection conn = new Connection(); String str = "outString = 'hello';\nwrite(outString, './tmp/outString');"; PreparedScript script = conn.prepareScript(str, new String[] {}, new String[] {"outString"}, false); String result = script.executeScript().getString("outString"); Assert.assertEquals("hello", result); conn.close(); }
@Test public void testScalarOutputDouble() throws DMLException { Connection conn = new Connection(); String str = "outDouble = 1.23;\nwrite(outDouble, './tmp/outDouble');"; PreparedScript script = conn.prepareScript(str, new String[] {}, new String[] {"outDouble"}, false); double result = script.executeScript().getDouble("outDouble"); Assert.assertEquals(1.23, result, 0); conn.close(); }
@Test public void testScalarOutputLong() throws DMLException { Connection conn = new Connection(); String str = "outInteger = 5;\nwrite(outInteger, './tmp/outInteger');"; PreparedScript script = conn.prepareScript(str, new String[] {}, new String[] {"outInteger"}, false); long result = script.executeScript().getLong("outInteger"); Assert.assertEquals(5, result); conn.close(); }
@Test public void testScalarInputLong() throws IOException, DMLException { Connection conn = new Connection(); String str = conn.readScript(baseDirectory + File.separator + "scalar-input.dml"); PreparedScript script = conn.prepareScript(str, new String[] {"inScalar1", "inScalar2"}, new String[] {}, false); long inScalar1 = 4; long inScalar2 = 5; script.setScalar("inScalar1", inScalar1); script.setScalar("inScalar2", inScalar2); setExpectedStdOut("total:9"); script.executeScript(); conn.close(); }
@Test public void testScalarInputStringExplicitValueType() throws IOException, DMLException { Connection conn = new Connection(); String str = conn.readScript(baseDirectory + File.separator + "scalar-input-string.dml"); PreparedScript script = conn.prepareScript(str, new String[] {"inScalar1", "inScalar2"}, new String[] {}, false); String inScalar1 = "hello"; String inScalar2 = "goodbye"; script.setScalar("inScalar1", inScalar1); script.setScalar("inScalar2", inScalar2); setExpectedStdOut("result:hellogoodbye"); script.executeScript(); conn.close(); }