當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtil類代碼示例

本文整理匯總了Java中com.qmetry.qaf.automation.util.StringUtil的典型用法代碼示例。如果您正苦於以下問題:Java StringUtil類的具體用法?Java StringUtil怎麽用?Java StringUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StringUtil類屬於com.qmetry.qaf.automation.util包,在下文中一共展示了StringUtil類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getDataProvider

import com.qmetry.qaf.automation.util.StringUtil; //導入依賴的package包/類
public static final String getDataProvider(Map<String, String> map) {
	if ((null == map) || map.isEmpty()) {
		return "";
	}
	if(map.containsKey(params.JSON_DATA_TABLE.name())){
		return dataproviders.isfw_json.name();
	}
	String f = map.get(params.DATAFILE.name());

	if (StringUtil.isNotBlank(f)) {
		if (f.endsWith(".xls")) {
			return StringUtil.isNotBlank(map.get(params.KEY.name())) ? dataproviders.isfw_excel_table.name()
					: dataproviders.isfw_excel.name();
		} else if (f.endsWith(".json")) {
			return dataproviders.isfw_json.name();
		} else {
			return dataproviders.isfw_csv.name();
		}
	}
	return StringUtil.isNotBlank(map.get(params.SQLQUERY.name())) ? dataproviders.isfw_database.name()
			: StringUtil.isNotBlank(map.get(params.KEY.name())) ? dataproviders.isfw_property.name() : "";
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:23,代碼來源:DataProviderFactory.java

示例2: getOptionElement

import com.qmetry.qaf.automation.util.StringUtil; //導入依賴的package包/類
private QAFExtendedWebElement getOptionElement(String loc, String val,
		Class<? extends QAFExtendedWebElement> eleClass) {
	String optLoc;
	if (!val.contains("=")) {
		if (StringUtil.isNumeric(val)) {
			optLoc = String.format(
					".//option[@value='%s' or @lineNo=%s or  @id='%s' or contains(.,'%s') ]",
					val, val, val, val);
		} else {
			optLoc = String.format(
					".//option[translate(.,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')='%s' or translate(@value,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')='%s' or translate(@id,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')='%s']",
					val.toUpperCase(), val.toUpperCase(), val.toUpperCase());
		}
	} else {
		String[] parts = val.split("=", 2);
		if (parts[0].equalsIgnoreCase("label") || parts[0].equalsIgnoreCase("text")) {
			optLoc = String.format(".//option[contains(.,'%s')]", parts[1]);
		} else if (parts[0].equalsIgnoreCase("lineNo")) {
			optLoc = String.format(".//option[%d]", Integer.parseInt(parts[1]) + 1);
		} else {
			optLoc = String.format(".//option[@%s='%s']", parts[0], parts[1]);
		}

	}
	return new QAFExtendedWebElement(getElement(loc, eleClass), By.xpath(optLoc));
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:27,代碼來源:ElementInteractor.java

示例3: verifyUiElements

import com.qmetry.qaf.automation.util.StringUtil; //導入依賴的package包/類
final public boolean verifyUiElements(String... fieldmapnames) {
	Field[] flds = this.getClass().getDeclaredFields();
	List<String> includeLst = null;
	boolean outcome = true;
	if ((fieldmapnames != null) && (fieldmapnames.length > 0)) {
		includeLst = Arrays.asList(fieldmapnames);
	}
	for (Field fld : flds) {
		fld.setAccessible(true);
		if (fld.isAnnotationPresent(UiElement.class)) {
			UiElement map = fld.getAnnotation(UiElement.class);
			String mapName = StringUtil.isNotBlank(map.viewLoc()) ? map.viewLoc() : fld.getName();
			if ((includeLst == null) || includeLst.contains(mapName)) {
				outcome = outcome && verifyUiData(fld);
			}
		}
	}
	return outcome;
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:20,代碼來源:BaseFormDataBean.java

示例4: verifyUiVaules

import com.qmetry.qaf.automation.util.StringUtil; //導入依賴的package包/類
final public boolean verifyUiVaules(String... fieldmapnames) {
	Field[] flds = this.getClass().getDeclaredFields();
	List<String> includeLst = null;
	boolean outcome = true;
	if ((fieldmapnames != null) && (fieldmapnames.length > 0)) {
		includeLst = Arrays.asList(fieldmapnames);
	}
	for (Field fld : flds) {
		fld.setAccessible(true);
		if (fld.isAnnotationPresent(UiElement.class)) {
			UiElement map = fld.getAnnotation(UiElement.class);
			String mapName = StringUtil.isNotBlank(map.viewLoc()) ? map.viewLoc() : fld.getName();
			if ((includeLst == null) || includeLst.contains(mapName)) {
				outcome = outcome && verifyUiData(fld);
			}
		}
	}
	return outcome;
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:20,代碼來源:BaseFormDataBean.java

示例5: fetchUiData

import com.qmetry.qaf.automation.util.StringUtil; //導入依賴的package包/類
private Object fetchUiData(Field field) {
	try {
		Method m = this.getClass().getDeclaredMethod("fetch" + StringUtil.getTitleCase(field.getName()));
		m.setAccessible(true);
		logger.debug("invoking custom fetch method for field " + field.getName());
		return m.invoke(this);

	} catch (Exception e) {
	}
	UiElement map = field.getAnnotation(UiElement.class);
	if ((null == map)) {
		return null;
	}
	Type type = map.fieldType();
	String loc = map.fieldLoc();
	Class<? extends QAFExtendedWebElement> eleClass = map.elementClass();

	return interactor.fetchValue(loc, type,eleClass);
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:20,代碼來源:BaseFormDataBean.java

示例6: verifyUiData

import com.qmetry.qaf.automation.util.StringUtil; //導入依賴的package包/類
private boolean verifyUiData(Field fld) {
	UiElement map = fld.getAnnotation(UiElement.class);
	Type type = map.fieldType();
	String loc = map.fieldLoc();
	String depends = map.dependsOnField();
	String depVal = map.dependingValue();
	Class<? extends QAFExtendedWebElement> eleClass = map.elementClass();

	try {
		if (StringUtil.isBlank(depends) || checkParent(depends, depVal)) {
			return interactor.verifyValue(loc, String.valueOf(getBeanData(loc)), type,eleClass);
		}
	} catch (Exception e1) {
		e1.printStackTrace();
		return false;
	}
	// Skipped so just return success
	return true;

}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:21,代碼來源:BaseFormDataBean.java

示例7: absractArgsAandSetDesciption

import com.qmetry.qaf.automation.util.StringUtil; //導入依賴的package包/類
private void absractArgsAandSetDesciption() {
	String prefix = BDDKeyword.getKeywordFrom(name);
	if (actualArgs == null || actualArgs.length == 0) {
		final String REGEX = ParamType.getParamValueRegx();
		List<String> arguments = new ArrayList<String>();

		description = removePrefix(prefix, name);

		Pattern p = Pattern.compile(REGEX);
		Matcher m = p.matcher(description); // get a matcher object
		int count = 0;

		while (m.find()) {
			String arg = description.substring(m.start(), m.end());
			arguments.add(arg);
			count++;
		}
		for (int i = 0; i < count; i++) {
			description = description.replaceFirst(Pattern.quote(arguments.get(i)),
					Matcher.quoteReplacement("{" + i + "}"));
		}
		actualArgs = arguments.toArray(new String[]{});
	}
	name = StringUtil
			.toCamelCaseIdentifier(description.length() > 0 ? description : name);
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:27,代碼來源:StringTestStep.java

示例8: quoteParams

import com.qmetry.qaf.automation.util.StringUtil; //導入依賴的package包/類
public static String quoteParams(String call) {
	String exp = "(\\s|^)\\$\\{[\\w\\.]*}(\\s|$)";
	Pattern p = Pattern.compile(exp);
	Matcher matcher = p.matcher(call);
	String resultString = new String(call);
	while (matcher.find()) {
		for (int i = 0; i <= matcher.groupCount(); i++) {
			String unQuatedparam = (matcher.group(i));
			if (StringUtil.isNotBlank(unQuatedparam)) {
				String quatedparam =
						unQuatedparam.replace("${", "'${").replace("}", "}'");
				resultString = new String(StringUtil.replace(new String(resultString),
						unQuatedparam, quatedparam));
			}
		}
	}
	return resultString;
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:19,代碼來源:BDDDefinitionHelper.java

示例9: getTestsFromFile

import com.qmetry.qaf.automation.util.StringUtil; //導入依賴的package包/類
@Factory
public Object[] getTestsFromFile(ITestContext context) {

	if (null != context) {
		includeGroups = Arrays.asList(context.getIncludedGroups());
		excludeGroups = Arrays.asList(context.getExcludedGroups());
	}

	String sanariosloc = MetaDataScanner.getParameter(context, "scenario.file.loc");
	if (StringUtil.isNotBlank(sanariosloc)) {
		ConfigurationManager.getBundle().setProperty("scenario.file.loc", sanariosloc);
	}

	System.out.printf("include groups %s\n exclude groups: %s Scanarios location: %s \n", includeGroups,
			excludeGroups, sanariosloc);
	logger.info("scenario.file.loc"
			+ ConfigurationManager.getBundle().getStringArray("scenario.file.loc", "./scenarios"));
	for (String fileName : ConfigurationManager.getBundle().getStringArray("scenario.file.loc", "./scenarios")) {
		process(fileName);
	}

	logger.info("total test found: " + scenarios.size());
	return scenarios.toArray(new Object[scenarios.size()]);

}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:26,代碼來源:ScenarioFactory.java

示例10: parseStepCall

import com.qmetry.qaf.automation.util.StringUtil; //導入依賴的package包/類
protected TestStep parseStepCall(Object[] statement, String referece, int lineNo) {

		String currStepName = (String) statement[0];
		Object[] currStepArgs = null;
		try {
			currStepArgs = (StringUtil.isNotBlank((String) statement[1]))
					? gson.fromJson((String) statement[1], Object[].class) : null;
		} catch (JsonSyntaxException jse) {
			logger.error(jse.getMessage() + statement[1], jse);
		}
		String currStepRes = statement.length > 2 ? (String) statement[2] : "";

		StringTestStep step = new StringTestStep(currStepName, currStepArgs);
		step.setResultParamName(currStepRes);
		step.setFileName(referece);
		step.setLineNumber(lineNo);

		return step;

	}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:21,代碼來源:AbstractScenarioFileParser.java

示例11: addAssertionLog

import com.qmetry.qaf.automation.util.StringUtil; //導入依賴的package包/類
public void addAssertionLog(String msg, MessageTypes type) {
	CheckpointResultBean bean = new CheckpointResultBean();
	bean.setMessage(msg);
	bean.setType(type);
	boolean added = addCheckpoint(bean);

	if (added && StringUtil.isBlank(getLastCapturedScreenShot())
			&& ((ApplicationProperties.FAILURE_SCREENSHOT.getBoolenVal(true) && (type == MessageTypes.Fail))
					|| ((type != MessageTypes.Info)
							&& ApplicationProperties.SUCEESS_SCREENSHOT.getBoolenVal(false)))) {

		takeScreenShot();
	}
	bean.setScreenshot(getLastCapturedScreenShot());
	setLastCapturedScreenShot("");

	if (type == MessageTypes.Fail) {
		verificationErrors.append(msg);
	}

}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:22,代碼來源:AssertionService.java

示例12: captureScreenShot

import com.qmetry.qaf.automation.util.StringUtil; //導入依賴的package包/類
private String captureScreenShot() {
	String filename = StringUtil.createRandomString(getTestCaseName()) + ".png";
	try {
		selenium.captureEntirePageScreenshot(getScreenShotDir() + filename, "");
	} catch (Exception e) {
		try {
			selenium.windowFocus();
		} catch (Throwable t) {
			logger.error(t);
		}
		selenium.captureScreenshot(getScreenShotDir() + filename);
	}
	lastCapturedScreenShot = filename;
	logger.info("Captured screen shot: " + lastCapturedScreenShot);
	return filename;
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:17,代碼來源:AssertionService.java

示例13: getResults

import com.qmetry.qaf.automation.util.StringUtil; //導入依賴的package包/類
@Override
public String getResults(Collection<CheckpointResultBean> bean) {
	StringBuilder sb = new StringBuilder(SEC_Header);
	for (CheckpointResultBean checkpointResultBean : bean) {
		String msg = checkpointResultBean.getMessage();
		if (StringUtil.isNotBlank(checkpointResultBean.getScreenshot())) {
			msg = msg + formatScreenshot(checkpointResultBean.getScreenshot());
		}
		sb.append(MessageTypes.valueOf(checkpointResultBean.getType()).formatMessage(msg));
		if (!checkpointResultBean.getSubCheckPoints().isEmpty()) {
			sb.append(getResults(checkpointResultBean.getSubCheckPoints()));
		}
	}
	sb.append(SEC_Footer);
	return sb.toString();
}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:17,代碼來源:HtmlCheckpointResultFormatter.java

示例14: addAssertionLog

import com.qmetry.qaf.automation.util.StringUtil; //導入依賴的package包/類
public void addAssertionLog(String msg, MessageTypes type) {
	logger.debug(type.formatText(msg));
	CheckpointResultBean bean = new CheckpointResultBean();
	bean.setMessage(msg);
	bean.setType(type);
	boolean added = addCheckpoint(bean);

	if (added && StringUtil.isBlank(getLastCapturedScreenShot())
			&& ((ApplicationProperties.FAILURE_SCREENSHOT.getBoolenVal(true) && (type.isFailure()))
					|| ((type != MessageTypes.Info)
							&& ApplicationProperties.SUCEESS_SCREENSHOT.getBoolenVal(false)))) {

		takeScreenShot();
	}
	bean.setScreenshot(getLastCapturedScreenShot());
	setLastCapturedScreenShot("");

	if (type == MessageTypes.Fail) {
		int verificationErrors = getVerificationErrors() +1;
		getContext().setProperty(VERIFICATION_ERRORS, verificationErrors);
	}

}
 
開發者ID:qmetry,項目名稱:qaf,代碼行數:24,代碼來源:QAFTestBase.java

示例15: beforeInitialize

import com.qmetry.qaf.automation.util.StringUtil; //導入依賴的package包/類
@Override
public void beforeInitialize(Capabilities desiredCapabilities) {
	if (ConfigurationUtils.getBaseBundle().getString("remote.server", "").contains("perfecto")) {
		String eclipseExecutionId = ConfigurationUtils.getExecutionIdCapability();

		if (StringUtil.isNotBlank(eclipseExecutionId)) {
			((DesiredCapabilities) desiredCapabilities)
					.setCapability("eclipseExecutionId", eclipseExecutionId);
		}
	}
}
 
開發者ID:Project-Quantum,項目名稱:Quantum,代碼行數:12,代碼來源:PerfectoDriverListener.java


注:本文中的com.qmetry.qaf.automation.util.StringUtil類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。