예제 #1
0
  @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));
  }
 @After
 public void tearDown() throws Exception {
   String verificationErrorString = verificationErrors.toString();
   if (!"".equals(verificationErrorString)) {
     fail(verificationErrorString);
   }
 }
예제 #3
0
 /**
  * 已匹配的终端数据和终端属性数据
  *
  * @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();
 }
예제 #4
0
  @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());
    }
  }
 @After
 public void tearDown() throws Exception {
   recorder.stopRecording();
   driver.quit();
   String verificationErrorString = verificationErrors.toString();
   if (!"".equals(verificationErrorString)) {
     fail(verificationErrorString);
   }
 }
 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 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());
  }
예제 #8
0
 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());
 }
예제 #9
0
 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());
 }
예제 #10
0
 /**
  * 最终终端数据
  *
  * @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();
 }
예제 #11
0
  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()));
  }
예제 #12
0
  /**
   * 组装终端核心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;
  }
예제 #13
0
 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 (bean == null) {
        final StringBuffer found = new StringBuffer();

        for (final TaskModel task : taskServiceStub.getTasks()) {
          if (task instanceof ProcessTaskModel) {
            found.append(((ProcessTaskModel) task).getAction()).append("; ");
          }
        }

        assertNotNull(
            "No tasks found for bean " + bean + ", actions: " + found.toString(), processTaskModel);
      }

    } catch (final RetryLaterException e) {
      fail(e.toString());
    }
  }
예제 #15
0
 public String toString() {
   return buf.toString();
 }