Examples of ExceptionFactory


Examples of org.jboss.forge.classloader.mock.exceptions.ExceptionFactory

      ClassLoader dep1Loader = registry.getAddon(AddonId.from("dep", "1")).getClassLoader();

      Class<?> foreignType = dep1Loader.loadClass(ExceptionFactory.class.getName());
      try
      {
         ExceptionFactory factory = (ExceptionFactory) foreignType.newInstance();

         Assert.fail("Should have received a " + ClassCastException.class.getName() + " but got a real object ["
                  + factory + "]");
      }
      catch (ClassCastException e)
      {
      }
      catch (Exception e)
      {
         Assert.fail("Should have received a " + ClassCastException.class.getName() + " but was: " + e);
      }

      Object delegate = foreignType.newInstance();
      ExceptionFactory enhancedFactory = (ExceptionFactory) ClassLoaderAdapterBuilder.callingLoader(thisLoader)
               .delegateLoader(dep1Loader).enhance(delegate);

      Assert.assertTrue(Proxies.isForgeProxy(enhancedFactory));

      String message = "AbstractA message.";
      try
      {
         enhancedFactory.throwException(message);
      }
      catch (MockException e)
      {
         Assert.assertTrue(Proxies.isForgeProxy(e));
         Assert.assertEquals(message, e.getMessage());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.