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

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


      AddonRegistry registry = LocalServices.getFurnace(getClass().getClassLoader())
               .getAddonRegistry();
      ClassLoader thisLoader = ClassLoaderAdapterPassthroughTest.class.getClassLoader();
      ClassLoader loader1 = registry.getAddon(AddonId.from("dep", "1")).getClassLoader();

      ClassWithGetterAndSetter local = new ClassWithGetterAndSetter();
      local.setPassthrough((ClassWithPassthroughMethod) loader1
               .loadClass(ClassWithPassthroughMethod.class.getName())
               .newInstance());

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

      enhanced.setPassthrough(new ClassWithPassthroughMethod());

      Assert.assertNotNull(enhanced);
      Assert.assertNotNull(enhanced.getPassthrough());
      Assert.assertFalse(Proxies.isForgeProxy(enhanced.getPassthrough()));
      Assert.assertFalse(enhanced.assertPassthroughNotProxied());
   }
View Full Code Here


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

      ClassWithGetterAndSetter enhanced;
      try
      {
         enhanced = (ClassWithGetterAndSetter) dep1Loader.loadClass(
                  ClassWithGetterAndSetter.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(ClassWithGetterAndSetter.class.getName()).newInstance();
      enhanced = (ClassWithGetterAndSetter) 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
      {
         ClassWithGetterAndSetter local = new ClassWithGetterAndSetter();
         local.setPassthrough((ClassWithPassthroughMethod) loader1
                  .loadClass(ClassWithPassthroughMethod.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(ClassWithGetterAndSetter.class.getName()).newInstance();
      ClassWithGetterAndSetter enhanced = (ClassWithGetterAndSetter) ClassLoaderAdapterBuilder
               .callingLoader(thisLoader).delegateLoader(loader1).enhance(delegate);

      enhanced.setPassthrough(new ClassWithPassthroughMethod());

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

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

      try
      {
         ClassWithGetterAndSetter local = new ClassWithGetterAndSetter();
         local.setPassthrough((ClassWithPassthroughMethod) loader1
                  .loadClass(ClassWithPassthroughMethod.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(ClassWithGetterAndSetter.class.getName()).newInstance();
      ClassWithGetterAndSetter enhanced = (ClassWithGetterAndSetter) ClassLoaderAdapterBuilder
               .callingLoader(thisLoader).delegateLoader(loader1).enhance(delegate);

      ClassWithPassthroughMethod parameterValue = new ClassWithPassthroughMethod();

      enhanced.setPassthrough(parameterValue);
      Assert.assertNotNull(enhanced);

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

      ClassLoader dep2Loader = registry.getAddon(AddonId.from("dep2", "2")).getClassLoader();

      ClassCreatesInstanceFromClassLoader creator;
      try
      {
         @SuppressWarnings("unused")
         ClassWithGetterAndSetter result = new ClassCreatesInstanceFromClassLoader()
                  .create(dep2Loader, ClassWithGetterAndSetter.class);
         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(ClassCreatesInstanceFromClassLoader.class.getName()).newInstance();
      creator = (ClassCreatesInstanceFromClassLoader) ClassLoaderAdapterBuilder.callingLoader(thisLoader)
               .delegateLoader(dep1Loader).enhance(delegate);

      ClassWithGetterAndSetter create = creator.create(dep2Loader, ClassWithGetterAndSetter.class);
      Assert.assertNotNull(create);
   }
View Full Code Here

TOP

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

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.