⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testresultsettoxmlconverter.java

📁 java开源的企业总线.xmlBlaster
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
         this.dbPool.update("DROP TABLE TEST_POLL");         changeDetector.checkAgain(null);         sleep(500);         assertEquals("Number of message is wrong", 1, this.updateMap.size());         String xml = (String)this.updateMap.get("db.change.event.TEST_POLL");         assertXpathEvaluatesTo("DROP", "/myRootTag/desc/command/text()", xml);         assertXpathNotExists("/myRootTag/row[@num='0']", xml);         this.updateMap.clear();         writeToFile("db.change.event.DROP", xml);         changeDetector.checkAgain(null);         sleep(500);         assertEquals("Number of message is wrong", 0, this.updateMap.size());      }      log.info("SUCCESS");   }   /**    * @throws Exception Any type is possible    */   public final void testNULLcol() throws Exception {      log.info("Start testNULLcol()");      this.prefs.put("converter.rootName", "myRootTag");      this.prefs.put("db.queryMeatStatement", "");      this.prefs.put("alertScheduler.pollInterval", "0"); // switch off      this.prefs.put("changeDetector.groupColName", ""); // !!! Tests without grouping      this.prefs.put("converter.addMeta", ""+true);      this.prefs.put("changeDetector.detectStatement", "SELECT colKey, col1, col2, ICAO_ID FROM TEST_POLL");      this.prefs.put("mom.topicName", "db.change.event.TEST_POLL");      this.dbPool.update("CREATE TABLE TEST_POLL (colKey NUMBER(10,3), col1 VARCHAR(20), col2 NUMBER(12), ICAO_ID VARCHAR(10))");      //this.dbPool.update("INSERT INTO TEST_POLL (colKey, col1, col2) VALUES ('2.0', 'XXX', '2000')");      this.dbPool.update("INSERT INTO TEST_POLL (colKey) VALUES ('2.0')");            this.processor = createTest(new Info(prefs), this.updateMap);      I_ChangeDetector changeDetector = processor.getChangeDetector();            changeDetector.checkAgain(null);      sleep(500);      assertEquals("Number of message is wrong", 1, this.updateMap.size());      String xml = (String)this.updateMap.get("db.change.event.TEST_POLL");      assertXpathEvaluatesTo("UPDATE", "/myRootTag/desc/command/text()", xml);      assertXpathEvaluatesTo("2", "/myRootTag/row[@num='0']/col[@name='COLKEY']/text()", xml);      assertXpathEvaluatesTo("", "/myRootTag/row[@num='0']/col[@name='COL1']/text()", xml);      assertXpathEvaluatesTo("", "/myRootTag/row[@num='0']/col[@name='COL2']/text()", xml);      assertXpathEvaluatesTo("", "/myRootTag/row[@num='0']/col[@name='ICAO_ID']/text()", xml);      log.info("SUCCESS");   }   private void sleep(long millis) {      try { Thread.sleep(millis); } catch(Exception e) { /* Ignore */ }   }      /**    * If the table does not exist we expect a null ResultSet    * @throws Exception Any type is possible    */   public final void testQueryMeatTableStates() throws Exception {      log.info("Start testQueryMeatTableStates()");      this.prefs.put("converter.rootName", "myRootTag");      this.prefs.put("db.queryMeatStatement", "select 'Bla-'||COLKEY from TEST_POLL");      this.prefs.put("alertScheduler.pollInterval", "0"); // switch off      this.prefs.put("changeDetector.groupColName", ""); // !!! Tests without grouping      this.prefs.put("converter.addMeta", ""+true);      this.prefs.put("changeDetector.detectStatement", "SELECT colKey, col1, col2, ICAO_ID FROM TEST_POLL");      this.prefs.put("mom.topicName", "db.change.event.TEST_POLL");            this.processor = createTest(new Info(prefs), this.updateMap);      I_ChangeDetector changeDetector = processor.getChangeDetector();            for (int i=0; i<2; i++) {         log.info("Testing no table ...");         changeDetector.checkAgain(null);         sleep(500);         assertEquals("Number of message is wrong", 0, this.updateMap.size());      }      {      log.info("Now testing an empty table ...");      this.dbPool.update("CREATE TABLE TEST_POLL (colKey NUMBER(10,3), col1 VARCHAR(20), col2 NUMBER(12), ICAO_ID VARCHAR(10))");      changeDetector.checkAgain(null);      sleep(500);      assertEquals("Number of message is wrong", 1, this.updateMap.size());      String xml = (String)this.updateMap.get("db.change.event.TEST_POLL");      assertNotNull("No db.change.event.${groupColValue} message has arrived", xml);      assertXpathNotExists("/myRootTag/row[@num='0']", xml);      assertXpathEvaluatesTo("CREATE", "/myRootTag/desc/command/text()", xml);      this.updateMap.clear();      changeDetector.checkAgain(null);      sleep(500);      assertEquals("Number of message is wrong", 0, this.updateMap.size());      }      {      log.info("Insert one row");      this.dbPool.update("INSERT INTO TEST_POLL VALUES ('1.1', '<Bla', '9000', 'EDDI')");      changeDetector.checkAgain(null);      sleep(500);      assertEquals("Number of message is wrong", 1, this.updateMap.size());      String xml = (String)this.updateMap.get("db.change.event.TEST_POLL");      assertNotNull("xml returned is null", xml);      assertXpathEvaluatesTo("UPDATE", "/myRootTag/desc/command/text()", xml);      //assertXpathEvaluatesTo("Bla-1,1", "/myRootTag/row[@num='0']/col[@name='BLA-||COLKEY']/text()", xml);      assertTrue(xml.indexOf("Bla-1.1") != -1);      this.updateMap.clear();      writeToFile("db.change.event.INSERT", xml);      changeDetector.checkAgain(null);      sleep(500);      assertEquals("Number of message is wrong", 0, this.updateMap.size());      }                  {         log.info("Update one row");         this.dbPool.update("UPDATE TEST_POLL SET colKey='4.44' WHERE ICAO_ID='EDDI'");         changeDetector.checkAgain(null);         sleep(500);         assertEquals("Number of message is wrong", 1, this.updateMap.size());         String xml = (String)this.updateMap.get("db.change.event.TEST_POLL");         assertXpathEvaluatesTo("UPDATE", "/myRootTag/desc/command/text()", xml);         //assertXpathEvaluatesTo("Bla-4.44", "/myRootTag/row[@num='0']/col[@name='BLA-||COLKEY']/text()", xml);         assertTrue(xml.indexOf("Bla-4.44") != -1);         this.updateMap.clear();         writeToFile("db.change.event.UPDATE", xml);         changeDetector.checkAgain(null);         sleep(500);         assertEquals("Number of message is wrong", 0, this.updateMap.size());      }      {         log.info("Delete one row");         this.dbPool.update("DELETE FROM TEST_POLL WHERE ICAO_ID='EDDI'");         changeDetector.checkAgain(null);         sleep(500);         assertEquals("Number of message is wrong", 1, this.updateMap.size());         String xml = (String)this.updateMap.get("db.change.event.TEST_POLL");         assertXpathEvaluatesTo("UPDATE", "/myRootTag/desc/command/text()", xml);         assertXpathNotExists("/myRootTag/row[@num='0']", xml);         this.updateMap.clear();         writeToFile("db.change.event.DELETE", xml);         changeDetector.checkAgain(null);         sleep(500);         assertEquals("Number of message is wrong", 0, this.updateMap.size());      }      {         log.info("Drop a table");         this.dbPool.update("DROP TABLE TEST_POLL");         changeDetector.checkAgain(null);         sleep(500);         assertEquals("Number of message is wrong", 1, this.updateMap.size());         String xml = (String)this.updateMap.get("db.change.event.TEST_POLL");         assertXpathEvaluatesTo("DROP", "/myRootTag/desc/command/text()", xml);         assertXpathNotExists("/myRootTag/row[@num='0']", xml);         this.updateMap.clear();         writeToFile("db.change.event.DROP", xml);         changeDetector.checkAgain(null);         sleep(500);         assertEquals("Number of message is wrong", 0, this.updateMap.size());      }      log.info("SUCCESS");   }   /**    * Test synchronous all possible table changes.    * We drive two test, one with meat and one as content less event messages.    * @throws Exception Any type is possible    */   public final void testGroupedQueryMeatTableStates() throws Exception {      log.info("Start testGroupedQueryMeatTableStates()");      this.prefs.put("converter.rootName", "myRootTag");      this.prefs.put("db.queryMeatStatement", "select ICAO_ID, 'Bla-'||COLKEY from TEST_POLL where ICAO_ID='${groupColValue}'");      this.prefs.put("alertScheduler.pollInterval", "0"); // switch off      this.prefs.put("changeDetector.groupColName", "ICAO_ID");      this.prefs.put("converter.addMeta", ""+true);      this.prefs.put("changeDetector.detectStatement", "SELECT colKey, col1, col2, ICAO_ID FROM TEST_POLL ORDER BY ICAO_ID");      this.prefs.put("mom.topicName", "db.change.event.${groupColValue}");            boolean hasConverter = false;      for (int run=0; run<2; run++) {         if (run == 0) {            this.prefs.put("converter.class", "");         }         else {                    if (this.processor != null) this.processor.shutdown();            this.prefs.put("converter.class", "org.xmlBlaster.contrib.dbwatcher.convert.ResultSetToXmlConverter");            hasConverter = true;         }         this.processor = createTest(new Info(prefs), this.updateMap);         I_ChangeDetector changeDetector = processor.getChangeDetector();         for (int i=0; i<2; i++) {            log.info("Testing no table ...");            changeDetector.checkAgain(null);            sleep(500);            assertEquals("Number of message is wrong", 0, this.updateMap.size());         }         {         log.info("Now testing an empty table ...");         this.dbPool.update("CREATE TABLE TEST_POLL (colKey NUMBER(10,3), col1 VARCHAR(20), col2 NUMBER(12), ICAO_ID VARCHAR(10))");         changeDetector.checkAgain(null);         sleep(500);         assertEquals("Number of message is wrong", 1, this.updateMap.size());         String xml = (String)this.updateMap.get("db.change.event.${groupColValue}");         assertNotNull("No db.change.event.${groupColValue} message has arrived", xml);         if (hasConverter) {            assertXpathNotExists("/myRootTag/row[@num='0']", xml);            assertXpathEvaluatesTo("CREATE", "/myRootTag/desc/command/text()", xml);         }         this.updateMap.clear();         writeToFile("db.change.event.CREATE", xml);         changeDetector.checkAgain(null);         sleep(500);         assertEquals("Number of message is wrong", 0, this.updateMap.size());         }         {         log.info("Insert one row");         this.dbPool.update("INSERT INTO TEST_POLL VALUES ('1.1', '<Bla', '9000', 'EDDI')");         changeDetector.checkAgain(null);         sleep(500);         assertEquals("Number of message is wrong", 1, this.updateMap.size());         String xml = (String)this.updateMap.get("db.change.event.EDDI");         assertNotNull("No db.change.event.EDDI message has arrived", xml);         if (hasConverter) {            assertXpathEvaluatesTo("INSERT", "/myRootTag/desc/command/text()", xml);            assertTrue(xml.indexOf("Bla-1.1") != -1);         }         this.updateMap.clear();         writeToFile("db.change.event.INSERT", xml);         changeDetector.checkAgain(null);         sleep(500);         assertEquals("Number of message is wrong", 0, this.updateMap.size());         }                        {            log.info("Update one row");            this.dbPool.update("UPDATE TEST_POLL SET col1='BXXX' WHERE ICAO_ID='EDDI'");            changeDetector.checkAgain(null);            sleep(500);            assertEquals("Number of message is wrong", 1, this.updateMap.size());            String xml = (String)this.updateMap.get("db.change.event.EDDI");            assertNotNull("No db.change.event.EDDI message has arrived", xml);            if (hasConverter) {               assertXpathEvaluatesTo("UPDATE", "/myRootTag/desc/command/text()", xml);               assertFalse(xml.indexOf("BXXX") != -1); // col is not in queryMeatStatement            }            this.updateMap.clear();            writeToFile("db.change.event.UPDATE", xml);            changeDetector.checkAgain(null);            sleep(500);            assertEquals("Number of message is wrong", 0, this.updateMap.size());         }         {            log.info("Delete one row");            this.dbPool.update("DELETE FROM TEST_POLL WHERE ICAO_ID='EDDI'");            changeDetector.checkAgain(null);            sleep(500);            assertEquals("Number of message is wrong", 1, this.updateMap.size());            String xml = (String)this.updateMap.get("db.change.event.EDDI");            assertNotNull("No db.change.event.EDDI message has arrived", xml);            if (hasConverter) {               assertXpathEvaluatesTo("DELETE", "/myRootTag/desc/command/text()", xml);               assertXpathNotExists("/myRootTag/row[@num='0']", xml);            }            this.updateMap.clear();            writeToFile("db.change.event.DELETE", xml);            changeDetector.checkAgain(null);            sleep(500);            assertEquals("Number of message is wrong", 0, this.updateMap.size());         }         {            log.info("Drop a table");            this.dbPool.update("DROP TABLE TEST_POLL");            changeDetector.checkAgain(null);            sleep(500);            assertEquals("Number of message is wrong", 1, this.updateMap.size());            String xml = (String)this.updateMap.get("db.change.event.${groupColValue}");            assertNotNull("No db.change.event.${groupColValue} message has arrived", xml);            if (hasConverter) {               assertXpathEvaluatesTo("DROP", "/myRootTag/desc/command/text()", xml);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -