Examples of IIndexService


Examples of net.sf.logsaw.index.IIndexService

  }

  @Test
  public void testLessThanQuery() {
    try {
      IIndexService indexService = IndexPlugin.getDefault().getIndexService();
      loadLogFile("sample-1.log.xml");
      createLogResourceWithPK("UTF-8", Locale.getDefault(), getTimeZone());
      indexService.synchronize(getLogResource(), null);
      IQueryContext ctx = indexService.createQueryContext(getLogResource());
      try {
        List<ARestriction<?>> ops = new LinkedList<ARestriction<?>>();
        ops.add(getRestrictionFactory().newRestriction(Log4JFieldProvider.FIELD_LEVEL, Operators.OPERATOR_LESS_THAN,
            Log4JFieldProvider.FIELD_LEVEL.getLevelProvider().findLevel("warn")));
        ResultPage p = indexService.query(ctx, ops, 0, 1000);
        assertEquals(4, p.getItems().size());
        assertEquals(4, p.getTotalHits());
      } finally {
        ctx.close();
      }
View Full Code Here

Examples of net.sf.logsaw.index.IIndexService

  }

  @Test
  public void testGreaterThanQuery() {
    try {
      IIndexService indexService = IndexPlugin.getDefault().getIndexService();
      loadLogFile("sample-1.log.xml");
      createLogResourceWithPK("UTF-8", Locale.getDefault(), getTimeZone());
      indexService.synchronize(getLogResource(), null);
      IQueryContext ctx = indexService.createQueryContext(getLogResource());
      try {
        List<ARestriction<?>> ops = new LinkedList<ARestriction<?>>();
        ops.add(getRestrictionFactory().newRestriction(Log4JFieldProvider.FIELD_LEVEL, Operators.OPERATOR_GREATER_THAN,
            Log4JFieldProvider.FIELD_LEVEL.getLevelProvider().findLevel("info")));
        ResultPage p = indexService.query(ctx, ops, 0, 1000);
        assertEquals(1, p.getItems().size());
        assertEquals(1, p.getTotalHits());
      } finally {
        ctx.close();
      }
View Full Code Here

Examples of net.sf.logsaw.index.IIndexService

  }

  @Test
  public void testEqualsQueryWithLevel() {
    try {
      IIndexService indexService = IndexPlugin.getDefault().getIndexService();
      loadLogFile("sample-1.log.xml");
      createLogResourceWithPK("UTF-8", Locale.getDefault(), getTimeZone());
      indexService.synchronize(getLogResource(), null);
      IQueryContext ctx = indexService.createQueryContext(getLogResource());
      try {
        List<ARestriction<?>> ops = new LinkedList<ARestriction<?>>();
        ops.add(getRestrictionFactory().newRestriction(Log4JFieldProvider.FIELD_LEVEL, Operators.OPERATOR_EQUALS,
            Log4JFieldProvider.FIELD_LEVEL.getLevelProvider().findLevel("warn")));
        ResultPage p = indexService.query(ctx, ops, 0, 1000);
        assertEquals(1, p.getItems().size());
        assertEquals(1, p.getTotalHits());
      } finally {
        ctx.close();
      }
View Full Code Here

Examples of net.sf.logsaw.index.IIndexService

  }

  @Test
  public void testNotEqualsQueryWithLevel() {
    try {
      IIndexService indexService = IndexPlugin.getDefault().getIndexService();
      loadLogFile("sample-1.log.xml");
      createLogResourceWithPK("UTF-8", Locale.getDefault(), getTimeZone());
      indexService.synchronize(getLogResource(), null);
      IQueryContext ctx = indexService.createQueryContext(getLogResource());
      try {
        List<ARestriction<?>> ops = new LinkedList<ARestriction<?>>();
        ops.add(getRestrictionFactory().newRestriction(Log4JFieldProvider.FIELD_LEVEL, Operators.OPERATOR_NOT_EQUALS,
            Log4JFieldProvider.FIELD_LEVEL.getLevelProvider().findLevel("info")));
        ResultPage p = indexService.query(ctx, ops, 0, 1000);
        assertEquals(1, p.getItems().size());
        assertEquals(1, p.getTotalHits());
      } finally {
        ctx.close();
      }
View Full Code Here

Examples of net.sf.logsaw.index.IIndexService

  }

  @Test
  public void testComplexQuery() {
    try {
      IIndexService indexService = IndexPlugin.getDefault().getIndexService();
      loadLogFile("sample-1.log.xml");
      createLogResourceWithPK("UTF-8", Locale.getDefault(), getTimeZone());
      indexService.synchronize(getLogResource(), null);
      IQueryContext ctx = indexService.createQueryContext(getLogResource());
      try {
        List<ARestriction<?>> ops = new LinkedList<ARestriction<?>>();
        ops.add(getRestrictionFactory().newRestriction(Log4JFieldProvider.FIELD_TIMESTAMP,
            Operators.OPERATOR_AFTER, new Date(1248183795312L)));
        ops.add(getRestrictionFactory().newRestriction(Log4JFieldProvider.FIELD_TIMESTAMP,
            Operators.OPERATOR_BEFORE, new Date(1248183796234L)));
        ops.add(getRestrictionFactory().newRestriction(Log4JFieldProvider.FIELD_MESSAGE,
            Operators.OPERATOR_CONTAINS, "manager"));
        ResultPage p = indexService.query(ctx, ops, 0, 1000);
        assertEquals(2, p.getItems().size());
        assertEquals(2, p.getTotalHits());
      } finally {
        ctx.close();
      }
View Full Code Here

Examples of net.sf.logsaw.index.IIndexService

    try {
      loadLogFile("no-timestamp.log.txt");
      createLogResourceWithPK("UTF-8", Locale.getDefault(), getTimeZone());
      APatternDialect dialect = (APatternDialect) getLogResource().getDialect();
      dialect.configure(APatternDialect.OPTION_PATTERN, "%p %t %c - %m%n");
      IIndexService indexService = IndexPlugin.getDefault().getIndexService();
      SynchronizationResult result = indexService.synchronize(getLogResource(), null);
      assertEquals(15, result.getNumberOfEntriesAdded());
      assertEquals(15, indexService.count(getLogResource()));
      result = indexService.synchronize(getLogResource(), null);
      assertEquals(15, result.getNumberOfEntriesAdded());
      assertEquals(15, indexService.count(getLogResource()));
    } catch (Exception e) {
      getLogger().error(e.getLocalizedMessage(), e);
      fail("Exception should not occur: " + e.getLocalizedMessage());
    }
  }
View Full Code Here

Examples of net.sf.logsaw.index.IIndexService

  }

  @Test
  public void testCaseInsensitive() {
    try {
      IIndexService indexService = IndexPlugin.getDefault().getIndexService();
      loadLogFile("sample-1.log.xml");
      createLogResourceWithPK("UTF-8", Locale.getDefault(), getTimeZone());
      indexService.synchronize(getLogResource(), null);
      IQueryContext ctx = indexService.createQueryContext(getLogResource());
      try {
        List<ARestriction<?>> ops = new LinkedList<ARestriction<?>>();
        ops.add(getRestrictionFactory().newRestriction(Log4JFieldProvider.FIELD_MESSAGE,
            Operators.OPERATOR_CONTAINS, "Recovery"));
        ResultPage p = indexService.query(ctx, ops, 0, 1000);
        assertEquals(2, p.getItems().size());
        assertEquals(2, p.getTotalHits());
      } finally {
        ctx.close();
      }
View Full Code Here

Examples of net.sf.logsaw.index.IIndexService

  }

  @Test
  public void testPhrase() {
    try {
      IIndexService indexService = IndexPlugin.getDefault().getIndexService();
      loadLogFile("sample-1.log.xml");
      createLogResourceWithPK("UTF-8", Locale.getDefault(), getTimeZone());
      indexService.synchronize(getLogResource(), null);
      IQueryContext ctx = indexService.createQueryContext(getLogResource());
      try {
        List<ARestriction<?>> ops = new LinkedList<ARestriction<?>>();
        ops.add(getRestrictionFactory().newRestriction(Log4JFieldProvider.FIELD_MESSAGE,
            Operators.OPERATOR_CONTAINS, "recovery manager"));
        ResultPage p = indexService.query(ctx, ops, 0, 1000);
        assertEquals(2, p.getItems().size());
        assertEquals(2, p.getTotalHits());
      } finally {
        ctx.close();
      }
View Full Code Here

Examples of net.sf.logsaw.index.IIndexService

  }

  @Test
  public void testCreateAndDelete() {
    try {
      IIndexService indexService = IndexPlugin.getDefault().getIndexService();
      loadLogFile("sample-1.log.xml");
      createLogResource("UTF-8", Locale.getDefault(), getTimeZone());
      indexService.createIndex(getLogResource());
      indexService.synchronize(getLogResource(), null);
      assertTrue(IndexPlugin.getDefault().getIndexFile(getLogResource()).exists());
      assertEquals(5, indexService.count(getLogResource()));
      indexService.deleteIndex(getLogResource());
      assertTrue(!IndexPlugin.getDefault().getIndexFile(getLogResource()).exists());
    } catch (Exception e) {
      getLogger().error(e.getLocalizedMessage(), e);
      fail("Exception should not occur: " + e.getLocalizedMessage());
    }
View Full Code Here

Examples of net.sf.logsaw.index.IIndexService

  }

  @Test
  public void testEncoding() {
    try {
      IIndexService indexService = IndexPlugin.getDefault().getIndexService();
      loadLogFile("sample-cp1252.log.xml");
      createLogResourceWithPK("UTF-8", Locale.getDefault(), getTimeZone());
      try {
        indexService.synchronize(getLogResource(), null);
        fail("Indexing should fail because of encoding");
      } catch (Exception e) {
        // nadda
      }
      createLogResourceWithPK("Cp1252", Locale.getDefault(), getTimeZone());
      indexService.synchronize(getLogResource(), null);
      assertEquals(6, indexService.count(getLogResource()));
    } catch (Exception e) {
      getLogger().error(e.getLocalizedMessage(), e);
      fail("Exception should not occur: " + e.getLocalizedMessage());
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.