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); }
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); }
@Test public void testSerialized() { runTest("-serport", PORT1, new SerializedMessageSender("localhost", PORT1)); }