org.jboss.forge.addon.ui.test.UITestHarness Java Examples

The following examples show how to use org.jboss.forge.addon.ui.test.UITestHarness. 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: SetupCommandTest.java    From thorntail-addon with Eclipse Public License 1.0 5 votes vote down vote up
@Before
public void setUp() throws Exception
{
   AddonRegistry addonRegistry = Furnace.instance(getClass().getClassLoader()).getAddonRegistry();
   projectFactory = addonRegistry.getServices(ProjectFactory.class).get();
   uiTestHarness = addonRegistry.getServices(UITestHarness.class).get();
   shellTest = addonRegistry.getServices(ShellTest.class).get();
   project = projectFactory.createTempProject();
}
 
Example #2
Source File: CreateTestClassCommandTest.java    From thorntail-addon with Eclipse Public License 1.0 5 votes vote down vote up
@Before
public void setUp()
{
   AddonRegistry addonRegistry = Furnace.instance(getClass().getClassLoader()).getAddonRegistry();
   projectFactory = addonRegistry.getServices(ProjectFactory.class).get();
   uiTestHarness = addonRegistry.getServices(UITestHarness.class).get();
   shellTest = addonRegistry.getServices(ShellTest.class).get();
   project = projectFactory.createTempProject(Arrays.asList(JavaSourceFacet.class, ThorntailFacet.class));
}
 
Example #3
Source File: WindupUpdateDistributionCommandTest.java    From windup with Eclipse Public License 1.0 4 votes vote down vote up
@Test
@Ignore("The current implementation doesn't work as it tampers with addons loaded at the time."
            + " Even if it replaced all Windup addons, it would still fail on Windows as they keep the .jar's locked.")
public void testUpdateDistribution() throws Exception
{
    // Download and unzip an old distribution.
    final CoordinateBuilder coords = CoordinateBuilder.create()
                .setGroupId("org.jboss.windup")
                .setArtifactId("windup-distribution")
                .setClassifier("offline")
                .setVersion("2.2.0.Final")
                .setPackaging("zip");
    System.out.println("Downloading " + coords + ", may take a while.");
    List<Coordinate> results = resolver.resolveVersions(DependencyQueryBuilder.create(coords));

    File windupDir = OperatingSystemUtils.createTempDir();
    this.updater.extractArtifact(results.get(0), windupDir);
    windupDir = DistributionUpdater.getWindupDistributionSubdir(windupDir);
    Assert.assertTrue(windupDir.exists());
    System.setProperty(PathUtil.WINDUP_HOME, windupDir.getAbsolutePath());

    // Run the upgrader.
    distUpdater.replaceWindupDirectoryWithLatestDistribution();

    // Check the new version.
    String newUiVersion = getInstalledAddonVersion(windupDir.toPath().resolve("addons").toString(), WINDUP_UI_ADDON_NAME);
    Assert.assertTrue(SingleVersion.valueOf(newUiVersion).compareTo(SingleVersion.valueOf("2.2.0.Final")) > 0);

    // Try to run Windup from there.
    // TODO: I need to set the harness addons directory to the freshly created dir.
    UITestHarness harness = furnace.getAddonRegistry().getServices(UITestHarness.class).get();
    try (CommandController controller = harness.createCommandController(WindupCommand.class))
    {
        controller.initialize();
        controller.setValueFor(InputPathOption.NAME, Collections.singletonList(new File("src/test/resources/test.jar").getAbsolutePath()));
        final File resultDir = new File("target/testRunFromUpgraded");
        resultDir.mkdirs();
        controller.setValueFor(OutputPathOption.NAME, resultDir.getAbsolutePath());

        Result result = controller.execute();
        Assert.assertTrue(result.getMessage(), !(result instanceof Failed));
    }
    catch (Throwable ex)
    {
        throw new WindupException("Failed running Windup from the upgraded directory: " + ex.getMessage(), ex);
    }
}