Package org.jboss.forge.classloader.mock.collisions

Examples of org.jboss.forge.classloader.mock.collisions.InterfaceWithGetterAndSetter


      AddonRegistry registry = LocalServices.getFurnace(getClass().getClassLoader())
               .getAddonRegistry();
      ClassLoader thisLoader = ClassLoaderAdapterCollisionsTest.class.getClassLoader();
      ClassLoader dep1Loader = registry.getAddon(AddonId.from("dep1", "1")).getClassLoader();

      InterfaceWithGetterAndSetter enhanced;
      try
      {
         enhanced = (InterfaceWithGetterAndSetter) dep1Loader.loadClass(
                  ClassImplementsInterfaceWithGetterAndSetter.class.getName()).newInstance();
         Assert.fail("Should have received a " + ClassCastException.class.getName());
      }
      catch (ClassCastException e)
      {
      }
      catch (Exception e)
      {
         Assert.fail("Should have received a " + ClassCastException.class.getName());
      }

      Object delegate = dep1Loader.loadClass(ClassImplementsInterfaceWithGetterAndSetter.class.getName())
               .newInstance();
      enhanced = (InterfaceWithGetterAndSetter) ClassLoaderAdapterBuilder.callingLoader(thisLoader)
               .delegateLoader(dep1Loader).enhance(delegate);

      Assert.assertFalse(Proxies.isForgeProxy(delegate));
      Assert.assertFalse(Proxies.isProxyType(delegate.getClass()));
      Assert.assertTrue(Proxies.isForgeProxy(enhanced));
      Assert.assertTrue(Proxies.isProxyType(enhanced.getClass()));
      Assert.assertNotNull(enhanced);
      Assert.assertNull(enhanced.getPassthrough());
   }
View Full Code Here


      ClassLoader thisLoader = ClassLoaderAdapterCollisionsTest.class.getClassLoader();
      ClassLoader loader1 = registry.getAddon(AddonId.from("dep1", "1")).getClassLoader();

      try
      {
         InterfaceWithGetterAndSetter local = new ClassImplementsInterfaceWithGetterAndSetter();
         local.setPassthrough((InterfaceWithPassthroughMethod) loader1
                  .loadClass(ClassImplementsInterfaceWithPassthroughMethod.class.getName())
                  .newInstance());

         Assert.fail("Should have received a " + ClassCastException.class.getName());
      }
      catch (ClassCastException e)
      {
      }
      catch (Exception e)
      {
         Assert.fail("Should have received a " + ClassCastException.class.getName());
      }

      Object delegate = loader1.loadClass(ClassImplementsInterfaceWithGetterAndSetter.class.getName()).newInstance();
      InterfaceWithGetterAndSetter enhanced = (InterfaceWithGetterAndSetter) ClassLoaderAdapterBuilder
               .callingLoader(thisLoader).delegateLoader(loader1).enhance(delegate);

      enhanced.setPassthrough(new ClassImplementsInterfaceWithPassthroughMethod());

      Assert.assertNotNull(enhanced);
   }
View Full Code Here

      ClassLoader thisLoader = ClassLoaderAdapterCollisionsTest.class.getClassLoader();
      ClassLoader loader1 = registry.getAddon(AddonId.from("dep1", "1")).getClassLoader();

      try
      {
         InterfaceWithGetterAndSetter local = new ClassImplementsInterfaceWithGetterAndSetter();
         local.setPassthrough((InterfaceWithPassthroughMethod) loader1
                  .loadClass(ClassImplementsInterfaceWithPassthroughMethod.class.getName())
                  .newInstance());

         Assert.fail("Should have received a " + ClassCastException.class.getName());
      }
      catch (ClassCastException e)
      {
      }
      catch (Exception e)
      {
         Assert.fail("Should have received a " + ClassCastException.class.getName());
      }

      Object delegate = loader1.loadClass(ClassImplementsInterfaceWithGetterAndSetter.class.getName()).newInstance();
      InterfaceWithGetterAndSetter enhanced = (InterfaceWithGetterAndSetter) ClassLoaderAdapterBuilder
               .callingLoader(thisLoader).delegateLoader(loader1).enhance(delegate);

      enhanced.setPassthrough(new ClassImplementsInterfaceWithPassthroughMethod());
      Assert.assertNotNull(enhanced);

      InterfaceWithPassthroughMethod result = enhanced.getPassthrough();
      Assert.assertNotNull(result);
   }
View Full Code Here

TOP

Related Classes of org.jboss.forge.classloader.mock.collisions.InterfaceWithGetterAndSetter

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.