/** * 已匹配的终端数据和终端属性数据 * * @param filePath * @return */ public String getKnownTerminalSQL(String filePath) { StringBuffer sb = new StringBuffer(); try { List<String[]> list = CvsFileParser.getCSV(filePath, 100001); int i = 0; for (String[] s : list) { if (i % 5000 == 0) { sb.append("LOCK TABLES tbl_tmp_08 WRITE;\r\n"); sb.append("insert into tbl_tmp_08 (d_phonenum,d_tac,d_bistrict) values \r\n"); } String phoneNum = s[0]; String imei = s[2]; String bd = s[1]; sb.append("(\'" + phoneNum + "\',\'" + imei + "\',\'" + bd + "\')"); i++; if (i % 5000 == 0) { sb.append(";").append("\r\n"); sb.append("UNLOCK TABLES;"); } else { if (i < list.size()) { sb.append(",").append("\r\n"); } } } sb.append(";").append("\r\n"); sb.append("UNLOCK TABLES;"); } catch (Exception e) { e.printStackTrace(); } return sb.toString(); }
public static StringBuffer sbWinners(StringBuffer sb, NameVotingSystem.NameVote[] winners) { for (int i = 0; i < winners.length; i++) { sb.append(winners[i].name); sb.append(": "); sb.append(winners[i].rating); } return sb; }
private String readAll(BufferedReader input) throws IOException { String line = null; StringBuffer capture = new StringBuffer(); while ((line = input.readLine()) != null) { capture.append(line); capture.append("\n"); } return capture.toString(); }
@After public void resetServices() { final List<TaskModel> tasks = taskServiceStub.cleanup(); final StringBuffer msg = new StringBuffer(); for (final TaskModel task : tasks) { final ProcessTaskModel processTask = (ProcessTaskModel) task; msg.append(processTask.getAction()).append(", "); } }
@Test public void testAudioMD_noMD5() throws Exception { Fits fits = new Fits(); // First generate the FITS output File input = new File("testfiles/test.wav"); FitsOutput fitsOut = fits.examine(input); XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat()); String actualXmlStr = serializer.outputString(fitsOut.getFitsXml()); // Read in the expected XML file Scanner scan = new Scanner(new File("testfiles/output/FITS_test_wav_NO_MD5.xml")); String expectedXmlStr = scan.useDelimiter("\\Z").next(); scan.close(); // Set up XMLUnit XMLUnit.setIgnoreWhitespace(true); XMLUnit.setNormalizeWhitespace(true); Diff diff = new Diff(expectedXmlStr, actualXmlStr); // Initialize attributes or elements to ignore for difference checking diff.overrideDifferenceListener( new IgnoreNamedElementsDifferenceListener( "version", "toolversion", "dateModified", "fslastmodified", "lastmodified", "startDate", "startTime", "timestamp", "fitsExecutionTime", "executionTime", "filepath", "location")); DetailedDiff detailedDiff = new DetailedDiff(diff); // Display any Differences List<Difference> diffs = detailedDiff.getAllDifferences(); if (!diff.identical()) { StringBuffer differenceDescription = new StringBuffer(); differenceDescription.append(diffs.size()).append(" differences"); System.out.println(differenceDescription.toString()); for (Difference difference : diffs) { System.out.println(difference.toString()); } } assertTrue("Differences in XML", diff.identical()); }
public void test2() { Cnd condition = Cnd.where("d_hsman_name", "=", "apple"); List<Tac> list = dao.search(Tac.class, condition); StringBuffer sb = new StringBuffer(" in (\t"); for (Tac tac : list) { sb.append("\'" + tac.getTac() + "\'").append(","); } sb.append("\t)"); // ViewTerminal v = dao.findByCondition(ViewTerminal.class, condition); // System.out.println(" >> "+Json.toJson(v)); System.out.println("" + sb.toString()); }
@After public void resetServices() { final List<TaskModel> tasks = taskServiceStub.cleanup(); final StringBuffer msg = new StringBuffer(); for (final TaskModel task : tasks) { final ProcessTaskModel processTask = (ProcessTaskModel) task; msg.append(processTask.getAction()).append(", "); } assertTrue("tasks should be empty after test execution. Left: " + msg, tasks.isEmpty()); }
@BeforeClass public static void MyTestFixtureSetUp() { StringBuffer sbf = new StringBuffer(); sbf.append("<root>\n"); sbf.append("\t<level1>\n"); sbf.append("\t<value>Wert 1</value>\n"); sbf.append("\t<value>Wert 2</value>\n"); sbf.append("\t<value>Wert 3</value>\n"); sbf.append("\t</level1>\n"); sbf.append("</root>\n"); try { BufferedWriter bwr = new BufferedWriter(new FileWriter(new File("OKW_XmlReaderTestXML.xml"))); // write contents of StringBuffer to a file bwr.write(sbf.toString()); // flush the stream bwr.flush(); // close the stream bwr.close(); } catch (IOException e) { Assert.fail(e.getMessage()); } }
@Test public void testOtsi() throws Exception { driver.get(baseUrl + "/"); driver.findElement(By.linkText("Kandidaadid")).click(); // Warning: waitForTextPresent may require manual changes for (int second = 0; ; second++) { if (second >= 60) fail("timeout"); try { if (driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Vana Kala[\\s\\S]*$")) break; } catch (Exception e) { } Thread.sleep(1000); } driver.findElement(By.id("nimi")).clear(); driver.findElement(By.id("nimi")).sendKeys("Magdalena"); try { assertEquals("Magdalena", driver.findElement(By.id("nimi")).getAttribute("value")); } catch (Error e) { verificationErrors.append(e.toString()); } driver.findElement(By.id("sButton")).click(); // Warning: waitForTextPresent may require manual changes for (int second = 0; ; second++) { if (second >= 60) fail("timeout"); try { if (driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Magdalena Malejeva[\\s\\S]*$")) break; } catch (Exception e) { } Thread.sleep(1000); } // Warning: verifyTextNotPresent may require manual changes try { assertFalse( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Vana Kala[\\s\\S]*$")); } catch (Error e) { verificationErrors.append(e.toString()); } }
private void Location() throws IOException { // Click Location driver .findElement( By.xpath( "//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Location\")]")) .click(); // Click West Checkbox // TODO Do not use number in Locator driver.findElement(By.xpath("//fieldset[6]/div/div[4]/div/div[3]/input")).click(); // Click South Checkbox // TODO Do not use number in Locator driver.findElement(By.xpath("//fieldset[6]/div/div[4]/div/div[6]/input")).click(); // Click Apply driver.findElement(By.id("edit-location-apply-filter")).click(); // Check Result Received or Not try { assertTrue( func.isTextPresent(driver.findElement(By.className("search-total-results")).getText())); } catch (Error e) { verificationErrors.append(e.toString()); } // Click All Selections driver.findElement(By.linkText("Clear All Selections")).click(); }
private void ActivitiesOfInterest() throws IOException { // Click Activities of Interest driver .findElement( By.xpath( "//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Activities of Interest\")]")) .click(); // Click Student Newspaper Checkbox // TODO Do not use number in locator driver.findElement(By.xpath("//div[11]/input")).click(); // Click TV Station Checkbox // TODO Do not use number in locator driver.findElement(By.xpath("//div[13]/input")).click(); // Click Apply driver.findElement(By.id("edit-activities-interests-apply-filter")).click(); // Check Result Received or Not try { assertTrue( func.isTextPresent(driver.findElement(By.className("search-total-results")).getText())); } catch (Error e) { verificationErrors.append(e.toString()); } // Click All Selections driver.findElement(By.linkText("Clear All Selections")).click(); }
private void TypesOfSchool() throws IOException { // Click Type of School driver.findElement(By.cssSelector("strong")).click(); // Click Private driver.findElement(By.id("edit-public-private-private")).click(); // Move School Size Slider // TODO Slider not working properly WebElement Slider1 = driver.findElement(By.id("population_jq_slider")); Actions moveSlider1 = new Actions(driver); Action action1 = moveSlider1.dragAndDropBy(Slider1, 0, 10).build(); action1.perform(); // Select Religious Affiliation new Select(driver.findElement(By.id("edit-religious-affiliation"))) .selectByVisibleText("Church of Christ"); // Move Tuition Range Slider // TODO Slider not working properly WebElement Slider2 = driver.findElement(By.id("tuition_range_jq_slider")); Actions moveSlider2 = new Actions(driver); Action action2 = moveSlider2.dragAndDropBy(Slider2, 0, 10).build(); action2.perform(); // Click Apply driver.findElement(By.id("edit-type-of-school-apply-filter")).click(); // Check Result Received or Not try { assertTrue( func.isTextPresent(driver.findElement(By.className("search-total-results")).getText())); } catch (Error e) { verificationErrors.append(e.toString()); } // Click All Selections driver.findElement(By.linkText("Clear All Selections")).click(); }
private void AreaOfStudy() throws IOException, InterruptedException { // Click Area of School driver .findElement( By.xpath( "//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Area of Study\")]")) .click(); // Select One Area Study new Select(driver.findElement(By.id("edit-area-of-study-parent"))) .selectByVisibleText("Area, Ethnic, Cultural, and Gender Studies"); // Wait For Another Select List To Load Thread.sleep(5000); // Select Subareas of Study new Select(driver.findElement(By.xpath("//div[@id='child-area-of-study-wrapper']//select"))) .selectByVisibleText("Area, Ethnic, Cultural, and Gender Studies, Other"); // Click Apply driver.findElement(By.id("edit-area-of-study-apply-filter")).click(); // Check Result Received or Not try { assertTrue( func.isTextPresent(driver.findElement(By.className("search-total-results")).getText())); } catch (Error e) { verificationErrors.append(e.toString()); } // Click All Selections driver.findElement(By.linkText("Clear All Selections")).click(); }
private void SpecialNeeds() throws IOException { // Click Special Needs driver .findElement( By.xpath( "//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Special Needs\")]")) .click(); // Select Special Needs Select SpecialNeeds = new Select(driver.findElement(By.id("edit-special-needs"))); // Select Learning Center SpecialNeeds.selectByVisibleText("Learning Center"); // Select Early Syllabus SpecialNeeds.selectByVisibleText("Early syllabus"); // Click Apply driver.findElement(By.id("edit-special-needs-apply-filter")).click(); // Check Result Received or Not try { assertTrue( func.isTextPresent(driver.findElement(By.className("search-total-results")).getText())); } catch (Error e) { verificationErrors.append(e.toString()); } // Click All Selections driver.findElement(By.linkText("Clear All Selections")).click(); }
@After public void tearDown() throws Exception { String verificationErrorString = verificationErrors.toString(); if (!"".equals(verificationErrorString)) { fail(verificationErrorString); } }
/** * 最终终端数据 * * @param filePath * @return */ public String getTerminalSQL(String filePath) { StringBuffer sb = new StringBuffer(); try { List<String[]> list = CvsFileParser.getCSV(filePath, 100001); int i = 0; for (String[] s : list) { int support = 0; int supprotType = 0; if (i % 5000 == 0) { sb.append("LOCK TABLES tbl_bussiness_simplify WRITE;\r\n"); sb.append( "insert into tbl_bussiness_simplify (d_btype,d_bdistrict,d_phonenum,d_support,d_support_type) values \r\n"); } String phoneNum = s[0]; String bd = s[1]; String gprs = s[2]; String wap = s[3]; String smartPhone = s[4]; String os = s[5]; String wifi = s[6]; if (smartPhone.equals("1") || os.equals("1")) { support = 1; supprotType = 2; } else { if (wap.equals("1") && gprs.equals("1")) { support = 1; supprotType = 1; } } sb.append("(0,\'" + bd + "\',\'" + phoneNum + "\'," + support + "," + supprotType + ")"); i++; if (i % 5000 == 0) { sb.append(";").append("\r\n"); sb.append("UNLOCK TABLES;"); } else { if (i < list.size()) { sb.append(",").append("\r\n"); } } } sb.append(";").append("\r\n"); sb.append("UNLOCK TABLES;"); } catch (Exception e) { e.printStackTrace(); } return sb.toString(); }
@After public void tearDown() throws Exception { recorder.stopRecording(); driver.quit(); String verificationErrorString = verificationErrors.toString(); if (!"".equals(verificationErrorString)) { fail(verificationErrorString); } }
public static void testGet() throws IOException { HttpClient client = new DefaultHttpClient(); StringBuffer url = new StringBuffer("http://bassice.gicp.net/webchat/token/gh_b817172873c4"); url.append("?") .append("signature=5cbeee310990d9c54d9843b9a2dff96ec30d3565") .append("&") .append("timestamp=1371608072") .append("&") .append("nonce=1372170854") .append("&") .append("echostr=5976194625791363975"); HttpGet get = new HttpGet(url.toString()); System.out.println(get); HttpResponse response = client.execute(get); System.out.println(EntityUtils.toString(response.getEntity())); }
@Test public void testWeather() throws Exception { driver.get(baseUrl + "/"); driver.findElement(By.linkText("Edmonton")).click(); for (int second = 0; ; second++) { if (second >= 60) fail("timeout"); try { if (isElementPresent(By.id("cityjump"))) break; } catch (Exception e) { } Thread.sleep(1000); } // Warning: verifyTextPresent may require manual changes try { assertTrue( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Current Conditions[\\s\\S]*$")); } catch (Error e) { verificationErrors.append(e.toString()); } // Warning: verifyTextPresent may require manual changes try { assertTrue( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Forecast[\\s\\S]*$")); } catch (Error e) { verificationErrors.append(e.toString()); } // Warning: verifyTextPresent may require manual changes try { assertTrue( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Edmonton City Centre Airport[\\s\\S]*$")); } catch (Error e) { verificationErrors.append(e.toString()); } }
/** * 组装终端核心SQL * * @param filePath * @return */ public HashMap<String, String> getTerminalCoreSQL(String filePath) { HashMap<String, String> map = new HashMap<String, String>(); try { List<String[]> list = CvsFileParser.getCSV(filePath); // sb.append("insert into tbl_terminal_core // (d_hsman_ch,d_hsman,d_hstype_ch,d_hstype,d_tac,d_gprs,d_wap,d_smartphone,d_os,d_wifi,d_createtime) values "); for (String[] s : list) { StringBuffer sb = new StringBuffer(); String tac = s[0]; String hsman = s[1]; String hsmanen = s[2]; String hstype = s[3]; String hstypeen = s[4]; String gprs = s[5]; String wap = s[6]; String smartphone = s[7]; String os = s[8]; String wifi = s[9]; sb.append("(\'" + hsman + "\',") .append("\'" + hsmanen + "\',") .append("\'" + hstype + "\',") .append("\'" + hstypeen + "\',") .append("\'" + tac + "\',") .append(gprs) .append(","); sb.append(wap) .append(",") .append(smartphone) .append(",") .append(os) .append(",") .append(wifi) .append(",") .append("now()),"); sb.append("\r\n"); map.put(tac, sb.toString()); } } catch (Exception e) { e.printStackTrace(); } return map; }
public void testSystem(Class ivc, int numc, int numv) throws java.lang.InstantiationException, java.lang.IllegalAccessException { IndexVotable iv = (IndexVotable) ivc.newInstance(); IndexVotable nv = (IndexVotable) ivc.newInstance(); generateRandomVotes(numc, numv); for (int i = 0; i < numv; i++) { iv.voteIndexVoteSet(ivotes[i]); nv.voteRating(votes[i]); } NameVotingSystem.NameVote[] ivw = iv.getWinners(); NameVotingSystem.NameVote[] nvw = nv.getWinners(); boolean good = SummableVotingSystemTest.winnersEq(ivw, nvw); if (!good) { StringBuffer sb = new StringBuffer("index vote=\n"); sbWinners(sb, ivw); sb.append("name vote=\n"); sbWinners(sb, nvw); fail(sb.toString()); } }
public void run() { try { String line = in.readLine(); while (line != null) { buf.append(line); buf.append('\n'); line = in.readLine(); } } catch (IOException ioe) { System.err.println("can't read output from process"); } }
protected void assertStep(final BusinessProcessModel process, final String bean) throws InterruptedException { LOG.info("assertStep action = " + bean); try { final ProcessTaskModel processTaskModel = taskServiceStub.runProcessTask(bean); if (processTaskModel == null) { final StringBuffer found = new StringBuffer(); for (final TaskModel task : taskServiceStub.getTasks()) { if (task instanceof ProcessTaskModel) { found.append(((ProcessTaskModel) task).getAction()).append("; "); } } assertNotNull("No task found for bean " + bean + ", action(s): " + found, processTaskModel); } } catch (final RetryLaterException e) { fail(e.toString()); } }
private void SearchButton() throws IOException { // Enter Text To Be Search driver.findElement(By.id("edit-keys")).clear(); driver.findElement(By.id("edit-keys")).sendKeys("Abilene"); // Click Search driver.findElement(By.id("edit-submit")).click(); // Check Result Received or Not try { assertTrue( func.isTextPresent(driver.findElement(By.className("search-total-results")).getText())); } catch (Error e) { verificationErrors.append(e.toString()); } // Click All Selections driver.findElement(By.linkText("Clear All Selections")).click(); }
@Test( dataProvider = "addNewAgentApplicant", dataProviderClass = applicantDataInternationalNewApplicant.class) public void testEnterDataAddNewApplicant( String loginEmail, String loginPassword, String firstName, String lastName, String birthDay, String birthMonth, String birthYear) throws Exception { // Add new applicant to Agent Thread.sleep(300); // Test case from HERE to CITIZENSHIP will fail if the applicant already exists. driver.findElement(By.id("field-email")).clear(); driver.findElement(By.id("field-email")).sendKeys(loginEmail); Thread.sleep(150); driver.findElement(By.id("field-confirmEmail")).clear(); driver.findElement(By.id("field-confirmEmail")).sendKeys(loginEmail); Thread.sleep(100); driver.findElement(By.id("field-firstName")).clear(); driver.findElement(By.id("field-firstName")).sendKeys(firstName); driver.findElement(By.id("field-lastName")).clear(); driver.findElement(By.id("field-lastName")).sendKeys(lastName); new Select(driver.findElement(By.name("dayOfBirth"))).selectByVisibleText(birthDay); new Select(driver.findElement(By.name("monthOfBirth"))).selectByVisibleText(birthMonth); new Select(driver.findElement(By.name("yearOfBirth"))).selectByVisibleText(birthYear); driver.findElement(By.xpath("//button[@type='submit']")).click(); System.out.println("Applicant = " + loginEmail); Thread.sleep(500); try { assertEquals( "Profile Information", driver.findElement(By.cssSelector("h3.col-xs-12")).getText()); } catch (Error e) { screenShots.takeScreenShot("enterDataAddNewAppl"); verificationErrors.append(e.toString()); } }
public void generatorTerminalCore() { StringBuffer sb = new StringBuffer(); sb.append("LOCK TABLES `tbl_terminal_core` WRITE;\r\n"); sb.append( "insert into tbl_terminal_core (d_hsman_ch,d_hsman,d_hstype_ch,d_hstype,d_tac,d_gprs,d_wap,d_smartphone,d_os,d_wifi,d_createtime) values \r\n"); HashMap<String, String> map = getTerminalCoreSQL("终端核心表_02.csv"); Iterator it = map.keySet().iterator(); while (it.hasNext()) { String key = (String) it.next(); String sql = map.get(key); sb.append(sql); } sb.append("UNLOCK TABLES;"); // System.out.println(sb.toString()); IOUtil.createFile(sb.toString(), "SQL_终端核心表_03" + System.currentTimeMillis()); }
@Test public void testRegistreerimine() throws Exception { driver.get(baseUrl + "/login"); driver.findElement(By.xpath("//button[5]")).click(); driver.findElement(By.id("kasutajanimi")).clear(); driver.findElement(By.id("kasutajanimi")).sendKeys("Testkasutaja"); driver.findElement(By.id("eesnimi")).clear(); driver.findElement(By.id("eesnimi")).sendKeys("Test"); driver.findElement(By.id("perenimi")).clear(); driver.findElement(By.id("perenimi")).sendKeys("Kasutaja"); driver.findElement(By.id("parool")).clear(); driver.findElement(By.id("parool")).sendKeys("testkasutaja"); driver.findElement(By.id("email")).clear(); driver.findElement(By.id("email")).sendKeys("*****@*****.**"); driver.findElement(By.id("telnr")).clear(); driver.findElement(By.id("telnr")).sendKeys("55123123"); driver.findElement(By.id("regamisnupp")).click(); try { assertEquals( "Registreerimine õnnestus!", driver.findElement(By.xpath("//div/div/div/div")).getText()); } catch (Error e) { verificationErrors.append(e.toString()); } }
private void Sports() throws IOException { // Click Sports driver .findElement( By.xpath("//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Sports\")]")) .click(); // Select Sports Select Sports = new Select(driver.findElement(By.id("edit-varsity-sports"))); // Select Baseball Sports.selectByVisibleText("baseball"); // Select Basketball Sports.selectByVisibleText("basketball"); // Click Apply driver.findElement(By.id("edit-varsity-sports-apply-filter")).click(); // Check Result Received or Not try { assertTrue( func.isTextPresent(driver.findElement(By.className("search-total-results")).getText())); } catch (Error e) { verificationErrors.append(e.toString()); } // Click All Selections driver.findElement(By.linkText("Clear All Selections")).click(); }
@Test( dataProvider = "addNewApplicant", dataProviderClass = applicantDataDomesticNewApplicant.class) public void testRegisterAccount( String loginEmail, String loginPassword, String firstName, String lastName, String birthDay, String birthMonth, String birthYear) throws Exception { // Register New Account driver.findElement(By.id("field-firstName")).clear(); driver.findElement(By.id("field-firstName")).sendKeys(firstName); driver.findElement(By.id("field-lastName")).clear(); driver.findElement(By.id("field-lastName")).sendKeys(lastName); new Select(driver.findElement(By.name("day"))).selectByVisibleText(birthDay); new Select(driver.findElement(By.name("month"))).selectByVisibleText(birthMonth); new Select(driver.findElement(By.name("year"))).selectByVisibleText(birthYear); driver.findElement(By.id("field-email")).clear(); driver.findElement(By.id("field-email")).sendKeys(loginEmail); driver.findElement(By.id("field-confirmEmail")).clear(); driver.findElement(By.id("field-confirmEmail")).sendKeys(loginEmail); driver.findElement(By.id("field-password")).clear(); driver.findElement(By.id("field-password")).sendKeys(loginPassword); driver.findElement(By.id("field-confirmPassword")).clear(); driver.findElement(By.id("field-confirmPassword")).sendKeys(loginPassword); driver.findElement(By.id("field-terms")).click(); driver.findElement(By.xpath("(//button[@type='submit'])[2]")).click(); try { assertEquals( "Successfully registered.", driver.findElement(By.cssSelector("div.alert.alert-success")).getText()); } catch (Error e) { screenShots.takeScreenShot("registerAcct_outp"); verificationErrors.append(e.toString()); } System.out.println("Applicant = " + loginEmail + " Password = " + loginPassword); // Write out the Applicants email address to the output file created in gotoSite.java // First create object of java FileWriter and BufferedWriter class. String WriteFile = generateFileName(); FileWriter FW = new FileWriter(WriteFile); BufferedWriter BW = new BufferedWriter(FW); BW.write(loginEmail); // Writing applicants login to File. BW.newLine(); // To write next string on new line. BW.write(lastName); // Writing applicants lastname to File. BW.newLine(); // To write next string on new line. BW.write(firstName); // Writing applicants first name to File. BW.newLine(); // To write next string on new line. BW.close(); }
public String toString() { return buf.toString(); }