@Test public void testJavaLangClass() { String inputCommand1 = ReflectionCommand.GET_JAVA_LANG_CLASS_SUB_COMMAND_NAME + "\n" + "java.lang.String\ne\n"; String inputCommand2 = ReflectionCommand.GET_JAVA_LANG_CLASS_SUB_COMMAND_NAME + "\n" + "java.lang" + ".FOOOOO\ne\n"; try { command.execute("r", new BufferedReader(new StringReader(inputCommand1)), writer); assertEquals("!yro0\n", sWriter.toString()); command.execute("r", new BufferedReader(new StringReader(inputCommand2)), writer); assertEquals("!yro0\n!xsThe class java.lang.FOOOOO does not exist.\n", sWriter.toString()); } catch (Exception e) { e.printStackTrace(); fail(); } }
@Override public void execute(String commandName, BufferedReader reader, BufferedWriter writer) throws Py4JException, IOException { char subCommand = safeReadLine(reader).charAt(0); String returnCommand = null; if (subCommand == GET_UNKNOWN_SUB_COMMAND_NAME) { returnCommand = getUnknownMember(reader); } else if (subCommand == GET_JAVA_LANG_CLASS_SUB_COMMAND_NAME) { returnCommand = getJavaLangClass(reader); } else { returnCommand = getMember(reader); } logger.finest("Returning command: " + returnCommand); writer.write(returnCommand); writer.flush(); }
ReflectionCommand extends AbstractCommand { @Override public void execute(String commandName, BufferedReader reader, BufferedWriter writer) throws Py4JException, IOException { char subCommand = safeReadLine(reader).charAt(0); String returnCommand = null; if (subCommand == GET_UNKNOWN_SUB_COMMAND_NAME) { returnCommand = getUnknownMember(reader); } else if (subCommand == GET_JAVA_LANG_CLASS_SUB_COMMAND_NAME) { returnCommand = getJavaLangClass(reader); } else { returnCommand = getMember(reader); } logger.finest("Returning command: " + returnCommand); writer.write(returnCommand); writer.flush(); } }
ReflectionCommand extends AbstractCommand { @Override public void execute(String commandName, BufferedReader reader, BufferedWriter writer) throws Py4JException, IOException { char subCommand = safeReadLine(reader).charAt(0); String returnCommand = null; if (subCommand == GET_UNKNOWN_SUB_COMMAND_NAME) { returnCommand = getUnknownMember(reader); } else if (subCommand == GET_JAVA_LANG_CLASS_SUB_COMMAND_NAME) { returnCommand = getJavaLangClass(reader); } else { returnCommand = getMember(reader); } logger.finest("Returning command: " + returnCommand); writer.write(returnCommand); writer.flush(); } ReflectionCommand(); }
ReflectionCommand extends AbstractCommand { @Override public void execute(String commandName, BufferedReader reader, BufferedWriter writer) throws Py4JException, IOException { char subCommand = safeReadLine(reader).charAt(0); String returnCommand = null; if (subCommand == GET_UNKNOWN_SUB_COMMAND_NAME) { returnCommand = getUnknownMember(reader); } else if (subCommand == GET_JAVA_LANG_CLASS_SUB_COMMAND_NAME) { returnCommand = getJavaLangClass(reader); } else { returnCommand = getMember(reader); } logger.finest("Returning command: " + returnCommand); writer.write(returnCommand); writer.flush(); } ReflectionCommand(); @Override void execute(String commandName, BufferedReader reader, BufferedWriter writer); @Override void init(Gateway gateway, Py4JServerConnection connection); }
ReflectionCommand extends AbstractCommand { @Override public void execute(String commandName, BufferedReader reader, BufferedWriter writer) throws Py4JException, IOException { char subCommand = safeReadLine(reader).charAt(0); String returnCommand = null; if (subCommand == GET_UNKNOWN_SUB_COMMAND_NAME) { returnCommand = getUnknownMember(reader); } else if (subCommand == GET_JAVA_LANG_CLASS_SUB_COMMAND_NAME) { returnCommand = getJavaLangClass(reader); } else { returnCommand = getMember(reader); } logger.finest("Returning command: " + returnCommand); writer.write(returnCommand); writer.flush(); } ReflectionCommand(); @Override void execute(String commandName, BufferedReader reader, BufferedWriter writer); @Override void init(Gateway gateway, Py4JServerConnection connection); final static char GET_UNKNOWN_SUB_COMMAND_NAME; final static char GET_MEMBER_SUB_COMMAND_NAME; final static char GET_JAVA_LANG_CLASS_SUB_COMMAND_NAME; static final String REFLECTION_COMMAND_NAME; }