/** * Log a step into test case result. * * @param tcName * @param result * @param msg */ public void logStep(String tcName, String result, String msg) { if ("".equals(tcName)) { tcName = oi.logRunningTC; if (!"".equals(result.trim())) { if ("false".equals(StringUtils.lowerCase(result.trim()))) { oi.logList.add( tcName + "," + result.trim() + ",At step " + init.currentStep + " of " + init.sumStep + "," + msg.trim()); } else { oi.logList.add(tcName + "," + result.trim() + "," + msg.trim()); } } } else { if (StringUtils.left(tcName, 4).equals("test")) { tcName = StringUtils.mid(tcName, 4, tcName.length()); } oi.logRunningTC = tcName; if ("".equals(result.trim())) { oi.logList.add(tcName + "," + init.logTcStart); } else { oi.logList.add(tcName + "," + result.trim()); } } }
@Override public boolean isPasswordValid(String encPass, String rawPass, Object token) { /* * encPass -> Passwort aus UserDetais rawPass -> Passwort aus dem * Eingabefels token -> Ist null oder ein Md5Token und kommt aus * User.getToken() */ if (encPass == null) { /* * Passwort auf der DB ist null Da null nicht im Webformular * eingegeben werden kann, wird ein false geliefert. (vergleich ist * nicht notwendig!) */ return false; } if (token == null) { /* * Kein Token Verwenden. Einfach nur die Passwörter vergleichen. */ return encPass.equals(rawPass); } /* * Ab hier wird ein Token verwendet! Wenn man in Debugger wartet, kann * der eingegebene Token Ablaufen! */ if (rawPass.length() <= Md5Token.TOKEN_LENGTH) { /* * Passwort ist zu klein, um einen Token zu enthalten! */ return false; } /* * Passwort ohne Token ermitteln */ String newRawPass = StringUtils.left(rawPass, rawPass.length() - Md5Token.TOKEN_LENGTH); if (encPass.equals(newRawPass)) { /* * eingegebenes Token ermitteln */ String rawToken = StringUtils.right(rawPass, Md5Token.TOKEN_LENGTH); Md5Token md5Token = (Md5Token) token; /* * Token prüfen */ return md5Token.isEqualsToken(rawToken); } return false; }
/** * Take a screenshoot, log an Running Error into test result file. * * @param e * @param dr * @param tcName * @throws Exception */ public void logCaseFail(String e, WebDriver dr, String tcName) throws Exception { try { if (tcName.trim() == "") { tcName = oi.logRunningTC; } if (StringUtils.left(tcName, 4).equals("test")) { tcName = StringUtils.mid(tcName, 4, tcName.length()); } // log fail System.out.println(init.logErrorPrefixMsg + "Test Case Name:" + tcName + " ERROR: " + e); String tmp = "" + ran.nextInt(100000); String picName = oi.reportFilePath + "pic-" + tmp + ".jpg"; String tmpStepLog = ""; tmpStepLog = ",At step " + init.currentStep + " of " + init.sumStep; if (e.contains("\n")) { oi.logList.add( tcName + "," + init.logErrorPrefixMsg + tmpStepLog + "," + " Photo: " + picName + "," + e.toString().substring(0, e.toString().indexOf("\n"))); } else { oi.logList.add( tcName + "," + init.logErrorPrefixMsg + tmpStepLog + "," + " Photo: " + picName + "," + e); } // taking screenshot org.apache.commons.io.FileUtils.copyFile( ((TakesScreenshot) dr).getScreenshotAs(OutputType.FILE), new File(picName)); } catch (Exception e1) { throw e1; } // oi.reportFilePath = oi.reportFilePath + "error-" + tmp + "-"; }
public static QName stringToQName(String text) { if (StringUtils.isEmpty(text)) { return null; } int index = text.lastIndexOf(QNAME_DELIMITER); String namespace = StringUtils.left(text, index); String localPart = StringUtils.right(text, text.length() - index - 1); if (StringUtils.isEmpty(localPart)) { return null; } return new QName(namespace, localPart); }
/** * 현재 사용자가 선호하는 언어를 갱신한다. * * <p>쿠키나 Accept-Language HTTP 헤더에 선호하는 언어가 설정되어 있는 경우, 그것을 현재 로그인한 사용자가 선호하는 언어로 설정한다. */ public static void updatePreferredLanguage() { Http.Request request = Http.Context.current().request(); User user = UserApp.currentUser(); if (user.isAnonymous()) { return; } if (request.acceptLanguages().isEmpty() && request.cookie(Play.langCookieName()) == null) { return; } String code = StringUtils.left(Http.Context.current().lang().code(), 255); if (!code.equals(user.lang)) { user.lang = code; user.update(); } }
private static AmazonECSClient getAmazonECSClient(String credentialsId, String regionName) { final AmazonECSClient client; AmazonWebServicesCredentials credentials = getCredentials(credentialsId); if (credentials == null) { // no credentials provided, rely on com.amazonaws.auth.DefaultAWSCredentialsProviderChain // to use IAM Role define at the EC2 instance level ... client = new AmazonECSClient(); } else { if (LOGGER.isLoggable(Level.FINE)) { String awsAccessKeyId = credentials.getCredentials().getAWSAccessKeyId(); String obfuscatedAccessKeyId = StringUtils.left(awsAccessKeyId, 4) + StringUtils.repeat("*", awsAccessKeyId.length() - (2 * 4)) + StringUtils.right(awsAccessKeyId, 4); LOGGER.log( Level.FINE, "Connect to Amazon ECS with IAM Access Key {1}", new Object[] {obfuscatedAccessKeyId}); } client = new AmazonECSClient(credentials); } client.setRegion(getRegion(regionName)); return client; }
public static String left(String str, int length) { return org.apache.commons.lang.StringUtils.left(str, length); }
/** * 取给定字符串起始指定个字符的子字符串 * * @param str * @param len * @return */ public static String left(String str, int len) { return StringUtils.left(str, len); }