当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils类代码示例

本文整理汇总了Java中com.surenpi.autotest.utils.StringUtils的典型用法代码示例。如果您正苦于以下问题:Java StringUtils类的具体用法?Java StringUtils怎么用?Java StringUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StringUtils类属于com.surenpi.autotest.utils包,在下文中一共展示了StringUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertBeanName

import com.surenpi.autotest.utils.StringUtils; //导入依赖的package包/类
/**
 * 把类名称转为默认的bean名称
 * @param pageClsStr pageClsStr
 * @return pageClsStr
 */
private String convertBeanName(final String pageClsStr)
{
	String result = pageClsStr;
	int index = pageClsStr.lastIndexOf(".");

	if(index < 0)
	{
		result = pageClsStr;
	}
	else
	{
		result = pageClsStr.substring(index + 1);
	}
	
	if(result.length() > 1 && result.charAt(1) >= 'A' && result.charAt(1) <= 'Z')
	{
		return result;
	}
	
	return StringUtils.uncapitalize(result);
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:27,代码来源:Phoenix.java

示例2: getUrl

import com.surenpi.autotest.utils.StringUtils; //导入依赖的package包/类
/**
 * 根据当前的操作系统来选择
 * @see #getUrl(String, String, String, String)
 * @param browser 浏览器类型
 * @param ver 浏览器版本
 * @return 驱动下载地址
 */
public String getUrl(String browser, String ver)
{
       //实现对多个操作系统的兼容性设置
       final String os = System.getProperty("os.name");
       final String arch = System.getProperty("os.arch");
       
       String commonOs = osMap.getProperty("os.map.name." + os);
       String commonArch = osMap.getProperty("os.map.arch." + arch);
       
       if(StringUtils.isAnyBlank(commonOs, commonArch))
       {
           throw new RuntimeException(String.format("unknow os [%s] and arch [%s].", os, arch));
       }
       
	return getUrl(browser, ver, commonOs, commonArch);
}
 
开发者ID:LinuxSuRen,项目名称:autotest.webdriver.downloader,代码行数:24,代码来源:DriverMapping.java

示例3: execFileChoose

import com.surenpi.autotest.utils.StringUtils; //导入依赖的package包/类
/**
 * 执行文件选择
 * @param title 标题
 * @param file 文件
 */
public void execFileChoose(String title, File file)
{
	if(StringUtils.isBlank(title))
	{
		title = autoItPro.getProperty("dialog.title");
	}
	
	if(file == null || !file.isFile())
	{
		throw new RuntimeException(String.format("File is null or not a file [%s].", file));
	}
	
	execFileChoose(title, file.getAbsolutePath());
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:20,代码来源:AutoItCmd.java

示例4: getBy

import com.surenpi.autotest.utils.StringUtils; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public By getBy()
{
	if(StringUtils.isAnyBlank(getHostType(), getHostValue()))
	{
		throw new IllegalArgumentException("HostType or HostValue is required in AbstractTreeLocator.");
	}
	
	Map<String, AbstractLocator> beans = context.getBeansOfType(AbstractLocator.class);
	Collection<AbstractLocator> locators = beans.values();
	for(AbstractLocator locator : locators)
	{
		LocatorAware locatorWare = null;
		if(!(locator instanceof LocatorAware))
		{
			continue;
		}
		
		if(getHostType().equals(locator.getType()))
		{
			locatorWare = (LocatorAware) locator;
			
			String oldValue = locator.getValue();
			locatorWare.setValue(getHostValue());
			
			By by = locator.getBy();
			
			locatorWare.setValue(oldValue);
			
			return by;
		}
	}
	
	return null;
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:37,代码来源:AbstractTreeLocator.java

示例5: search

import com.surenpi.autotest.utils.StringUtils; //导入依赖的package包/类
@Override
public WebElement search(Element element)
{
	List<By> byList = new ArrayList<By>();

	if (StringUtils.isNotBlank(element.getId()))
	{
		byList.add(By.id(element.getId()));
	}
	else if (StringUtils.isNotBlank(element.getCSS()))
	{
		byList.add(By.className(element.getCSS()));
	}
	else if (StringUtils.isNotBlank(element.getXPath()))
	{
		byList.add(By.xpath(element.getXPath()));
	}
	else if (StringUtils.isNotBlank(element.getLinkText()))
	{
		byList.add(By.linkText(element.getLinkText()));
	}
	else if (StringUtils.isNotBlank(element.getPartialLinkText()))
	{
		byList.add(By.partialLinkText(element.getPartialLinkText()));
	}
	else if (StringUtils.isNotBlank(element.getTagName()))
	{
		byList.add(By.tagName(element.getTagName()));
	}

	return cyleFindElement(byList);
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:33,代码来源:CyleSearchStrategy.java

示例6: findStrategy

import com.surenpi.autotest.utils.StringUtils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T> ElementSearchStrategy<T> findStrategy(Class<T> type, Element element)
{
	String strategy = element.getStrategy();
	strategy = StringUtils.isBlank(strategy) ? "prioritySearchStrategy" : strategyMap.get(strategy);
	
	return (ElementSearchStrategy<T>) context.getBean(strategy, ElementSearchStrategy.class);
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:9,代码来源:SearchStrategyUtils.java

示例7: findElementsStrategy

import com.surenpi.autotest.utils.StringUtils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T> ElementsSearchStrategy<T> findElementsStrategy(Class<T> type, Element element)
{
    String strategy = element.getStrategy();
    strategy = StringUtils.isBlank(strategy) ? "prioritySearchStrategy" : strategyMap.get(strategy);
    
    return (ElementsSearchStrategy<T>) context.getBean(strategy, ElementsSearchStrategy.class);
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:9,代码来源:SearchStrategyUtils.java

示例8: fillNotBlankValue

import com.surenpi.autotest.utils.StringUtils; //导入依赖的package包/类
@Override
public void fillNotBlankValue(Element ele, Object value)
{
	if(value == null || StringUtils.isBlank(value.toString()))
	{
		throw new RuntimeException("Can not allow null or empty value!");
	}
	
	fillValue(ele, value, true);
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:11,代码来源:SeleniumValueEditor.java

示例9: autoDataSourceProcess

import com.surenpi.autotest.utils.StringUtils; //导入依赖的package包/类
/**
 * 数据源处理
 * @param beanCls Page类的class类型
 * @param pageBean Page类对象
 */
private void autoDataSourceProcess(Class<?> beanCls, Page pageBean)
{
    AutoDataSource autoDataSource = beanCls.getAnnotation(AutoDataSource.class);
    if(autoDataSource != null)
    {
        String dsName = StringUtils.defaultIfBlank(autoDataSource.name(),
                System.currentTimeMillis());
        pageBean.setDataSource(dsName);
        dataSourceMap.put(dsName,
                new DataSourceInfo(autoDataSource.type(), autoDataSource.resource()));
    }
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:18,代码来源:AnnotationProcess.java

示例10: runFromClasspathFile

import com.surenpi.autotest.utils.StringUtils; //导入依赖的package包/类
/**
	 * 从类路径中查找配置文件
	 * @param filePath
	 * @throws Exception 
	 */
	public void runFromClasspathFile(final String filePath)
			throws Exception
	{
		if(StringUtils.isBlank(filePath))
		{
			throw new IllegalArgumentException("File path can not be empty.");
		}
		
		ClassLoader classLoader = SuiteRunner.class.getClassLoader();
		
		int resCount = 0;
		Enumeration<URL> resources = classLoader.getResources(filePath);
		while(resources.hasMoreElements())
		{
			URL url = resources.nextElement();
			
			resCount++;
			progressInfo.setInfo(String.format("Prepare to run from file : [%s].", url));
//			
//			try(InputStream input4Valid = url.openStream())
//			{
//				Validation.validationSuite(input4Valid);
//			}

			try(InputStream input = url.openStream())
			{
				Suite suite = suiteParser.parse(input);
				
				progressInfo.setInfo(String.format("Parse file [%s] complete.", url));
				
				runSuite(suite);
			}
		}

		progressInfo.setInfo(String.format("All runner is done, total [%s].", resCount));
	}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.suite.runner,代码行数:42,代码来源:SuiteRunner.java

示例11: getValue

import com.surenpi.autotest.utils.StringUtils; //导入依赖的package包/类
@Override
public String getValue(final String orginData)
{
	String value = orginData;
	
	Date nowDate = new Date();
	value = value.replace("${now}", String.valueOf(System.currentTimeMillis()));
	
	for(String format : formatSet)
	{
		String param = "${now " + format + "}";
		if(value.contains(param))
		{
			dateFormat.applyPattern(format);
			value = value.replace(param, dateFormat.format(nowDate));
		}
	}
	
	if(value.contains("${id_card}"))
	{
		value = value.replace("${id_card}", IDCardUtil.generate());
	}
	
	if(value.contains("${email}"))
	{
		value = value.replace("${email}", StringUtils.email());
	}
	
	if(value.contains("${phone}"))
	{
		value = value.replace("${phone}", CommonNumberUtil.phoneNumber());
	}
	
	if(value.contains("${postcode}"))
	{
		value = value.replace("${postcode}", CommonNumberUtil.postCode());
	}
	
	if(value.contains(random))
	{
		value = parseRandomParam(value);
	}
	
	for(String key : globalData.keySet())
	{
		value = value.replace("${" + key + "}", globalData.get(key).toString());
	}
	
	return value;
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:51,代码来源:SimpleDynamicData.java

示例12: visit

import com.surenpi.autotest.utils.StringUtils; //导入依赖的package包/类
@Override
public void visit(Element node)
{
    if (!"locator".equals(node.getName()))
    {
        return;
    }
    
    String name = node.attributeValue("name");
    String value = node.attributeValue("value");
    String timeoutStr = node.attributeValue("timeout");
    String extend = node.attributeValue("extend");
    
    if(StringUtils.isBlank(name) || StringUtils.isBlank(value))
    {
        logger.error("locator has empty name or value.");
    }
    
    long timeout = 0;
    if(StringUtils.isNotBlank(timeoutStr))
    {
        try
        {
            timeout = Long.parseLong(timeoutStr);
        }
        catch(NumberFormatException e){}
    }
    
    Map<String, Locator> beans = context.getBeansOfType(Locator.class);
    Collection<Locator> locatorList = beans.values();
    for(Locator locator : locatorList)
    {
        if(!name.equals(locator.getType()))
        {
            continue;
        }
        
        if(locator instanceof LocatorAware)
        {
            LocatorAware locatorAware = (LocatorAware) locator;
            locatorAware.setValue(value);
            locatorAware.setTimeout(timeout);
            locatorAware.setExtend(extend);
            
            absEle.getLocatorList().add(locator);
            
            break;
        }
    }
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:51,代码来源:FieldLocatorsVisitor.java

示例13: initPageData

import com.surenpi.autotest.utils.StringUtils; //导入依赖的package包/类
/**
 * 从数据源中加载指定的数据组到指定的Page类中
 * @param page 页面对象
 * @param row 数据组序号(从1开始)
 * @return 数据源
 */
public DynamicDataSource initPageData(Page page, int row)
{
	String dataSourceStr = page.getDataSource();
	if(StringUtils.isBlank(dataSourceStr))
	{
		return null;
	}
	
	final DataSourceInfo dataSourceInfo = dataSourceMap.get(dataSourceStr);
	if(dataSourceInfo == null)
	{
		return null;
	}
	
	getDynamicDataSources();
	@SuppressWarnings({ "unchecked", "rawtypes" })
       DataSource<Page> dataSource = (DataSource) dynamicDataSourceMap.get(dataSourceInfo.getType());
	if(dataSource == null)
	{
		throw new AutoTestException("Can not found dataSource by type : " + dataSourceInfo.getType());
	}
	
	String resoucePathName = dataSourceInfo.getResource();
	DataResource clzResource = new ClasspathResource(
			Phoenix.class, resoucePathName);
	try
	{
		if(clzResource.getUrl() == null)
		{
               if(configFile != null)
               {
                   File file = new File(configFile.getParentFile(), dataSourceInfo.getResource());
                   if(!file.isFile())
                   {
                       throw new ConfigNotFoundException("dataSourceFile", file.getAbsolutePath());
                   }
                   
                   clzResource = new FileResource(file);
               }
               else
               {
                   throw new ConfigNotFoundException(String.format("Can not found dataSource file '%s' from classpath.",
                           resoucePathName));
               }
		}
	}
	catch (IOException e)
	{
		logger.error("", e);
	}
	
	dataSource.loadData(clzResource, row, page);
	
	return dataSource;
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:62,代码来源:Phoenix.java

示例14: runSuite

import com.surenpi.autotest.utils.StringUtils; //导入依赖的package包/类
/**
 * 测试套件运行入口
 * @param suite
 * @throws DocumentException 
 * @throws IOException 
 * @throws SecurityException 
 * @throws NoSuchFieldException 
 * @throws IllegalAccessException 
 * @throws IllegalArgumentException 
 * @throws InterruptedException 
 * @throws SAXException 
 */
private void runSuite(Suite suite)
		throws IOException, DocumentException, NoSuchFieldException,
		SecurityException, IllegalArgumentException, IllegalAccessException, InterruptedException, SAXException
{
	String xmlConfPath = suite.getXmlConfPath();
	if(StringUtils.isBlank(xmlConfPath))
	{
		throw new RuntimeException("Suite xml config is emtpy!");
	}
	
	URL suitePathUrl = suite.getPathUrl();
	try(Phoenix phoenix = applicationClazz == null ? new Phoenix(): new Phoenix(applicationClazz))
	{
	    phoenix.init();
		String[] xmlConfArray = xmlConfPath.split(",");
		for(String xmlConf : xmlConfArray)
		{
			this.progressInfo.setInfo(String.format("解析元素定位配置文件[%s]!", xmlConf));
			
			if(suitePathUrl != null)
			{
				File patentFile = new File(URLDecoder.decode(suitePathUrl.getFile(), "utf-8"));
				patentFile = patentFile.getParentFile();
				
				phoenix.readFromSystemPath(new File(patentFile, xmlConf).toString());
			}
			else
			{
				phoenix.readFromClassPath(xmlConf);
			}
		}

		phoenix.getEngine().setProgressId("progress_identify", progressInfo.getIdentify());
		
		List<SuitePage> pageList = suite.getPageList();
		
		//执行指定的数据组(按照数据序列)
		Integer[] rowsArray = suite.getRowsArray();
		for(int row : rowsArray)
		{
			long afterSleep = suite.getAfterSleep();
			
			this.progressInfo.setInfo(String.format("准备使用第[%s]组数据运行套件,然后休眠时间[%s]毫秒!", row, afterSleep));
			
			runSuiteWithData(phoenix, row, pageList);
			
			if(afterSleep > 0)
			{
				Thread.sleep(afterSleep);
			}
		}
	}
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.suite.runner,代码行数:66,代码来源:SuiteRunner.java

示例15: runSuiteWithData

import com.surenpi.autotest.utils.StringUtils; //导入依赖的package包/类
/**
 * 使用指定数据组来运行
 * @param settingUtil
 * @param row
 * @param pageList
 * @throws SecurityException
 * @throws IllegalArgumentException
 * @throws IllegalAccessException
 * @throws InterruptedException
 */
@SuppressWarnings("unchecked")
   private void runSuiteWithData(Phoenix settingUtil, int row, List<SuitePage> pageList)
		throws SecurityException, IllegalArgumentException, IllegalAccessException, InterruptedException
{
	
	Collection<DynamicDataSource> dynamicDataSourceList = settingUtil.getDynamicDataSources();
	for(DynamicDataSource dynamicDataSource : dynamicDataSourceList)
	{
		Object dynamicParam = globalData.get(DATA_SOURCE_PARAM_KEY);
		if(dynamicParam instanceof Map)
		{
			Map<String, Object> dataGlobalMap = dynamicDataSource.getGlobalMap();
			if(dataGlobalMap != null)
			{
				dataGlobalMap.putAll((Map<? extends String, ? extends Object>) dynamicParam);
				dataGlobalMap.putAll(settingUtil.getEngine().getDataMap());
			}
		}
	}
	settingUtil.initData(row);
	
	this.progressInfo.setInfo(String.format("数据初始化完毕!共有[%s]个测试页面!", pageList.size()));
	
	for(SuitePage suitePage : pageList)
	{
		String pageCls = suitePage.getPage();
		Page page = (Page) settingUtil.getPage(pageCls);
		if(page == null)
		{
			throw new RuntimeException(String.format("Can not found page [%s].", pageCls));
		}
		
		Object pageData = globalData.get(pageCls);
		if(pageData instanceof Map)
		{
			@SuppressWarnings("unchecked")
			Map<String, Object> pageDataMap = (Map<String, Object>) pageData;
			page.putAllData(pageDataMap);
		}
		
		String url = page.getUrl();
		if(StringUtils.isNotBlank(url))
		{
			page.open();
		}
		
		List<SuiteAction> actionList = suitePage.getActionList();
		if(actionList == null)
		{
			actionList = new ArrayList<SuiteAction>();
		}
		
		this.progressInfo.setInfo(String.format("页面[%s]一共有[%s]个测试动作!开始测试!", pageCls, actionList.size()));
		
		int repeat = suitePage.getRepeat();
		repeat = repeat <= 0 ? 1: repeat;
		for(int i = 0; i < repeat; i++)
		{
			performActionList(page, actionList, settingUtil);
		}
	}
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.suite.runner,代码行数:73,代码来源:SuiteRunner.java


注:本文中的com.surenpi.autotest.utils.StringUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。