Ejemplo n.º 1
0
  protected void testMPSSelectorFunc(String selector, int selectedMPs) throws Exception {
    // 1. Get the monitored result through ZMonitor TestBase API.
    MonitoredResult mResult = this.getMonitoredResult();

    // 2. Use Selection API to manipulate the Monitor Point Sequence.
    // String selector = ".BusinessObject .Dao:greater-than(END, 50)";

    System.out.println(
        "------------------------\n" + "selector: " + selector + "\n------------------------");

    MonitorPointSelection mpSel = mResult.asSelection().select(selector);

    MonitorPoint mp;
    StringBuffer sb = new StringBuffer("\n testSelection_SelectorPseudoClass: " + selector + "\n");
    sb.append("--------------------\n");
    EclipseConsoleMonitorSequenceHandler handler =
        ZMonitorManager.getInstance().getBeanById("console-handler");
    int counter = 0;
    while (mpSel.hasNext()) {
      counter++;
      mp = mpSel.toNext();
      Strings.appendln(sb, " Start printing from root:");
      handler.writeRoot2MP(sb, mp, " ");
      sb.append("--------------------\n");
    }
    System.out.println(sb);
    Assert.assertEquals(selectedMPs, counter);
  }
Ejemplo n.º 2
0
  @Test
  public void test_SimpleSlf4j() throws Exception {
    // 1. Get the monitored result through ZMonitor TestBase API.
    MonitoredResult mResult = this.getMonitoredResult();

    // 2. Use Selection API to manipulate the Monitor Point Sequence.
    String selector =
        ".BusinessObject .Service .Dao.lookUpDB[message*='hello world!']:greater-than(END,50)";

    MonitorPointSelection mpSel = mResult.asSelection().select(selector);

    MonitorPoint mp;
    StringBuffer sb = new StringBuffer("testSelection_SelectorPseudoClass: " + selector + "\n");
    sb.append("--------------------\n");
    EclipseConsoleMonitorSequenceHandler handler =
        ZMonitorManager.getInstance().getBeanById("console-handler");
    try {
      int counter = 0;
      while (mpSel.hasNext()) {
        counter++;
        mp = mpSel.toNext();
        Strings.appendln(sb, " Start printing from root:");
        handler.writeRoot2MP(sb, mp, " ");
        sb.append("--------------------\n");
      }
      System.out.println(sb);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 3
0
 public static void assertMPAmount(MonitorPointSelection mpSel, int expectedAmount) {
   EclipseConsoleMonitorSequenceHandler handler =
       ZMonitorManager.getInstance().getBeanIfAny(EclipseConsoleMonitorSequenceHandler.class);
   int counter = 0;
   MonitorPoint mp;
   StringBuffer sb = null;
   if (handler != null) {
     sb = new StringBuffer("--------------------\n");
   }
   while (mpSel.hasNext()) {
     mp = mpSel.toNext();
     counter++;
     if (handler != null) {
       handler.writeMP(sb, mp, " ");
       sb.append("--------------------\n");
     }
   }
   if (handler != null) {
     System.out.println(sb);
   }
   Assert.assertEquals(expectedAmount, counter);
 }