Package org.jboss.forge.classloader.mock

Examples of org.jboss.forge.classloader.mock.MockSimpleCountService


   public void testServiceProxiesCanBeInterrupted() throws Exception
   {
      AddonRegistry registry = LocalServices.getFurnace(getClass().getClassLoader())
               .getAddonRegistry();

      final MockSimpleCountService service = registry.getServices(MockSimpleCountService.class).get();
      final AtomicReference<ContainerException> exception = new AtomicReference<>();
      Thread t = new Thread(new Runnable()
      {
         @Override
         public void run()
         {
            try
            {
               while (true)
               {
                  service.execute();
               }
            }
            catch (ContainerException e)
            {
               exception.set(e);
            }

            if (!Thread.currentThread().isInterrupted())
               throw new RuntimeException("Should have been interrupted at this point.");
         }
      });

      Assert.assertNull(exception.get());

      t.start();
      Thread.sleep(250);
      t.interrupt();
      Thread.sleep(250);

      Assert.assertTrue(service.execute() > 0);
      Assert.assertNotNull(exception.get());
   }
View Full Code Here

TOP

Related Classes of org.jboss.forge.classloader.mock.MockSimpleCountService

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.