Package org.springsource.loaded

Examples of org.springsource.loaded.ReloadableType$MergedRewrite$ChainedAdapters


  }

  @Test
  public void reloadSubtype() throws Exception {
    subLoader.loadAsReloadableType("superpkg.Top");
    ReloadableType rtypeB = subLoader.loadAsReloadableType("subpkg.Bottom");

    result = runUnguarded(rtypeB.getClazz(), "m");
    assertEquals("Bottom.m() running", result.stdout);

    rtypeB.loadNewVersion("2", retrieveRename("subpkg.Bottom", "subpkg.Bottom002", "superpkg.Top002:superpkg.Top"));
    result = runUnguarded(rtypeB.getClazz(), "m");
    assertEquals("Bottom002.m() running", result.stdout);
  }
View Full Code Here


    assertEquals("Bottom002.m() running", result.stdout);
  }

  @Test
  public void reloadSupertype() throws Exception {
    ReloadableType rtypeA = subLoader.loadAsReloadableType("superpkg.Top");
    subLoader.loadAsReloadableType("subpkg.Bottom");

    result = runUnguarded(rtypeA.getClazz(), "m");
    assertEquals("Top.m() running", result.stdout);

    rtypeA.loadNewVersion("2", retrieveRename("superpkg.Top", "superpkg.Top002"));
    result = runUnguarded(rtypeA.getClazz(), "m");
    assertEquals("Top002.m() running", result.stdout);
  }
View Full Code Here

  @Test
  public void reloadSupertypeCalledThroughSubtype() throws Exception {
    String top = "superpkg.Top";
    String bot = "subpkg.Bottom";

    ReloadableType rtypeA = subLoader.loadAsReloadableType(top);
    ReloadableType rtypeB = subLoader.loadAsReloadableType(bot);

    rtypeA.loadNewVersion("2", retrieveRename(top, top + "003"));
    rtypeB.loadNewVersion("2", retrieveRename(bot, bot + "003", top + "003:" + top));

    // Check the registry looks right for Top
    int topId = NameRegistry.getIdFor("superpkg/Top");
    TypeRegistry trTop = TypeRegistry.getTypeRegistryFor(subLoader.getParent());
    assertEquals(0, topId);
    assertEquals(top, trTop.getReloadableType(topId).getName());
    assertEquals(top, trTop.getReloadableType("superpkg/Top").getName());

    int bottomId = NameRegistry.getIdFor("subpkg/Bottom");
    TypeRegistry trBot = TypeRegistry.getTypeRegistryFor(subLoader);
    assertEquals(1, bottomId);
    assertEquals(bot, trBot.getReloadableType(bottomId).getName());
    assertEquals(bot, trBot.getReloadableType("subpkg/Bottom").getName());

    // Now call the m() in the Bottom003 type, which calls super.newMethodOnTop()
    result = runUnguarded(rtypeB.getClazz(), "m");
    assertEquals("newMethodOnTop() running", result.stdout);
  }
View Full Code Here

  @Test
  public void reloadTargetInSuperloader() throws Exception {
    String target = "superpkg.Target";
    String invoker = "subpkg.Invoker";

    ReloadableType targetR = subLoader.loadAsReloadableType(target);
    ReloadableType invokerR = subLoader.loadAsReloadableType(invoker);

    targetR.loadNewVersion("2", retrieveRename(target, target + "002"));
    invokerR.loadNewVersion("2", retrieveRename(invoker, invoker + "002", target + "002:" + target));

    // Check the registry looks right for target
    int targetId = NameRegistry.getIdFor(toSlash(target));
    assertEquals(0, targetId);
    TypeRegistry trtarget = TypeRegistry.getTypeRegistryFor(subLoader.getParent());
    assertEquals(target, trtarget.getReloadableType(targetId).getName());
    assertEquals(target, trtarget.getReloadableType(toSlash(target)).getName());

    int invokerId = NameRegistry.getIdFor(toSlash(invoker));
    TypeRegistry trinvokerR = TypeRegistry.getTypeRegistryFor(subLoader);
    assertEquals(1, invokerId);
    assertEquals(invoker, trinvokerR.getReloadableType(invokerId).getName());
    assertEquals(invoker, trinvokerR.getReloadableType(toSlash(invoker)).getName());

    // Now call the run() in the Invoker type, which calls 'Target.m()' where Target is in a different loader
    // and has been reloaded
    result = runUnguarded(invokerR.getClazz(), "run");
    assertEquals("Target002.m() running", result.stdout);
  }
View Full Code Here

  @Test
  public void reloadTargetInSuperloaderCallingStaticMethod() throws Exception {
    String target = "superpkg.TargetB";
    String invoker = "subpkg.InvokerB";

    ReloadableType targetR = subLoader.loadAsReloadableType(target);
    ReloadableType invokerR = subLoader.loadAsReloadableType(invoker);

    targetR.loadNewVersion("2", retrieveRename(target, target + "002"));
    invokerR.loadNewVersion("2", retrieveRename(invoker, invoker + "002", target + "002:" + target));

    // Check the registry looks right for target
    int targetId = NameRegistry.getIdFor(toSlash(target));
    assertEquals(0, targetId);
    TypeRegistry trtarget = TypeRegistry.getTypeRegistryFor(subLoader.getParent());
    assertEquals(target, trtarget.getReloadableType(targetId).getName());
    assertEquals(target, trtarget.getReloadableType(toSlash(target)).getName());

    int invokerId = NameRegistry.getIdFor(toSlash(invoker));
    TypeRegistry trinvokerR = TypeRegistry.getTypeRegistryFor(subLoader);
    assertEquals(1, invokerId);
    assertEquals(invoker, trinvokerR.getReloadableType(invokerId).getName());
    assertEquals(invoker, trinvokerR.getReloadableType(toSlash(invoker)).getName());

    // Now call the run() in the Invoker type, which calls 'Target.m()' where Target is in a different loader
    // and has been reloaded
    result = runUnguarded(invokerR.getClazz(), "run");
    assertEquals("TargetB002.m() running", result.stdout);
  }
View Full Code Here

 
  @Test
  public void superdispatchers() throws Exception {
    String sub = "subpkg.Controller";
   
    ReloadableType subR = subLoader.loadAsReloadableType(sub);
   
    Result result = runOnInstance(subR.getClazz(), subR.getClazz().newInstance(), "foo");
    assertEquals("grails.Top.foo() running\nsubpkg.ControllerB.foo() running",result.stdout);

    // Reload the subtype
    subR.loadNewVersion("2",retrieveRename(sub,sub+"002"));
   
    result = runOnInstance(subR.getClazz(), subR.getClazz().newInstance(), "foo");
    assertEquals("grails.Top.foo() running\nsubpkg.ControllerB.foo() running again!",result.stdout);
  }
View Full Code Here

  public void reloadTargetInSuperloaderCallingStaticMethod2() throws Exception {
    // start out same as previous test, then loads a further version:
    String target = "superpkg.TargetB";
    String invoker = "subpkg.InvokerB";

    ReloadableType targetR = subLoader.loadAsReloadableType(target);
    ReloadableType invokerR = subLoader.loadAsReloadableType(invoker);

    targetR.loadNewVersion("2", retrieveRename(target, target + "002"));
    invokerR.loadNewVersion("2", retrieveRename(invoker, invoker + "002", target + "002:" + target));

    // Now call the run() in the Invoker type, which calls 'Target.m()' where Target is in a different loader
    // and has been reloaded
    result = runUnguarded(invokerR.getClazz(), "run");
    assertEquals("TargetB002.m() running", result.stdout);

    // now new: load new version of target that is missing the method

    targetR.loadNewVersion("3", targetR.bytesInitial);
    try {
      result = runUnguarded(invokerR.getClazz(), "run");
      fail("");
    } catch (InvocationTargetException ite) {
      assertTrue(ite.getCause() instanceof NoSuchMethodError);
      assertEquals("TargetB.m()V", ite.getCause().getMessage());
    }
View Full Code Here

  public void reloadCheckingCompatibilityForReturnedFields() throws Exception {
    // start out same as previous test, then loads a further version:
    String target = "superpkg.TargetD";
    String invoker = "subpkg.InvokerD";

    ReloadableType targetR = subLoader.loadAsReloadableType(target);
    ReloadableType invokerR = subLoader.loadAsReloadableType(invoker);

    result = runUnguardedWithCCL(invokerR.getClazz(), subLoader, "run");
    assertEquals("null", result.stdout);

    targetR.loadNewVersion("2", retrieveRename(target, target + "002"));
    //    invokerR.loadNewVersion("2", retrieveRename(invoker, invoker + "002", target + "002:" + target));

    // Now call the run() in the Invoker type, which calls 'Target.m()' where Target is in a different loader
    // and has been reloaded
    result = runUnguardedWithCCL(invokerR.getClazz(), subLoader, "run");
    assertEquals("a subby", result.stdout);
  }
View Full Code Here

  @Test
  public void reloadTargetInSuperLoaderCallingSuper() throws Exception {
    String top = "superpkg.TopB";
    String bot = "subpkg.BottomB";

    ReloadableType rtypeA = subLoader.loadAsReloadableType(top);
    ReloadableType rtypeB = subLoader.loadAsReloadableType(bot);

    rtypeA.loadNewVersion("2", retrieveRename(top, top + "002"));
    rtypeB.loadNewVersion("2", retrieveRename(bot, bot + "002", top + "002:" + top));

    // Check the registry looks right for Top
    int topId = NameRegistry.getIdFor("superpkg/TopB");
    TypeRegistry trTop = TypeRegistry.getTypeRegistryFor(subLoader.getParent());
    assertEquals(0, topId);
    assertEquals(top, trTop.getReloadableType(topId).getName());
    assertEquals(top, trTop.getReloadableType("superpkg/TopB").getName());

    int bottomId = NameRegistry.getIdFor("subpkg/BottomB");
    TypeRegistry trBot = TypeRegistry.getTypeRegistryFor(subLoader);
    assertEquals(1, bottomId);
    assertEquals(bot, trBot.getReloadableType(bottomId).getName());
    assertEquals(bot, trBot.getReloadableType("subpkg/BottomB").getName());

    // Now call the m() in the Bottom003 type, which calls super.newMethodOnTop()
    result = runUnguarded(rtypeB.getClazz(), "m");
    assertEquals("TopB002.m() running", result.stdout);
  }
View Full Code Here

    // start out same as previous test, then loads a further version:
    String target = "superpkg.TargetC";
    String targetImpl = "superpkg.TargetImplC";
    String invoker = "subpkg.InvokerC";

    ReloadableType targetR = subLoader.loadAsReloadableType(target);
    ReloadableType targetImplR = subLoader.loadAsReloadableType(targetImpl);
    ReloadableType invokerR = subLoader.loadAsReloadableType(invoker);

    targetR.loadNewVersion("2", retrieveRename(target, target + "002"));
    targetImplR.loadNewVersion("2", retrieveRename(targetImpl, targetImpl + "002", target + "002:" + target));
    invokerR.loadNewVersion("2",
        retrieveRename(invoker, invoker + "002", target + "002:" + target, targetImpl + "002:" + targetImpl));

    // Now call the run() in the Invoker type, which calls 'Target.m()' where Target is in a different loader
    // and has been reloaded
    result = runUnguarded(invokerR.getClazz(), "run");
    assertEquals("TargetImplC002.m() running", result.stdout);

    // now new: load new version of target that is missing the method

    targetR.loadNewVersion("3", targetR.bytesInitial);
    try {
      result = runUnguarded(invokerR.getClazz(), "run");
      fail("");
    } catch (InvocationTargetException ite) {
      assertTrue(ite.getCause() instanceof NoSuchMethodError);
      assertEquals("TargetC.m()V", ite.getCause().getMessage());
    }
View Full Code Here

TOP

Related Classes of org.springsource.loaded.ReloadableType$MergedRewrite$ChainedAdapters

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.