public static boolean supportSerializationProtocol(TestNGConfiguration config) { final Project project = config.getProject(); final GlobalSearchScope scopeToDetermineTestngIn; if (config.getPersistantData().getScope() == TestSearchScope.WHOLE_PROJECT) { scopeToDetermineTestngIn = GlobalSearchScope.allScope(project); } else { final Module module = config.getConfigurationModule().getModule(); scopeToDetermineTestngIn = module != null ? GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module) : GlobalSearchScope.allScope(project); } final JavaPsiFacade facade = JavaPsiFacade.getInstance(project); final PsiClass aClass = facade.findClass(SerializedMessageSender.class.getName(), scopeToDetermineTestngIn); if (aClass == null) return false; final PsiClass[] starters = facade.findClasses(RemoteTestNG.class.getName(), scopeToDetermineTestngIn); for (PsiClass starter : starters) { if (starter.findFieldByName("m_serPort", false) == null) { LOG.info("Multiple TestNG versions found"); return false; } } return Registry.is("testng.serialized.protocol.enabled") && !TestNGVersionChecker.isVersionIncompatible(project, scopeToDetermineTestngIn); }
@Override public IMessage receiveMessage() throws IOException, ClassNotFoundException { IMessage result = null; try { ObjectInputStream ios = new ObjectInputStream(m_inStream); // synchronized(m_input) { result = (IMessage) ios.readObject(); p("Received message " + result); // sendAck(); // } } catch(Exception ex) { if (RemoteTestNG.isVerbose()) { ex.printStackTrace(); } } return result; }
private void launchRemoteTestNG(final String portArg, final int portValue, final String protocol) { new Thread(new Runnable() { @Override public void run() { List<String> args = new ArrayList<>(); args.add(portArg); args.add(Integer.toString(portValue)); args.add(RemoteArgs.VERSION); args.add(getTestNGVersion()); if (protocol != null) { args.add(RemoteArgs.PROTOCOL); args.add(protocol); } args.add("-dontexit"); args.add(getPathToResource("testng-remote.xml")); RemoteTestNG.main(args.toArray(new String[0])); } }).start(); }
public static boolean supportSerializationProtocol(TestNGConfiguration config) { final Project project = config.getProject(); final GlobalSearchScope scopeToDetermineTestngIn; if (config.getPersistantData().getScope() == TestSearchScope.WHOLE_PROJECT) { scopeToDetermineTestngIn = GlobalSearchScope.allScope(project); } else { scopeToDetermineTestngIn = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(config.getConfigurationModule().getModule()); } final JavaPsiFacade facade = JavaPsiFacade.getInstance(project); final PsiClass aClass = facade.findClass(SerializedMessageSender.class.getName(), scopeToDetermineTestngIn); if (aClass == null) return false; final PsiClass[] starters = facade.findClasses(RemoteTestNG.class.getName(), scopeToDetermineTestngIn); for (PsiClass starter : starters) { if (starter.findFieldByName("m_serPort", false) == null) { LOG.info("Multiple TestNG versions found"); return false; } } return Registry.is("testng.serialized.protocol.enabled") && !TestNGVersionChecker.isVersionIncompatible(project, scopeToDetermineTestngIn); }
@Override public void sendMessage(IMessage message) { if (m_outStream == null) { throw new IllegalStateException("Trying to send a message on a shutdown sender"); } if (writer == null) { try { writer = new PrintWriter(new BufferedWriter( new OutputStreamWriter(m_outStream, "UTF-8")), //$NON-NLS-1$ false /* autoflush */); } catch (UnsupportedEncodingException e1) { writer = new PrintWriter(new BufferedWriter( new OutputStreamWriter(m_outStream)), false /* autoflush */); } } String msg = ((IStringMessage) message).getMessageAsString(); if (RemoteTestNG.isVerbose()) { p("Sending message:" + message); p(" String version:" + msg); StringBuffer buf = new StringBuffer(); for(int i = 0; i < msg.length(); i++) { if('\u0001' == msg.charAt(i)) { p(" word:[" + buf.toString() + "]"); buf.delete(0, buf.length()); } else { buf.append(msg.charAt(i)); } } p(" word:[" + buf.toString() + "]"); } synchronized(m_ackLock) { writer.println(msg); writer.flush(); waitForAck(); } }
private static void p(String msg) { if (RemoteTestNG.isVerbose()) { System.out.println("[StringMessageSender] " + msg); //$NON-NLS-1$ } }
protected void handleThrowable(Throwable cause) { if (RemoteTestNG.isVerbose()) { cause.printStackTrace(); } }
static void p(String s) { if (RemoteTestNG.isVerbose()) { System.out.println("[SerializedMessageSender] " + s); } }