org.jboss.forge.furnace.Furnace Java Examples

The following examples show how to use org.jboss.forge.furnace.Furnace. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StrictModeDisabledTest.java    From furnace with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testDependenciesAreCorrectlyDeployedAndAssigned()
{
   Furnace furnace = LocalServices.getFurnace(getClass().getClassLoader());
   Assert.assertSame(AddonCompatibilityStrategies.LENIENT, furnace.getAddonCompatibilityStrategy());

   Addon self = LocalServices.getAddon(getClass().getClassLoader());

   Set<org.jboss.forge.furnace.addons.AddonDependency> dependencies = self.getDependencies();
   Assert.assertEquals(2, dependencies.size());

   Iterator<org.jboss.forge.furnace.addons.AddonDependency> iterator = dependencies.iterator();

   org.jboss.forge.furnace.addons.AddonDependency incompatibleAddon = iterator.next();
   Assert.assertEquals(AddonId.from(INCOMPATIBLE, INCOMPATIBLE_VERSION), incompatibleAddon.getDependency().getId());
   Assert.assertEquals(AddonStatus.STARTED, incompatibleAddon.getDependency().getStatus());

   org.jboss.forge.furnace.addons.AddonDependency compatibleAddon = iterator.next();
   Assert.assertEquals(AddonId.from(COMPATIBLE, COMPATIBLE_VERSION), compatibleAddon.getDependency().getId());
   Assert.assertEquals(AddonStatus.STARTED, compatibleAddon.getDependency().getStatus());
}
 
Example #2
Source File: AddonManagerHotswapTest.java    From furnace with Eclipse Public License 1.0 6 votes vote down vote up
@Test(timeout = 20000)
public void testFurnaceLoadsInstalledAddonFromSeparateInstance() throws IOException, TimeoutException
{
   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());
}
 
Example #3
Source File: AddonManagerHotswapTest.java    From furnace with Eclipse Public License 1.0 6 votes vote down vote up
@Before
public void setUp() throws IOException, InterruptedException
{
   furnace = ServiceLoader.load(Furnace.class).iterator().next();
   resolver = new MavenAddonDependencyResolver();
   repository = File.createTempFile("furnace-repo", ".tmp");
   repository.delete();
   repository.mkdir();
   furnace.addRepository(AddonRepositoryMode.MUTABLE, repository);
   furnace.startAsync();
   while (!furnace.getStatus().isStarted())
   {
      Thread.sleep(100);
   }
   addonManager = new AddonManagerImpl(furnace, resolver);
}
 
Example #4
Source File: FurnaceProducer.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
public void setup(File repoDir) {
	furnace = FurnaceFactory.getInstance(Thread.currentThread()
			.getContextClassLoader(), Thread.currentThread()
			.getContextClassLoader());
	furnace.addRepository(AddonRepositoryMode.IMMUTABLE, repoDir);
	Future<Furnace> future = furnace.startAsync();

	try {
		future.get();
	} catch (InterruptedException | ExecutionException e) {
		throw new RuntimeException("Furnace failed to start.", e);
	}

	AddonRegistry addonRegistry = furnace.getAddonRegistry();
	commandFactory = addonRegistry.getServices(CommandFactory.class).get();
	controllerFactory = (CommandControllerFactory) addonRegistry
			.getServices(CommandControllerFactory.class.getName()).get();
       dependencyResolver = (DependencyResolver) addonRegistry
               .getServices(DependencyResolver.class.getName()).get();
}
 
Example #5
Source File: ParserContext.java    From windup with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Initialize tag handlers based upon the provided furnace instance.
 */
public ParserContext(Furnace furnace, RuleLoaderContext ruleLoaderContext)
{
    this.ruleLoaderContext = ruleLoaderContext;

    @SuppressWarnings("rawtypes")
    Imported<ElementHandler> loadedHandlers = furnace.getAddonRegistry().getServices(ElementHandler.class);
    for (ElementHandler<?> handler : loadedHandlers)
    {
        NamespaceElementHandler annotation = Annotations.getAnnotation(handler.getClass(),
                    NamespaceElementHandler.class);
        if (annotation != null)
        {
            HandlerId handlerID = new HandlerId(annotation.namespace(), annotation.elementName());
            if (handlers.containsKey(handlerID))
            {
                String className1 = Proxies.unwrapProxyClassName(handlers.get(handlerID).getClass());
                String className2 = Proxies.unwrapProxyClassName(handler.getClass());
                throw new WindupException("Multiple handlers registered with id: " + handlerID + " Classes are: "
                            + className1 + " and " + className2);
            }
            handlers.put(handlerID, handler);
        }
    }
}
 
Example #6
Source File: FurnaceProtocol.java    From furnace with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public ContainerMethodExecutor getExecutor(FurnaceProtocolConfiguration protocolConfiguration,
         ProtocolMetaData metaData, CommandCallback callback)
{
   if (metaData == null)
   {
      return new ContainerMethodExecutor()
      {
         @Override
         public TestResult invoke(TestMethodExecutor arg0)
         {
            return TestResult.skipped();
         }
      };
   }

   Collection<FurnaceHolder> contexts = metaData.getContexts(FurnaceHolder.class);
   if (contexts.size() == 0)
   {
      throw new IllegalArgumentException(
               "No " + Furnace.class.getName() + " found in " + ProtocolMetaData.class.getName() + ". " +
                        "Furnace protocol can not be used");
   }
   return new FurnaceTestMethodExecutor(protocolConfiguration, contexts.iterator().next());
}
 
Example #7
Source File: AddonRemoveMojo.java    From furnace with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void execute() throws MojoExecutionException, MojoFailureException
{
   if (skip)
   {
      getLog().info("Execution skipped.");
      return;
   }
   if (!addonRepository.exists())
   {
      throw new MojoExecutionException("Addon Repository " + addonRepository.getAbsolutePath() + " does not exist.");
   }
   Furnace forge = new FurnaceImpl();
   AddonRepository repository = forge.addRepository(AddonRepositoryMode.MUTABLE, addonRepository);
   MavenAddonDependencyResolver addonResolver = new MavenAddonDependencyResolver(this.classifier);
   addonResolver.setSettings(settings);
   AddonManager addonManager = new AddonManagerImpl(forge, addonResolver);
   for (String addonId : addonIds)
   {
      AddonId id = AddonId.fromCoordinates(addonId);
      RemoveRequest request = addonManager.remove(id, repository);
      getLog().info("" + request);
      request.perform();
   }
}
 
Example #8
Source File: AddonRepositoryLoadingTest.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testAddonRepositoryIsCorrectInMultiViewEnvironment() throws Exception
{
   Furnace furnace = LocalServices.getFurnace(getClass().getClassLoader());
   Assert.assertNotNull(furnace);
   AddonRegistry registry = furnace.getAddonRegistry();
   AddonRepository rep1 = registry.getAddon(AddonId.from("dep1", "1")).getRepository();
   AddonRepository rep2 = registry.getAddon(AddonId.from("dep2", "2")).getRepository();
   AddonRepository rep3 = registry.getAddon(AddonId.from("dep3", "3")).getRepository();
   AddonRepository rep4 = registry.getAddon(AddonId.from("dep4", "4")).getRepository();
   AddonRepository rep5 = registry.getAddon(AddonId.from("dep5", "5")).getRepository();
   Assert.assertEquals(rep1, rep2);
   Assert.assertEquals(rep3, rep4);
   Assert.assertEquals(rep4, rep5);
}
 
Example #9
Source File: GraphContextImpl.java    From windup with Eclipse Public License 1.0 5 votes vote down vote up
public GraphContextImpl(Furnace furnace, GraphTypeManager typeManager,
            GraphApiCompositeClassLoaderProvider classLoaderProvider, Path graphDir)
{
    this.furnace = furnace;
    this.graphTypeManager = typeManager;
    this.classLoaderProvider = classLoaderProvider;
    this.graphDir = graphDir;
}
 
Example #10
Source File: BootstrapClassLoaderTestCase.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void shouldBeAbleToPassPrimitivesIntoDelegate() throws Exception
{
   Furnace instance = FurnaceFactory.getInstance();
   Assert.assertNotNull(instance);
   instance.setServerMode(false);
}
 
Example #11
Source File: AddonModuleLoader.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
public AddonModuleLoader(Furnace furnace, AddonLifecycleManager lifecycleManager, AddonStateManager stateManager)
{
   this.furnace = furnace;
   this.lifecycleManager = lifecycleManager;
   this.stateManager = stateManager;
   this.moduleCache = new AddonModuleIdentifierCache();
   this.moduleJarFileCache = new AddonModuleJarFileCache();
   installModuleMBeanServer();
}
 
Example #12
Source File: AddonRunnable.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
public AddonRunnable(Furnace furnace, AddonLifecycleManager lifecycleManager, AddonStateManager stateManager,
         Addon addon)
{
   this.lifecycleManager = lifecycleManager;
   this.stateManager = stateManager;
   this.furnace = furnace;
   this.addon = addon;
}
 
Example #13
Source File: PopulateMavenRepositoryTest.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
protected void createProjects(Furnace furnace) throws Exception {
    File projectsOutputFolder = new File(baseDir, "target/createdProjects");
    Files.recursiveDelete(projectsOutputFolder);

    ProjectGenerator generator = new ProjectGenerator(furnace, projectsOutputFolder, localMavenRepo);
    File archetypeJar = generator.getArtifactJar("io.fabric8.archetypes", "archetypes-catalog", ProjectGenerator.FABRIC8_ARCHETYPE_VERSION);

    List<String> archetypes = getArchetypesFromJar(archetypeJar);
    assertThat(archetypes).describedAs("Archetypes to create").isNotEmpty();

    String testArchetype = System.getProperty(TEST_ARCHETYPE_SYSTEM_PROPERTY, "");
    if (Strings.isNotBlank(testArchetype)) {
        LOG.info("Due to system property: '" + TEST_ARCHETYPE_SYSTEM_PROPERTY + "' we will just run the test on archetype: " + testArchetype);
        generator.createProjectFromArchetype(testArchetype);
    } else {
        for (String archetype : archetypes) {
            // TODO fix failing archetypes...
            if (!archetype.startsWith("jboss-fuse-") && !archetype.startsWith("swarm")) {
                generator.createProjectFromArchetype(archetype);
            }
        }
    }

    removeSnapshotFabric8Artifacts();


    List<File> failedFolders = generator.getFailedFolders();
    if (failedFolders.size() > 0) {
        LOG.error("Failed to build all the projects!!!");
        for (File failedFolder : failedFolders) {
            LOG.error("Failed to build project: " + failedFolder.getName());
        }
    }
}
 
Example #14
Source File: PopulateMavenRepositoryTest.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@Test
public void testPopulateMavenRepo() throws Exception {
    // lets point to a local maven repo
    localMavenRepo.mkdirs();
    System.setProperty("maven.repo.local", localMavenRepo.getAbsolutePath());

    Furnaces.withFurnace(new FurnaceCallback<String>() {

        @Override
        public String invoke(Furnace furnace) throws Exception {
            createProjects(furnace);
            return null;
        }
    });
}
 
Example #15
Source File: ContainerLifecycleListenerTest.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
private void waitUntilStarted(Furnace furnace) throws InterruptedException
{
   while (!furnace.getStatus().isStarted())
   {
      Thread.sleep(150);
   }
}
 
Example #16
Source File: Furnaces.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
public static <T> T withFurnace(FurnaceCallback<T> callback) throws Exception {
    Furnace furnace = startFurnace();
    try {
        return callback.invoke(furnace);
    } finally {
        furnace.stop();
    }
}
 
Example #17
Source File: AddonManagerRealTest.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@Before
public void setUp() throws IOException
{
   furnace = ServiceLoader.load(Furnace.class).iterator().next();
   resolver = new MavenAddonDependencyResolver();
   repository = OperatingSystemUtils.createTempDir();
   furnace.addRepository(AddonRepositoryMode.MUTABLE, repository);
   addonManager = new AddonManagerImpl(furnace, resolver);
}
 
Example #18
Source File: ForgeSetArgsTest.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@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();
}
 
Example #19
Source File: AddonManagerInstallTest.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@Before
public void setUp() throws IOException
{
   furnace = ServiceLoader.load(Furnace.class).iterator().next();
   resolver = new MavenAddonDependencyResolver();
   repository = OperatingSystemUtils.createTempDir();
   furnace.addRepository(AddonRepositoryMode.MUTABLE, repository);
   addonManager = new AddonManagerImpl(furnace, resolver);
}
 
Example #20
Source File: TestRepositoryDeploymentListener.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void preDeploy(Furnace furnace, Archive<?> archive) throws Exception
{
   previousUserSettings = System.setProperty(MavenContainer.ALT_USER_SETTINGS_XML_LOCATION,
            getAbsolutePath("profiles/settings.xml"));
   previousLocalRepository = System.setProperty(MavenContainer.ALT_LOCAL_REPOSITORY_LOCATION,
            "target/the-other-repository");
}
 
Example #21
Source File: AddonManagerRepositoryTest.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #22
Source File: WindupUpdateDistributionCommandTest.java    From windup with Eclipse Public License 1.0 5 votes vote down vote up
private void waitForOldWindupUIAddon(Furnace furnace) throws InterruptedException
{
    Addon addon = furnace.getAddonRegistry().getAddon(AddonId.from(WINDUP_UI_ADDON_NAME, WINDUP_OLD_VERSION));
    Addons.waitUntilStarted(addon);
    do
    {
        // We need to wait till furnace will process all the information changed in the directories.
        Thread.sleep(500);
    }
    while (furnace.getAddonRegistry().getServices(WindupUpdateDistributionCommand.class).isUnsatisfied());
}
 
Example #23
Source File: FurnaceImpl.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Furnace setServerMode(boolean server)
{
   assertNotAlive();
   this.serverMode = server;
   return this;
}
 
Example #24
Source File: AddonLoader.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
public AddonLoader(Furnace furnace, AddonLifecycleManager lifecycleManager, AddonStateManager stateManager,
         AddonModuleLoader loader)
{
   this.lock = furnace.getLockManager();
   this.lifecycleManager = lifecycleManager;
   this.stateManager = stateManager;
   this.loader = loader;
}
 
Example #25
Source File: ImportedTest.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testIsAmbiguous() throws Exception
{
   Furnace furnace = LocalServices.getFurnace(getClass().getClassLoader());
   AddonRegistry registry = furnace.getAddonRegistry();
   Imported<MockInterface> services = registry.getServices(MockInterface.class);
   Assert.assertFalse(services.isUnsatisfied());
   Assert.assertTrue(services.isAmbiguous());
}
 
Example #26
Source File: AddonActionRequestFactory.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
public static UpdateRequest createUpdateRequest(AddonInfo addonToRemove, AddonInfo addonToInstall,
         MutableAddonRepository repository, Furnace furnace)
{
   RemoveRequest removeRequest = createRemoveRequest(addonToRemove, repository, furnace);
   DeployRequest installRequest = createDeployRequest(addonToInstall, repository, furnace);
   return new UpdateRequestImpl(removeRequest, installRequest);
}
 
Example #27
Source File: SpringBootFabric8SetupTest.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateNewSpringBootProjectAndRunFabric8Setup() throws Exception {
    // lets point to a local maven repo
    localMavenRepo.mkdirs();
    System.setProperty("maven.repo.local", localMavenRepo.getAbsolutePath());

    Furnaces.withFurnace(new FurnaceCallback<String>() {

        @Override
        public String invoke(Furnace furnace) throws Exception {
            createNewProject(furnace);
            return null;
        }
    });
}
 
Example #28
Source File: FurnaceTestMethodExecutor.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
private void waitUntilStable(Furnace furnace) throws InterruptedException
{
   while (furnace.getStatus().isStarting())
   {
      Thread.sleep(10);
   }
}
 
Example #29
Source File: FreeMarkerOperation.java    From windup with Eclipse Public License 1.0 5 votes vote down vote up
protected FreeMarkerOperation(Furnace furnace, String templatePath, String outputFilename, String... varNames)
{
    this.furnace = furnace;
    this.templatePath = templatePath.replace('\\', '/');
    this.outputFilename = outputFilename;
    this.variableNames = Arrays.asList(varNames);
}
 
Example #30
Source File: GraphTypeManager.java    From windup with Eclipse Public License 1.0 4 votes vote down vote up
private Furnace getFurnace()
{
    if (furnace == null)
        this.furnace = SimpleContainer.getFurnace(GraphContextFactory.class.getClassLoader());
    return this.furnace;
}