@Test public void testCall_WithEmpyArguments() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); fun.call(null, new AviatorObject[0]); out.flush(); out.close(); String lineSeparator = System.getProperty("line.separator"); byte[] data = out.toByteArray(); assertEquals(lineSeparator, new String(data)); }
@Test public void testCall_WithTwoArgument() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); AviatorObject[] args = new AviatorObject[2]; args[0] = new AviatorJavaType("out"); args[1] = new AviatorString("hello"); Map<String, Object> env = new HashMap<String, Object>(); env.put("out", out); fun.call(env, args); out.flush(); out.close(); String lineSeparator = System.getProperty("line.separator"); byte[] data = out.toByteArray(); assertEquals("hello" + lineSeparator, new String(data)); }
@Test(expected = IllegalArgumentException.class) public void testCall_WithFourArgument() throws Exception { fun.call(null, new AviatorObject[4]); }