Package org.springsource.loaded.test.infra

Examples of org.springsource.loaded.test.infra.Result


    String theType = "ctors.Setter";
    TypeRegistry r = getTypeRegistry(theType);
    ReloadableType rtype = r.addType(theType, loadBytesForClass(theType));

    result = runConstructor(rtype.getClazz(), "");
    Result res = runOnInstance(rtype.getClazz(), result.returnValue, "getInteger");
    assertEquals(1, ((Integer) res.returnValue).intValue());
    res = runOnInstance(rtype.getClazz(), result.returnValue, "getString");
    assertEquals("one", (res.returnValue));

    rtype.loadNewVersion("000", rtype.bytesInitial);
View Full Code Here


    String supertype = "ctors.A";
    String subtype = "ctors.B";
    TypeRegistry r = getTypeRegistry(supertype + "," + subtype);
    ReloadableType rsupertype = r.addType(supertype, loadBytesForClass(supertype));
    ReloadableType rsubtype = r.addType(subtype, loadBytesForClass(subtype));
    Result res = null;

    // Use the code 'untouched'
    result = runConstructor(rsubtype.getClazz(), "int", 3);
    res = runOnInstance(rsubtype.getClazz(), result.returnValue, "getString");
    assertEquals("3", (res.returnValue));
View Full Code Here

    String caller = "ctors.Caller";
    String callee = "ctors.Callee";
    TypeRegistry r = getTypeRegistry(caller + "," + callee);
    ReloadableType rcaller = r.addType(caller, loadBytesForClass(caller));
    ReloadableType rcallee = r.addType(callee, loadBytesForClass(callee));
    Result res = null;

    // Use the code 'untouched'
    Object callerInstance = rcaller.getClazz().newInstance();
    res = runOnInstance(rcaller.getClazz(), callerInstance, "runA");
    assertEquals("callee", res.returnValue.toString());
View Full Code Here

  @Test
  public void constructorsAndFinalFields() throws Exception {
    String caller = "ctors.Finals";
    TypeRegistry r = getTypeRegistry(caller);
    ReloadableType rcaller = r.addType(caller, loadBytesForClass(caller));
    Result res = null;

    // Use the code 'untouched'
    Object callerInstance = rcaller.getClazz().newInstance();
    res = runOnInstance(rcaller.getClazz(), callerInstance, "getValue");
    assertEquals("324 abc", res.returnValue.toString());
View Full Code Here

    String calleeSuper = "ctors.CalleeSuperB";
    TypeRegistry r = getTypeRegistry(caller + "," + callee + "," + calleeSuper);
    ReloadableType rcaller = r.addType(caller, loadBytesForClass(caller));
    ReloadableType rcalleeSuper = r.addType(calleeSuper, loadBytesForClass(calleeSuper));
    ReloadableType rcallee = r.addType(callee, loadBytesForClass(callee));
    Result res = null;

    // Use the code 'untouched'
    Object callerInstance = rcaller.getClazz().newInstance();
    res = runOnInstance(rcaller.getClazz(), callerInstance, "runA");
    assertEquals("callee", res.returnValue.toString());

    // Reload the code, a new constructor in the callee and runB() invokes it
    rcalleeSuper.loadNewVersion("002", retrieveRename(calleeSuper, calleeSuper + "2"));
    rcaller.loadNewVersion("002", retrieveRename(caller, caller + "2", "ctors.CalleeB2:ctors.CalleeB"));
    rcallee.loadNewVersion("002", retrieveRename(callee, callee + "2", "ctors.CalleeSuperB2:ctors.CalleeSuperB"));

    // The new runB() method will include a call 'new Callee("abcde")'
    // Without a rewrite, it will cause this problem:
    // Caused by: java.lang.NoSuchMethodError: ctors.Callee.<init>(Ljava/lang/String;)V
    //   at ctors.Caller__E002.runB(Caller2.java:10)
    // This new Callee constructor also invokes a constructor in the supertype that wasn't there initially
    res = runOnInstance(rcaller.getClazz(), callerInstance, "runB");
    assertEquals("callee", res.returnValue.toString());
    assertContains("Super number was 32768", res.toString());
    assertContains("abcde", res.toString());
  }
View Full Code Here

  @Test
  public void rewriteWithReturnValues() throws Exception {
    TypeRegistry typeRegistry = getTypeRegistry("data.HelloWorld");
    ReloadableType rtype = typeRegistry.addType("data.HelloWorld", loadBytesForClass("data.HelloWorld"));

    Result r = runUnguarded(rtype.getClazz(), "getValue");
    assertEquals("message from HelloWorld", r.returnValue);

    rtype.loadNewVersion("000", rtype.bytesInitial);
    r = runUnguarded(rtype.getClazz(), "getValue");
    assertEquals("message from HelloWorld", r.returnValue);
View Full Code Here

  @Test
  public void rewriteWithPrimitiveReturnValues_int() throws Exception {
    TypeRegistry typeRegistry = getTypeRegistry("data.HelloWorldPrimitive");
    ReloadableType rtype = typeRegistry.addType("data.HelloWorldPrimitive", loadBytesForClass("data.HelloWorldPrimitive"));

    Result r = runUnguarded(rtype.getClazz(), "getValue");
    assertTrue(r.returnValue instanceof Integer);
    assertEquals(42, r.returnValue);

    rtype.loadNewVersion("000", rtype.bytesInitial);
    r = runUnguarded(rtype.getClazz(), "getValue");
View Full Code Here

  @Test
  public void rewriteWithPrimitiveReturnValues_boolean() throws Exception {
    TypeRegistry typeRegistry = getTypeRegistry("data.HelloWorldPrimitive");
    ReloadableType rtype = typeRegistry.addType("data.HelloWorldPrimitive", loadBytesForClass("data.HelloWorldPrimitive"));

    Result r = runUnguarded(rtype.getClazz(), "getValueBoolean");
    assertTrue(r.returnValue instanceof Boolean);
    assertEquals(true, r.returnValue);

    rtype.loadNewVersion("000", rtype.bytesInitial);
    r = runUnguarded(rtype.getClazz(), "getValueBoolean");
View Full Code Here

  @Test
  public void rewriteWithPrimitiveReturnValues_short() throws Exception {
    TypeRegistry typeRegistry = getTypeRegistry("data.HelloWorldPrimitive");
    ReloadableType rtype = typeRegistry.addType("data.HelloWorldPrimitive", loadBytesForClass("data.HelloWorldPrimitive"));

    Result r = runUnguarded(rtype.getClazz(), "getValueShort");
    assertTrue(r.returnValue instanceof Short);
    assertEquals((short) 3, r.returnValue);

    rtype.loadNewVersion("000", rtype.bytesInitial);
    r = runUnguarded(rtype.getClazz(), "getValueShort");
View Full Code Here

  @Test
  public void rewriteWithPrimitiveReturnValues_long() throws Exception {
    TypeRegistry typeRegistry = getTypeRegistry("data.HelloWorldPrimitive");
    ReloadableType rtype = typeRegistry.addType("data.HelloWorldPrimitive", loadBytesForClass("data.HelloWorldPrimitive"));

    Result r = runUnguarded(rtype.getClazz(), "getValueLong");
    assertTrue(r.returnValue instanceof Long);
    assertEquals(3L, r.returnValue);

    rtype.loadNewVersion("000", rtype.bytesInitial);
    r = runUnguarded(rtype.getClazz(), "getValueLong");
View Full Code Here

TOP

Related Classes of org.springsource.loaded.test.infra.Result

Copyright © 2018 www.massapicom. 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.