Examples of ILogResourceManager


Examples of net.sf.logsaw.ui.ILogResourceManager

    log.configure(SimpleLogResourceFactory.OPTION_LOGFILE, getLogFile().getPath());
  }

  @Test
  public void testAddAndRemove() {
    final ILogResourceManager mgr = UIPlugin.getDefault().getLogResourceManager();
    try {
      final int size = mgr.getAll().length;
      loadLogFile("sample-1.log.xml");
      createLogResource("UTF-8", Locale.getDefault(), getTimeZone());
      assertNotNull(getLogResource());
      assertTrue(getLogResource().getPK() == null);
      mgr.add(getLogResource());
      assertTrue(getLogResource().getPK() != null);
      assertEquals(size + 1, mgr.getAll().length);
     
      mgr.remove(getLogResource());
      assertEquals(size, mgr.getAll().length);
    } catch (Exception e) {
      getLogger().error(e.getLocalizedMessage(), e);
      fail("Exception should not occur: " + e.getLocalizedMessage());
    }
  }
View Full Code Here

Examples of net.sf.logsaw.ui.ILogResourceManager

    }
  }

  @Test
  public void testSynchronize() {
    ILogResourceManager mgr = UIPlugin.getDefault().getLogResourceManager();
    try {
      int size = mgr.getAll().length;
      loadLogFile("sample-1.log.xml");
      createLogResource("UTF-8", Locale.getDefault(), getTimeZone());
      assertNotNull(getLogResource());
      assertTrue(getLogResource().getPK() == null);
      mgr.add(getLogResource());
      assertTrue(getLogResource().getPK() != null);
      assertEquals(size + 1, mgr.getAll().length);
     
      final SynchronizationResult[] result = new SynchronizationResult[1];
      final CountDownLatch countDown = new CountDownLatch(1);
      mgr.synchronize(getLogResource(), new IGenericCallback<SynchronizationResult>() {
        /* (non-Javadoc)
         * @see net.sf.logsaw.ui.IGenericCallback#doCallback(java.lang.Object)
         */
        @Override
        public void doCallback(SynchronizationResult payload) {
          result[0] = payload;
          countDown.countDown();
        }
      });
      countDown.await();
      assertTrue(IndexPlugin.getDefault().getIndexFile(getLogResource()).exists());
      assertEquals(5, result[0].getNumberOfEntriesAdded());
      assertEquals(5, IndexPlugin.getDefault().getIndexService().count(getLogResource()));
     
      mgr.remove(getLogResource());
      assertTrue(!IndexPlugin.getDefault().getIndexFile(getLogResource()).exists());
      assertEquals(size, mgr.getAll().length);
    } 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.