[
https://issues.jboss.org/browse/FORGE-2548?page=com.atlassian.jira.plugin...
]
George Gastaldi commented on FORGE-2548:
----------------------------------------
I found the bug and fixed. Here is a test case illustrating how I found the problem:
{code}
package org.jboss.forge.addon.scaffold;
import java.io.File;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.forge.addon.projects.Project;
import org.jboss.forge.addon.projects.ProjectFactory;
import org.jboss.forge.addon.resource.Resource;
import org.jboss.forge.addon.resource.ResourceFactory;
import org.jboss.forge.addon.ui.controller.WizardCommandController;
import org.jboss.forge.addon.ui.test.UITestHarness;
import org.jboss.forge.arquillian.AddonDependencies;
import org.jboss.forge.arquillian.AddonDependency;
import org.jboss.forge.arquillian.archive.AddonArchive;
import org.jboss.forge.furnace.container.simple.Service;
import org.jboss.forge.furnace.container.simple.lifecycle.SimpleContainer;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* @author <a href="mailto:ggastald@redhat.com">George Gastaldi</a>
*/
@RunWith(Arquillian.class)
public class ClausBugTest
{
private UITestHarness testHarness;
private ProjectFactory projectFactory;
private ResourceFactory resourceFactory;
@Deployment
@AddonDependencies({
@AddonDependency(name = "org.jboss.forge.addon:parser-java"),
@AddonDependency(name = "org.jboss.forge.addon:maven"),
@AddonDependency(name = "org.jboss.forge.addon:projects"),
@AddonDependency(name = "org.jboss.forge.addon:ui"),
@AddonDependency(name = "org.jboss.forge.addon:ui-test-harness"),
@AddonDependency(name =
"org.jboss.forge.furnace.container:simple"),
@AddonDependency(name = "io.fabric8.forge:camel", version =
"2.2.72")
})
public static AddonArchive getDeployment()
{
return ShrinkWrap
.create(AddonArchive.class)
.addAsServiceProvider(Service.class, ClausBugTest.class);
}
@Before
public void setUp()
{
projectFactory = SimpleContainer.getServices(getClass().getClassLoader(),
ProjectFactory.class).get();
resourceFactory = SimpleContainer.getServices(getClass().getClassLoader(),
ResourceFactory.class).get();
testHarness = SimpleContainer.getServices(getClass().getClassLoader(),
UITestHarness.class).get();
}
@Test
public void testSomething() throws Exception
{
Resource<File> root = resourceFactory.create(new
File("/home/ggastald/workspace/foo"));
Project project = projectFactory.findProject(root);
Assert.assertNotNull("Should have found a project", project);
try (WizardCommandController controller =
testHarness.createWizardController("Camel: Add Endpoint", root))
{
Assert.assertNotNull("Should have created controller", controller);
controller.initialize();
controller.setValueFor("componentName", "netty4-http");
controller.setValueFor("instanceName", "Foo");
controller.setValueFor("routeBuilder", "org.foo.MyRoutes");
Assert.assertTrue(controller.canMoveToNextStep());
controller.next().initialize();
controller.setValueFor("host", "host");
controller.setValueFor("port", "8080");
controller.setValueFor("path", "path");
Assert.assertTrue(controller.canMoveToNextStep());
controller.next().initialize();
}
}
}
{code}
Better error message what is wrong in a custom wizard for addon
developers
--------------------------------------------------------------------------
Key: FORGE-2548
URL:
https://issues.jboss.org/browse/FORGE-2548
Project: Forge
Issue Type: Enhancement
Affects Versions: 3.0.0.Alpha2
Reporter: Claus Ibsen
When you develop custom addon's then various things can go wrong. And whether the
command runs in CLI or IDEA or Eclipse then it works a little bit differently.
I have a command wizard that fails with this cryptic index out of bounds exception. I
finally found the stracktrace in idea.log file, as IDEA itself says nothing
{code}
2015-12-08 10:45:34,976 [ 148775] ERROR - llij.ide.plugins.PluginManager - Index: 2,
Size: 2
java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at
org.jboss.forge.addon.ui.impl.controller.WizardCommandControllerImpl.getCurrentEntry(WizardCommandControllerImpl.java:491)
at
org.jboss.forge.addon.ui.impl.controller.WizardCommandControllerImpl.getCurrentController(WizardCommandControllerImpl.java:502)
at
org.jboss.forge.addon.ui.impl.controller.WizardCommandControllerImpl.getInputs(WizardCommandControllerImpl.java:244)
at
org.jboss.forge.addon.ui.impl.controller.NoUIWizardControllerDecorator.getInputs(NoUIWizardControllerDecorator.java:189)
{code}
As all the stacktrace is purely in forge code, I cannot really see what I do wrong.
Can you guys improve that part of the code that has the index out of bounds and do a
better exception message that can help me what is the problem / as well other addon
developers.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)