Package org.jboss.forge.furnace

Examples of org.jboss.forge.furnace.Furnace


   /**
    * Hack to deploy addon in an immutable repository
    */
   private static void deployAddonInImmutableRepository(AddonId addonId, AddonRepository repository)
   {
      Furnace furnace = new FurnaceImpl();
      furnace.addRepository(AddonRepositoryMode.MUTABLE, repository.getRootDirectory());
      AddonManagerImpl addonManager = new AddonManagerImpl(furnace, new MavenAddonDependencyResolver());
      addonManager.deploy(addonId).perform();
   }
View Full Code Here


   {
      Assert.assertEquals(1, furnace.getRepositories().size());
      Assert.assertEquals(0, furnace.getAddonRegistry().getAddons().size());
      Assert.assertEquals(0, furnace.getRepositories().get(0).listEnabled().size());

      Furnace furnace2 = ServiceLoader.load(Furnace.class).iterator().next();
      AddonDependencyResolver resolver = new MavenAddonDependencyResolver();
      furnace2.addRepository(AddonRepositoryMode.MUTABLE, repository);
      AddonManager addonManager = new AddonManagerImpl(furnace2, resolver);

      AddonId addon = AddonId.from("test:no_dep", "1.1.2-SNAPSHOT");
      InstallRequest install = addonManager.install(addon);
      List<? extends AddonActionRequest> actions = install.getActions();
      Assert.assertEquals(1, actions.size());
      Assert.assertThat(actions.get(0), instanceOf(DeployRequest.class));
      install.perform();

      Addons.waitUntilStarted(furnace.getAddonRegistry().getAddon(addon));

      Assert.assertEquals(1, furnace2.getRepositories().get(0).listEnabled().size());
      Assert.assertEquals(1, furnace.getRepositories().get(0).listEnabled().size());
      Assert.assertEquals(1, furnace.getAddonRegistry().getAddons().size());
   }
View Full Code Here

   @Test
   public void testAddonsCanReferenceDependenciesInOtherRepositories() throws IOException
   {
      String[] args = new String[] { "arg1", "arg2" };

      Furnace forge = FurnaceFactory.getInstance();
      forge.setArgs(args);
      forge.addRepository(AddonRepositoryMode.MUTABLE, repodir1);
      forge.startAsync();

      String[] forgeArgs = forge.getArgs();
      Assert.assertArrayEquals(args, forgeArgs);

      forge.stop();
   }
View Full Code Here

   }

   @Test
   public void testGetVersionIsCallable() throws Exception
   {
      Furnace furnace = LocalServices.getFurnace(this.getClass().getClassLoader());
      furnace.getVersion();
   }
View Full Code Here

   private final AddonRegistry registry;

   public FacetFactoryImpl()
   {
      Furnace furnace = SimpleContainer.getFurnace(this.getClass().getClassLoader());
      this.registry = furnace.getAddonRegistry();
   }
View Full Code Here

   }

   @Test(timeout = 5000)
   public void testPreShutdownIsCalled() throws Exception
   {
      Furnace furnace = LocalServices.getFurnace(getClass().getClassLoader());
      AddonRegistry registry = furnace.getAddonRegistry();
      Addon dep2 = registry.getAddon(AddonId.from("dep2", "2"));
      RecordingEventManager manager = registry.getServices(RecordingEventManager.class).get();
      Assert.assertEquals(3, manager.getPostStartupCount());
      MutableAddonRepository repository = (MutableAddonRepository) furnace.getRepositories().get(0);
      repository.disable(dep2.getId());
      Addons.waitUntilStopped(dep2);
      Assert.assertEquals(1, manager.getPreShutdownCount());
   }
View Full Code Here

   }

   @Test
   public void testPostStartupIsCalled() throws Exception
   {
      Furnace furnace = LocalServices.getFurnace(getClass().getClassLoader());
      AddonRegistry registry = furnace.getAddonRegistry();
      RecordingEventManager manager = registry.getServices(RecordingEventManager.class).get();
      Assert.assertEquals(2, manager.getPostStartupCount());
   }
View Full Code Here

public class ContainerLifecycleListenerTest
{
   @Test
   public void testContainerStartup() throws Exception
   {
      Furnace furnace = FurnaceFactory.getInstance();
      TestLifecycleListener listener = new TestLifecycleListener();
      ListenerRegistration<ContainerLifecycleListener> registration = furnace.addContainerLifecycleListener(listener);
      File temp = File.createTempFile("addonDir", "sdfsdf");
      temp.deleteOnExit();
      furnace.addRepository(AddonRepositoryMode.IMMUTABLE, temp);

      furnace.startAsync();
      waitUntilStarted(furnace);
      Assert.assertEquals(1, listener.beforeStartTimesCalled);
      registration.removeListener();
      furnace.stop();
   }
View Full Code Here

   }

   private Imported<Scanner> resolveScanners() {
      if(importedScanners == null)
      {
         Furnace furnace = SimpleContainer.getFurnace(this.getClass().getClassLoader());
         if(furnace != null)
            this.importedScanners = furnace.getAddonRegistry().getServices(Scanner.class);
      }
      return importedScanners;
   }
View Full Code Here

   }

   @Test
   public void testAddonsSharedIfSubgraphEquivalent() throws IOException, InterruptedException, TimeoutException
   {
      Furnace furnace = FurnaceFactory.getInstance();
      AddonRepository left = furnace.addRepository(AddonRepositoryMode.MUTABLE, repodir1);
      AddonRepository right = furnace.addRepository(AddonRepositoryMode.MUTABLE, repodir2);

      AddonDependencyResolver resolver = new MavenAddonDependencyResolver();
      AddonManager manager = new AddonManagerImpl(furnace, resolver);

      AddonId no_dep = AddonId.from("test:no_dep", "1.0.0.Final");
      AddonId one_dep = AddonId.from("test:one_dep", "1.0.0.Final");
      AddonId one_dep_a = AddonId.from("test:one_dep_a", "1.0.0.Final");

      AddonId no_dep2 = AddonId.from("test:no_dep", "2.0.0.Final");

      Assert.assertFalse(left.isDeployed(one_dep_a));
      Assert.assertFalse(left.isDeployed(no_dep));
      Assert.assertFalse(left.isDeployed(no_dep2));
      Assert.assertFalse(left.isDeployed(one_dep));
      Assert.assertFalse(right.isDeployed(one_dep_a));
      Assert.assertFalse(right.isDeployed(no_dep));
      Assert.assertFalse(right.isDeployed(no_dep2));
      Assert.assertFalse(right.isDeployed(one_dep));

      manager.install(no_dep, left).perform();
      manager.deploy(one_dep, left).perform();

      manager.deploy(one_dep_a, right).perform();
      manager.deploy(no_dep2, right).perform();

      Assert.assertFalse(left.isDeployed(one_dep_a));
      Assert.assertFalse(right.isDeployed(one_dep));
      Assert.assertFalse(right.isDeployed(no_dep));
      Assert.assertFalse(left.isDeployed(no_dep2));
      Assert.assertTrue(left.isDeployed(no_dep));
      Assert.assertTrue(left.isDeployed(one_dep));
      Assert.assertTrue(right.isDeployed(one_dep_a));
      Assert.assertTrue(right.isDeployed(no_dep2));

      ConfigurationScanListener listener = new ConfigurationScanListener();
      ListenerRegistration<ContainerLifecycleListener> registration = furnace.addContainerLifecycleListener(listener);

      furnace.startAsync();

      while (!listener.isConfigurationScanned())
         Thread.sleep(100);

      AddonRegistry registry = furnace.getAddonRegistry();
      Addons.waitUntilStarted(registry.getAddon(one_dep_a), 10, TimeUnit.SECONDS);
      AddonRegistry leftRegistry = furnace.getAddonRegistry(left);

      Assert.assertNotNull(leftRegistry.getAddon(no_dep));
      Assert.assertTrue(registry.getAddon(no_dep).getStatus().isMissing());

      Assert.assertNotNull(registry.getAddon(no_dep2));
      Assert.assertTrue(leftRegistry.getAddon(no_dep2).getStatus().isMissing());

      registration.removeListener();

      furnace.stop();
   }
View Full Code Here

TOP

Related Classes of org.jboss.forge.furnace.Furnace

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.