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; }
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()); }
/** * 已匹配的终端数据和终端属性数据 * * @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(); }
@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 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 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(); }
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 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(); }
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()); }
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 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(); }
@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()); } }
@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(", "); } }
/** * 组装终端核心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; }
@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 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"); } }
@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()); } }
/** * 最终终端数据 * * @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(); }
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 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())); }
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()); } }
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()); } }
@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(); }
public void test3(String fileName) throws ClassNotFoundException { if (null != dao) { System.out.println(" >> dao is not null"); // List<String[]> list = CvsFileParser.getCSV("tac.csv"); List<String[]> list = CvsFileParser.getCSV(fileName, 1000000); int offset = 0; int foffset = 0; Tac tac = null; // List<String> outL = new ArrayList<String>(); // List<Tac> tList = new ArrayList<Tac>(); HashMap ok = new HashMap(); HashMap failure = new HashMap(); HashMap common = new HashMap(); String ttac = ""; for (String[] s : list) { // Integer i=1; tac = new Tac(); // ttac = s[0]; String phoneNum = s[0]; // String uid = s[2]; String imei = s[1]; String bd = s[2]; // try{ // ttac = imei.substring(0,8); // tac.setTac(ttac); // }catch(Exception e){ // System.err.println(" >> "+imei); // continue; // } // Tac tmp = dao.findByCondition(Tac.class, Cnd.where("d_tac", "=", ttac)); // if(null == tmp){ //// failure.put(phoneNum+"_"+imei, tmp); // foffset ++; // }else{ // //// tList.add(tmp); // ok.put(ttac,tmp); //// if(null != tmp.getHsmanName()){ //// ok.put(tmp.getHsmanName()+"_"+tmp.getHstypeName(), tmp); //// }else{ //// ok.put(tmp.getHsmanNameEn()+"_"+tmp.getHstypeNameEn(), tmp); //// } // offset++; BCOUNT++; // } SB_SQL.append( "insert into tbl_cmdata (d_phonenum,d_imei,d_bistrict) values (\'" + phoneNum + "\',\'" + imei + "\',\'" + bd + "\')"); } // System.out.println(" >> 成功|offset:"+offset); // System.out.println(" >> 失败|foffset:"+foffset); // StringBuffer sb = new StringBuffer(); // System.out.println(" >> 识别的号码数量为:"+ok.size()); // System.out.println(" >> 未被识别的号码数量为:"+failure.size()); // System.out.println(" >> 总共的号码数量:"+common.size()); // int s = 0; // Iterator it = ok.keySet().iterator(); // HashMap<String,String> HSMAN_MAP = new HashMap<String,String>(); // while(it.hasNext()){ // String key = (String)it.next(); // Object obj = ok.get(key) ; // if( null != obj){ // String[] t = key.split("_"); // Tac value = (Tac)obj; // // sb.append(t[0]).append(",").append(t[1]).append(",").append(t[1]).append(",").append(t[1].substring(0,8)).append(",").append(value.getHsmanName()).append(",").append(value.getHsmanNameEn()).append(",").append(value.getHstypeName()).append(",").append(value.getHstypeNameEn()).append(",").append(1).append("\r\n"); // // sb.append(key).append(",").append(value.getHsmanName()).append(",").append(value.getHsmanNameEn()).append(",").append(value.getHstypeName()).append(",").append(value.getHstypeNameEn()).append(",").append(1).append("\r\n"); // // sb.append(value.getHsmanName()).append(",").append(value.getHsmanNameEn()).append(",").append(value.getHstypeName()).append(",").append(value.getHstypeNameEn()).append("\r\n"); // if(null != value.getHsmanName() && !"".equals(value.getHsmanName())){ // HSMAN_MAP.put(value.getHsmanName(), value.getHsmanName()); // }else if(null != value.getHsmanNameEn() && !"".equals(value.getHsmanNameEn())){ // HSMAN_MAP.put(value.getHsmanNameEn(), value.getHsmanNameEn()); // } // s++; // } // } /** * sb.append("\r\n"+s); IOUtil.createFile(sb.toString(), * "2011-07-11_已识别的终端数据_"+"_OK"+System.currentTimeMillis()); */ // Iterator its = HSMAN_MAP.keySet().iterator(); // while(its.hasNext()){ // String value = (String)its.next(); // sb.append(value).append("\r\n"); // } // IOUtil.createFile(sb.toString(), "厂商数据"+"_OK"+System.currentTimeMillis()); // BCOUNT += offset; try { Thread.sleep(2000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { System.out.println(" >> dao is null"); } }
@Test public void transformText() throws XslTransformerException { StringBuffer buf = new StringBuffer(); buf.append("<test>"); buf.append(" <item>one</item>"); buf.append(" <item>two</item>"); buf.append("</test>"); String xml = buf.toString(); buf = new StringBuffer(); buf.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); buf.append("<xsl:stylesheet version=\"2.0\""); buf.append(" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\""); buf.append(">"); buf.append("<xsl:import href=\"layout:common.xsl\" />"); buf.append(" <xsl:template match=\"node()\">"); buf.append(" <xsl:apply-templates />"); buf.append(" </xsl:template>"); buf.append(" "); buf.append(" <xsl:template match=\"/\">"); buf.append(" <html>"); buf.append(" <head>"); buf.append(" <title>"); buf.append(" Test for XSL Transformation"); buf.append(" </title>"); buf.append(" </head>"); buf.append(" <body>"); buf.append(" <xsl:value-of select=\"$root\" /><xsl:apply-templates />"); buf.append(" </body>"); buf.append(" </html>"); buf.append(" </xsl:template>"); buf.append(" "); buf.append(" <xsl:template match=\"test\">"); buf.append(" <h1>XSL Test</h1>"); buf.append(" <xsl:apply-templates />"); buf.append(" </xsl:template>"); buf.append(" "); buf.append(" <xsl:template match=\"item\">"); buf.append(" <h2>Item - <xsl:value-of select=\".\" /></h2>"); buf.append(" </xsl:template>"); buf.append("</xsl:stylesheet>"); String xsl = buf.toString(); XslTransformer transformer = new XslTransformer("/home/guy/workspace/Acumen.CMS/"); transformer.turnOffCaching(); PropertySet properties = new PropertySet(); properties.put("root", "/home/guy/workspace/Acumen.CMS/"); properties.put("controller", "topic"); properties.put("action", "view"); System.out.println(transformer.transformText("xml1", xml, "xsl1", xsl, properties)); System.out.println(transformer.transformText("xml1", xml, "xsl1", xsl, properties)); }
@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 void t20110514() throws Exception { List<String[]> list = CvsFileParser.getCSV("input_2011-05-14.csv"); StringBuffer sb = new StringBuffer(); int i = 0; HashMap map = new HashMap(); for (String[] s : list) { sb.append(s[0]) .append(",") .append(s[1]) .append(",") .append(s[2]) .append(",") .append(s[3]) .append(",") .append(s[4]) .append(",") .append(s[5]) .append(",") .append(s[6]) .append(","); String tac = s[2]; if (null != tac && !"".equals(tac)) { Tac tmp = dao.findByCondition(Tac.class, Cnd.where("d_tac", "=", tac)); try { if (null != tmp.getHsmanName()) { map.put(tmp.getHstypeName(), tmp); } else { map.put(tmp.getHstypeNameEn(), tmp); } // System.out.println(" >> "+tmp.getHsmanName()+"|"+tmp.getHstypeName()); // if(GoogleSearchTools.process(tmp.getHsmanName(), tmp.getHstypeName())){ // System.out.println(" >> 支持GPRS"); // sb.append("支持"); // i++; // }else{ // sb.append("不支持"); // } // }else{ // System.out.println(" >> "+tmp.getHsmanNameEn()+"|"+tmp.getHstypeNameEn()); // if(GoogleSearchTools.process(tmp.getHsmanNameEn(), tmp.getHstypeNameEn())){ // System.out.println(">> 支持GPRS"); // sb.append("支持"); // i++; // }else{ // sb.append("不支持"); // } // } } catch (Exception e) { sb.append("不支持"); } // Thread.sleep(50); } // sb.append("\r\n"); } Iterator it = map.keySet().iterator(); while (it.hasNext()) { String key = (String) it.next(); Object obj = map.get(key); // System.out.println(" >> key:"+key); if (null != obj) { Tac value = (Tac) obj; System.out.println( " >> 该手机号在成功终端中已经存在:" + key + "|" + value.getHsmanName() + "|" + value.getHsmanNameEn() + "|" + value.getHstypeName() + "|" + value.getHstypeNameEn()); } } // System.out.println(sb.toString()); // IOUtil.createFile(sb.toString(), "2011-05-13-1052.csv"); System.out.println(" >> 机型数量:" + map.size()); System.gc(); }