@Test
    public void testGetContentLengthFTP() {
        long contLength = ParsingUtils.getContentLength(TestUtils.AVAILABLE_FTP_URL);
        assertTrue("Error retrieving content length: " + contLength, contLength > 0);

        long start_time = System.currentTimeMillis();
        assertTrue(ParsingUtils.getContentLength(TestUtils.UNAVAILABLE_FTP_URL) == -1);
        long end_time = System.currentTimeMillis();
        assertTrue(end_time - start_time < Globals.CONNECT_TIMEOUT + 1000);
        assertTrue(end_time - start_time < Globals.CONNECT_TIMEOUT + 1000);
    }
    @Test
    public void testParseInt() {
        String with_commas = "123456";
        int expected = 123456;
        int actual = ParsingUtils.parseInt(with_commas);
        assertEquals(expected, actual);

        String exp_not = "3.5e4";
        expected = 35000;
        assertEquals(expected, ParsingUtils.parseInt(exp_not));
    }
 @Test
 public void testMultipleNestedMatches2() throws Exception {
   List<Object> vals = ParsingUtils.values(parser, "age");
   assertEquals(1, vals.size());
   int val = (Integer) vals.get(0);
   System.out.println(val);
 }
Esempio n. 4
0
  public void parse() throws BadLocationException {

    final List<OutlineNodeDefinition<?>> nodeDefinitions =
        configuration.getAllOutlineLevelDefinitions();
    final List<ShowInOutlineInstruction> showInOutlineInstructions =
        configuration.getInstructions(ShowInOutlineInstruction.class);

    String entry = null, header = null;

    for (int lineNumber = 0; lineNumber < numberOfLines; lineNumber++) {

      IRegion region = document.getLineInformation(lineNumber);
      String line = getLine(document, region);

      if (line.equals(MyContentOutlinePage.CONFIG_MARKER) || hasConfigSection) {
        onConfigLine(lineNumber, line, region);
        continue;
      }

      if (ParsingUtils.isLogEntryStart(line)) {
        header = line;
        entry = ParsingUtils.getLogEntry(document, lineNumber);
      }

      onAnyLine(lineNumber, line, entry, header, region);
      if (ParsingUtils.isLogEntryStart(line)) {
        onLogEntryLine(lineNumber, line, entry, region);
      }

      if (showInOutline(showInOutlineInstructions, line, entry, header)) {
        for (OutlineNodeDefinition<?> nodeDefinition : nodeDefinitions) {
          OutlineNodeContent content =
              nodeDefinition.recognize(lineNumber, line, entry, header, region, document);
          if (content != null) {
            @SuppressWarnings({"unchecked", "rawtypes"})
            OutlineNode<?> node =
                new OutlineNode(nodeDefinition, content, region, lineNumber, line, document);
            outlineNodesMap.put(lineNumber, node);
          }
        }
      }
    }

    sortOutlineNodes();
    dumpInfoToConfigSection();
  }
Esempio n. 5
0
 private void processFolding(int lineNumber, String line) throws BadLocationException {
   if (ParsingUtils.isLogEntryStart(line)) {
     processLogEntryFolding(lineNumber, line);
     processEntryExitFolding(lineNumber, line);
   } else {
     processIndentBasedFolding(lineNumber, line);
   }
 }
 @Test
 public void testSmallerMixedLevels() throws Exception {
   List<Object> vals = ParsingUtils.values(parser, "firstName", "address.state", "state");
   assertEquals(3, vals.size());
   assertEquals("John", vals.get(0));
   assertEquals("NY", vals.get(1));
   assertEquals("CA", vals.get(2));
 }
 @Test
 public void testFirstLevel() throws Exception {
   List<Object> vals = ParsingUtils.values(parser, "firstName", "foo", "age");
   assertEquals(3, vals.size());
   assertEquals("John", vals.get(0));
   assertSame(ParsingUtils.NOT_FOUND, vals.get(1));
   assertEquals(25, vals.get(2));
 }
 @Test
 public void testMixedLevels() throws Exception {
   List<Object> vals =
       ParsingUtils.values(
           parser, "firstName", "address.building.floors", "address.decor.walls", "zzz");
   assertEquals(4, vals.size());
   assertEquals("John", vals.get(0));
   assertEquals(10, vals.get(1));
   assertEquals("white", vals.get(2));
   assertEquals("end", vals.get(3));
 }
Esempio n. 9
0
 private void registerThread(String line) {
   String threadName = ParsingUtils.parseThread(line, componentNames);
   if (threadName == null) {
     return;
   }
   ThreadInfo info = discoveredThreads.get(threadName);
   if (info == null) {
     info = new ThreadInfo(threadName);
     discoveredThreads.put(threadName, info);
   }
   info.records++;
 }
Esempio n. 10
0
 private void processLogEntryFolding(int lineNumber, String line) throws BadLocationException {
   int endLine = lineNumber + 1;
   while (endLine < numberOfLines - 1) {
     String s = getLine(endLine);
     if (ParsingUtils.isLogEntryStart(s)) {
       break;
     }
     endLine++;
   }
   if (endLine > lineNumber + 1) {
     addFoldingRegion(lineNumber, endLine);
   }
 }
 @Test
 public void testSecondLevel() throws Exception {
   List<Object> vals =
       ParsingUtils.values(
           parser,
           "address.state",
           "address.foo",
           "address.building.floors",
           "address.building.bar");
   assertEquals(4, vals.size());
   assertEquals("NY", vals.get(0));
   assertSame(ParsingUtils.NOT_FOUND, vals.get(1));
   assertEquals(10, vals.get(2));
   assertSame(ParsingUtils.NOT_FOUND, vals.get(3));
 }
Esempio n. 12
0
  public void onLogEntryLine(int lineNumber, String line, String entry, IRegion region) {
    if (!configuration.skipThreadProcessing) {
      registerThread(line);
    }

    Date date = ParsingUtils.parseDate(line);
    if (date != null) {
      long currentTimestamp = date.getTime();
      if (lastTimestamp != null) {
        long delta = currentTimestamp - lastTimestamp;
        if (configuration.getErrorIfDelay() != null && delta >= configuration.getErrorIfDelay()) {
          addMarker(
              lineNumber,
              "Delay ("
                  + delta
                  + " msec) reached configured threshold of "
                  + configuration.getErrorIfDelay()
                  + " msec",
              IMarker.SEVERITY_ERROR);
        } else if (configuration.getWarningIfDelay() != null
            && delta >= configuration.getWarningIfDelay()) {
          addMarker(
              lineNumber,
              "Delay ("
                  + delta
                  + " msec) reached configured threshold of "
                  + configuration.getWarningIfDelay()
                  + " msec",
              IMarker.SEVERITY_WARNING);
        } else if (configuration.getInfoIfDelay() != null
            && delta >= configuration.getInfoIfDelay()) {
          addMarker(
              lineNumber,
              "Delay ("
                  + delta
                  + " msec) reached configured threshold of "
                  + configuration.getInfoIfDelay()
                  + " msec",
              IMarker.SEVERITY_INFO);
        }
      }
      lastTimestamp = currentTimestamp;
    }
  }
Esempio n. 13
0
    @Test
    public void testParseTrackLine() {
        String trackLine = "track type=bigWig name=\"Track 196\" visibility=2 " +
                "description=\" CD34 - H3K27me3 - hg19 - 18.7 M/20.9 M - 61P7DAAXX.6\" " +
                "maxHeightPixels=70 viewLimits=0:18 windowingFunction=mean autoScale=off " +
                "bigDataUrl=http://www.broadinstitute.org/epigenomics/dataportal/track_00196.portal.bw " +
                "color=255,0,0";

        TrackProperties props = new TrackProperties();
        ParsingUtils.parseTrackLine(trackLine, props);
        assertEquals("Track 196", props.getName());
        assertEquals(Track.DisplayMode.EXPANDED, props.getDisplayMode());
        assertEquals(" CD34 - H3K27me3 - hg19 - 18.7 M/20.9 M - 61P7DAAXX.6", props.getDescription());
        assertEquals(70, props.getHeight());
        assertEquals(0, props.getMinValue(), 1.0e-9);
        assertEquals(18, props.getMaxValue(), 1.0e-9);
        assertEquals(WindowFunction.mean, props.getWindowingFunction());
        assertEquals(false, props.isAutoScale());
        assertEquals(new Color(255, 0, 0), props.getColor());
        assertEquals("http://www.broadinstitute.org/epigenomics/dataportal/track_00196.portal.bw", props.getDataURL());
    }
 @Test
 public void testMultipleNestedMatches1() throws Exception {
   List<Object> vals = ParsingUtils.values(parser, "firstName");
   assertEquals(1, vals.size());
   assertThat(vals.get(0).toString(), containsString("John"));
 }
 @Test
 public void testRichObject() throws Exception {
   List<Object> vals = ParsingUtils.values(parser, "address");
   assertEquals(1, vals.size());
   assertThat(vals.get(0).toString(), containsString("floors"));
 }
Esempio n. 16
0
 /**
  * Determines if the resource actually exists.
  *
  * @return true if resource was found.
  */
 public boolean exists() {
   return ParsingUtils.pathExists(path);
 }
 @Test
 public void testCorrectLevelMatched() throws Exception {
   List<Object> vals = ParsingUtils.values(parser, "state");
   assertEquals(1, vals.size());
   assertThat(vals.get(0).toString(), containsString("CA"));
 }