Example #1
0
    void checkThreadInfo(ThreadInfo info) {
      if (!getName().equals(info.getThreadName())) {
        throw new RuntimeException(
            "Name: " + info.getThreadName() + " not matched. Expected: " + getName());
      }

      MonitorInfo[] monitors = info.getLockedMonitors();
      if (monitors.length != OWNED_MONITORS) {
        throw new RuntimeException(
            "Number of locked monitors = "
                + monitors.length
                + " not matched. Expected: "
                + OWNED_MONITORS);
      }
      MonitorInfo m = monitors[0];
      StackTraceElement ste = m.getLockedStackFrame();
      int depth = m.getLockedStackDepth();
      StackTraceElement[] stacktrace = info.getStackTrace();
      if (!ste.equals(stacktrace[depth])) {
        System.out.println("LockedStackFrame:- " + ste);
        System.out.println("StackTrace at " + depth + " :-" + stacktrace[depth]);
        throw new RuntimeException(
            "LockedStackFrame does not match " + "stack frame in ThreadInfo.getStackTrace");
      }

      String className = lock.getClass().getName();
      int hcode = System.identityHashCode(lock);
      if (!className.equals(m.getClassName())
          || hcode != m.getIdentityHashCode()
          || !m.getLockedStackFrame().getMethodName().equals("run")) {
        System.out.println(info);
        throw new RuntimeException("MonitorInfo " + m + " doesn't match.");
      }

      LockInfo[] syncs = info.getLockedSynchronizers();
      if (syncs.length != OWNED_SYNCS) {
        throw new RuntimeException(
            "Number of locked syncs = " + syncs.length + " not matched. Expected: " + OWNED_SYNCS);
      }
      AbstractOwnableSynchronizer s = mutex.getSync();
      String lockName = s.getClass().getName();
      hcode = System.identityHashCode(s);
      if (!lockName.equals(syncs[0].getClassName())) {
        throw new RuntimeException(
            "LockInfo : " + syncs[0] + " class name not matched. Expected: " + lockName);
      }
      if (hcode != syncs[0].getIdentityHashCode()) {
        throw new RuntimeException(
            "LockInfo: " + syncs[0] + " IdentityHashCode not matched. Expected: " + hcode);
      }
      LockInfo li = info.getLockInfo();
      if (li == null) {
        throw new RuntimeException("Expected non-null LockInfo");
      }
    }
Example #2
0
  private static void checkMap() throws Exception {
    // Add new system properties
    System.setProperty(KEY1, VALUE1);
    System.setProperty(KEY2, VALUE2);

    TabularData props1 = (TabularData) server.getAttribute(runtime, "SystemProperties");

    String value1 = getProperty(props1, KEY1);
    if (value1 == null || !value1.equals(VALUE1)) {
      throw new RuntimeException(
          "TEST FAILED: "
              + KEY1
              + " property found"
              + " with value = "
              + value1
              + " but expected to be "
              + VALUE1);
    }

    String value2 = getProperty(props1, KEY2);
    if (value2 == null || !value2.equals(VALUE2)) {
      throw new RuntimeException(
          "TEST FAILED: "
              + KEY2
              + " property found"
              + " with value = "
              + value2
              + " but expected to be "
              + VALUE2);
    }

    String value3 = getProperty(props1, KEY3);
    if (value3 != null) {
      throw new RuntimeException(
          "TEST FAILED: " + KEY3 + " property found" + " but should not exist");
    }
  }