首页 > 代码库 > SoapUI Pro Project Solution Collection-Custom project and setup
SoapUI Pro Project Solution Collection-Custom project and setup
import java.util.List;import java.util.Map;import org.apache.log4j.Logger;import com.eviware.soapui.SoapUI;import com.eviware.soapui.SoapUIProSettings;import com.eviware.soapui.impl.wsdl.WsdlProjectPro;import com.eviware.soapui.impl.wsdl.support.connections.DatabaseConnection;import com.eviware.soapui.impl.wsdl.support.connections.DefaultDatabaseConnectionContainer;import com.eviware.soapui.model.environment.Environment;import com.eviware.soapui.model.project.Project;import com.eviware.soapui.model.settings.Settings;import com.eviware.soapui.model.testsuite.TestSuite;import com.eviware.soapui.settings.HttpSettings;import com.eviware.soapui.settings.ProxySettings;import com.eviware.soapui.support.GroovyUtils;public class ProjectLevel { public void mypro(Project project,Logger log){ project.getProperties().clear(); project.setPropertyValue("", ""); GroovyUtils.registerJdbcDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver"); // project.getPropertyAt(1).getName(),get the soapui project level from API. if(project instanceof WsdlProjectPro){ //properties for project String name = project.getName(); String description = project.getDescription(); String path = project.getPath(); String resourceRoot = project.getResourceRoot(); ((WsdlProjectPro) project).setComposite(true); project.getShadowPassword(); ((WsdlProjectPro) project).getScriptLibrary(); ((WsdlProjectPro) project).getDefaultScriptLanguage(); ((WsdlProjectPro) project).setCacheDefinitions(true); //custom properties before setup the soapui project //testsuite int testSuiteCount = project.getTestSuiteCount(); TestSuite testSuiteByName = project.getTestSuiteByName(""); List<TestSuite> testSuiteList = project.getTestSuiteList(); Map<String, TestSuite> testSuites = ((WsdlProjectPro) project).getTestSuites(); for(TestSuite suite:testSuiteList){ String name2 = suite.getName(); } for(String key:testSuites.keySet()){ TestSuite value = testSuites.get(key); } //configuration jdbc connections GroovyUtils.registerJdbcDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver"); DefaultDatabaseConnectionContainer databaseConnectionContainer = ((WsdlProjectPro) project).getDatabaseConnectionContainer(); String[] databaseConnectionsNames = databaseConnectionContainer.getDatabaseConnectionsNames(com.eviware.soapui.model.environment.DefaultEnvironment.getInstance()); for(String dbname:databaseConnectionsNames){ databaseConnectionContainer.removeDatabaseConnectionByName(dbname); } DatabaseConnection addDatabaseConnection = databaseConnectionContainer.addDatabaseConnection("com.microsoft.sqlserver.jdbc.SQLServerDriver"); addDatabaseConnection.setDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver"); addDatabaseConnection.setConnectionString("jdbc:sqlserver://GDCQA4-SQL01;databaseName=QA4;user=qa_automation;password=Gr33nDot!"); addDatabaseConnection.setName("testname"); addDatabaseConnection.setPassword(""); int projectCount = project.getWorkspace().getProjectCount(); //environment settings ,we can mark testing with different environments ,refer this url //http://www.soapui.org/Working-with-Projects/environment-handling-in-soapui.html String activeEnvironmentName = ((WsdlProjectPro) project).getActiveEnvironmentName(); ((WsdlProjectPro) project).setActiveEnvironment("staging"); ((WsdlProjectPro) project).getEnvironmentList().clear(); List<Environment> environmentList = ((WsdlProjectPro) project).getEnvironmentList(); for(Environment e:environmentList){ String project2 = e.getProject().getName(); String name2 = e.getName(); e.addNewProperty("propertyname","propertyvlaue"); e.addNewService("testservice", null); } //soapui preference global settings, like the http settings,proxy settings and so on Settings settings = SoapUI.getSettings(); settings.setString(ProxySettings.ENABLE_PROXY, "false"); settings.setString(HttpSettings.HTTP_VERSION, "1.1"); settings.setString(SoapUIProSettings.OUTLINE_EDITOR_LIMIT, "4000000"); settings.setString(SoapUIProSettings.FORM_EDITOR_LIMIT, "200000"); settings.setString(SoapUIProSettings.SCRIPT_LIBRARY, "C:\\TEST\\groovy"); settings.setString(SoapUIProSettings.COMPLETE_MESSAGE_LOGS,"true"); SoapUI.updateProxyButtonAndTooltip(); SoapUI.updateProxyFromSettings(); settings.reloadSettings(); //set the event }
SoapUI Pro Project Solution Collection-Custom project and setup
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。