Exemplo n.º 1
0
  public void testVersion() throws Exception {
    if (Vm.isIBM()) {
      // IBM has a non-uniform version string that makes no sense to test in an automated way
      return;
    }
    String actualVersion = System.getProperty("java.runtime.version");
    String expectedVersion = TestConfigObject.getInstance().jvmVersion();

    Matcher matcher = VERSION_PATTERN.matcher(actualVersion);

    System.err.println(
        "Actual JVM version: '"
            + actualVersion
            + "'; expected JVM version: '"
            + expectedVersion
            + "'");

    assertTrue("Actual version of '" + actualVersion + "' matches pattern", matcher.matches());
    assertEquals(expectedVersion, matcher.group(1));
  }
Exemplo n.º 2
0
 public GenericList15Test() {
   if (Vm.isIBM()) {
     // these currently don't have to work on the IBM JDK
     disableAllUntil(new Date(Long.MAX_VALUE));
   }
 }
Exemplo n.º 3
0
  public void testVector() throws Exception {
    clazz = Vector.class;
    instance = clazz.newInstance();
    objManager.lookupOrCreate(instance);
    invokeMethod(
        clazz,
        instance,
        SerializationUtil.ADD_SIGNATURE,
        new Class[] {Object.class},
        new Object[] {new Integer(1)});
    invokeMethod(
        clazz,
        instance,
        SerializationUtil.ADD_AT_SIGNATURE,
        new Class[] {int.class, Object.class},
        new Object[] {new Integer(0), new Integer(1)});
    LinkedList l = new LinkedList();
    l.add("Hello");
    l.add("world");
    invokeMethod(
        clazz,
        instance,
        SerializationUtil.ADD_ALL_AT_SIGNATURE,
        new Class[] {int.class, Collection.class},
        new Object[] {new Integer(0), l});
    invokeMethod(
        clazz,
        instance,
        SerializationUtil.ADD_ALL_SIGNATURE,
        new Class[] {Collection.class},
        new Object[] {l});
    invokeMethod(
        clazz,
        instance,
        SerializationUtil.REMOVE_AT_SIGNATURE,
        new Class[] {int.class},
        new Object[] {new Integer(1)});
    invokeMethod(
        clazz,
        instance,
        SerializationUtil.SET_SIGNATURE,
        new Class[] {int.class, Object.class},
        new Object[] {new Integer(1), new Integer(2)});

    // This one is very important, this test that the parameter reversing logic works
    invokeMethod(
        clazz,
        instance,
        SerializationUtil.SET_ELEMENT_SIGNATURE,
        new Class[] {Object.class, int.class},
        new Object[] {new Integer(69), new Integer(1)});

    invokeMethod(
        clazz, instance, SerializationUtil.CLEAR_SIGNATURE, new Class[] {}, new Object[] {});

    tcObject = (MockTCObject) objManager.lookupOrCreate(instance);
    history = tcObject.getHistory();
    assertEquals(10, history.size());

    call = (MockTCObject.MethodCall) history.get(0);
    assertEquals(SerializationUtil.ADD, call.method);
    assertEquals(new Integer(1), call.parameters[0]);

    call = (MockTCObject.MethodCall) history.get(1);
    // Vector implementation calls insertElementAt() internally, hopefully this is constant over all
    // of time
    assertEquals(SerializationUtil.INSERT_AT, call.method);
    assertEquals(new Integer(0), call.parameters[0]);
    assertEquals(new Integer(1), call.parameters[1]);

    call = (MockTCObject.MethodCall) history.get(2);
    assertEquals(SerializationUtil.ADD_AT, call.method);
    assertEquals(new Integer(0), call.parameters[0]);
    assertEquals("Hello", call.parameters[1]);

    call = (MockTCObject.MethodCall) history.get(3);
    assertEquals(SerializationUtil.ADD_AT, call.method);
    assertEquals(new Integer(1), call.parameters[0]);
    assertEquals("world", call.parameters[1]);

    call = (MockTCObject.MethodCall) history.get(4);
    if (Vm.isIBM()) {
      // the IBM JDK delegates all add() method calls internally to addAt()
      assertEquals(SerializationUtil.ADD_AT, call.method);
      assertEquals(new Integer(4), call.parameters[0]);
      assertEquals("Hello", call.parameters[1]);
    } else {
      assertEquals(SerializationUtil.ADD, call.method);
      assertEquals("Hello", call.parameters[0]);
    }

    call = (MockTCObject.MethodCall) history.get(5);
    if (Vm.isIBM()) {
      // the IBM JDK delegates all add() method calls internally to addAt()
      assertEquals(SerializationUtil.ADD_AT, call.method);
      assertEquals(new Integer(5), call.parameters[0]);
      assertEquals("world", call.parameters[1]);
    } else {
      assertEquals(SerializationUtil.ADD, call.method);
      assertEquals("world", call.parameters[0]);
    }

    call = (MockTCObject.MethodCall) history.get(6);
    assertEquals(SerializationUtil.REMOVE_AT, call.method);
    assertEquals(new Integer(1), call.parameters[0]);

    call = (MockTCObject.MethodCall) history.get(7);
    assertEquals(SerializationUtil.SET, call.method);
    assertEquals(new Integer(1), call.parameters[0]);
    assertEquals(new Integer(2), call.parameters[1]);

    call = (MockTCObject.MethodCall) history.get(8);
    assertEquals(SerializationUtil.SET_ELEMENT, call.method);
    // These are supposed to be reversed
    assertEquals(new Integer(1), call.parameters[0]);
    assertEquals(new Integer(69), call.parameters[1]);

    call = (MockTCObject.MethodCall) history.get(9);
    assertEquals(SerializationUtil.CLEAR, call.method);
    params = call.parameters;
    assertEquals(0, params.length);
  }