Ejemplo n.º 1
0
  public void testInjectClearAndGetFault() {
    FaultManager fm = null;

    try {
      fm = FaultManager.create(conf);

      fm.inject(this.getClass(), "testInjectAndGetFault", TestFault.class);

      Fault fault = fm.getFault(this.getClass(), "testInjectAndGetFault");

      assertNotNull(fault);
      assertEquals(TestFault.class, fault.getClass());

      fm.clear(this.getClass(), "testInjectAndGetFault");

      fault = fm.getFault(this.getClass(), "testInjectAndGetFault");

      assertNull(fault);
    } catch (InterruptedException e) {
      assertTrue(false);
    } catch (IOException e) {
      e.printStackTrace();
      assertTrue(false);
    } finally {
      if (fm != null) {
        fm.close();
      }
    }
  }
Ejemplo n.º 2
0
  public void testShareWithOtherFaultManager() {
    FaultManager fm1 = null;
    FaultManager fm2 = null;

    try {
      fm1 = FaultManager.create(conf);

      fm1.inject(this.getClass(), "testShareWithOtherFaultManager", TestFault.class);

      // sleep을 할 필요가 없다. 왜냐하면, FaultManager가 create되면서
      // Pleiades의 모든 fault 정보를 Load하기 때문이다.
      fm2 = FaultManager.create(conf);
      Fault fault = fm2.getFault(this.getClass(), "testShareWithOtherFaultManager");
      assertNotNull(fault);
      assertEquals(TestFault.class, fault.getClass());

      assertNull(fm1.getFault(TestFault.class, "methodHaha"));

      fm2.inject(TestFault.class, "methodHaha", TestFault2.class);

      Thread.sleep(1000);

      fault = fm1.getFault(TestFault.class, "methodHaha");
      assertNotNull(fault);
      assertEquals(TestFault2.class, fault.getClass());
    } catch (InterruptedException e) {
      assertTrue(false);
    } catch (IOException e) {
      e.printStackTrace();
      assertTrue(false);
    } finally {
      if (fm1 != null) {
        fm1.close();
      }

      if (fm2 != null) {
        fm2.close();
      }
    }
  }
Ejemplo n.º 3
0
  public void testInjectClearAndGetFaultInDifferentFM() {
    FaultManager fm1 = null;
    FaultManager fm2 = null;

    try {
      fm1 = FaultManager.create(conf);

      fm1.inject(this.getClass(), "testInjectAndGetFault", TestFault.class);

      Fault fault = fm1.getFault(this.getClass(), "testInjectAndGetFault");

      assertNotNull(fault);
      assertEquals(TestFault.class, fault.getClass());

      fm2 = FaultManager.create(conf);
      Fault fault2 = fm2.getFault(this.getClass(), "testInjectAndGetFault");
      assertNotNull(fault2);

      fm2.clear(this.getClass(), "testInjectAndGetFault");

      Thread.sleep(1000);

      assertNull(fm1.getFault(this.getClass(), "testInjectAndGetFault"));
      assertNull(fm2.getFault(this.getClass(), "testInjectAndGetFault"));
    } catch (InterruptedException e) {
      assertTrue(false);
    } catch (IOException e) {
      e.printStackTrace();
      assertTrue(false);
    } finally {
      if (fm1 != null) {
        fm1.close();
      }

      if (fm2 != null) {
        fm2.close();
      }
    }
  }