Java 类org.testng.remote.RemoteTestNG 实例源码

项目:intellij-ce-playground    文件:TestNGRunnableState.java   
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);
}
项目:testng-remote    文件:SerializedMessageSender.java   
@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;
  }
项目:testng-remote    文件:RemoteTest.java   
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();
}
项目:tools-idea    文件:TestNGRunnableState.java   
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);
}
项目:testng-remote    文件:StringMessageSender.java   
@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();
  }
}
项目:testng-remote    文件:StringMessageSender.java   
private static void p(String msg) {
  if (RemoteTestNG.isVerbose()) {
    System.out.println("[StringMessageSender] " + msg); //$NON-NLS-1$
  }
}
项目:testng-remote    文件:StringMessageSender.java   
protected void handleThrowable(Throwable cause) {
  if (RemoteTestNG.isVerbose()) {
    cause.printStackTrace();
  }
}
项目:testng-remote    文件:SerializedMessageSender.java   
static void p(String s) {
  if (RemoteTestNG.isVerbose()) {
    System.out.println("[SerializedMessageSender] " + s);
  }
}