Beispiel #1
0
  public void process() {

    File reportDirectory = new File("target/test/dummy/output");

    try {
      switchyardForgeRegistrar = new SwitchyardForgeRegistrar(reportDirectory);

      if (switchyardForgeRegistrar.createProject("myProject") != null) {

        Project project = switchyardForgeRegistrar.getProject();
        if (project == null) {
          LOG.warn("No project found ");
        } else {

          MetadataFacet mdf = project.getFacet(MetadataFacet.class);
          mdf.setProjectName(project.getProjectRoot().getName());

          FacetFactory facetFactory = switchyardForgeRegistrar.getFacetFactory();
          switchYardFacet = facetFactory.install(project, SwitchYardFacet.class);
          SwitchYardFacet syf = project.getFacet(SwitchYardFacet.class);
        }
      }

    } catch (Throwable e) {
      e.printStackTrace();
    } finally {
      switchyardForgeRegistrar.stop();
      LOG.info("Furnace stopped.");
    }
  }
  @Test
  public void testCreateEnum() throws Exception {
    Project project = projectFactory.createTempProject();
    facetFactory.install(project, JavaSourceFacet.class);
    JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
    JavaEnumSource javaEnum =
        Roaster.parse(
            JavaEnumSource.class, "package org.jboss.forge.test; public enum CreditCardType{}");
    facet.saveJavaSource(javaEnum);

    JavaResource javaResource = facet.getJavaResource("org.jboss.forge.test.CreditCardType");
    Assert.assertNotNull(javaResource);
    Assert.assertThat(javaResource.getJavaType(), is(instanceOf(JavaEnum.class)));

    CommandController controller =
        testHarness.createCommandController(JavaAddEnumConstantCommand.class, javaResource);
    controller.initialize();
    controller.setValueFor("named", "VISA");
    Assert.assertTrue(controller.isValid());
    Assert.assertTrue(controller.canExecute());
    Result result = controller.execute();
    Assert.assertThat(result, is(not(instanceOf(Failed.class))));

    javaResource = facet.getJavaResource("org.jboss.forge.test.CreditCardType");
    JavaEnumSource enumClass = javaResource.getJavaType();
    List<EnumConstantSource> enumConstants = enumClass.getEnumConstants();
    Assert.assertEquals(1, enumConstants.size());

    Assert.assertEquals("VISA", enumConstants.get(0).getName());
  }
Beispiel #3
0
 @Override
 public Result execute(final UIExecutionContext context) throws Exception {
   applyUIValues(context.getUIContext());
   Project project = getSelectedProject(context);
   JPAFacet<?> facet = jpaVersion.getValue();
   if (facetFactory.install(project, facet)) {
     return Results.success();
   }
   return Results.fail("Could not install JPA.");
 }
Beispiel #4
0
 @Override
 public Result execute(final UIExecutionContext context) throws Exception {
   JavaEESpecFacet chosen = javaEEVersion.getValue();
   if (facetFactory.install(getSelectedProject(context.getUIContext()), chosen)) {
     // This facet may activate other facets, so better invalidate the cache
     projectFactory.invalidateCaches();
     return Results.success("JavaEE " + chosen.getSpecVersion() + " has been installed.");
   }
   return Results.fail("Could not install JavaEE " + chosen.getSpecVersion());
 }
  @Override
  public Result execute(UIExecutionContext context) throws Exception {
    UIContext uiContext = context.getUIContext();
    Project project = getSelectedProject(uiContext);

    facetFactory.install(project, FurnaceVersionFacet.class);
    project.getFacet(FurnaceVersionFacet.class).setVersion(furnace.getVersion().toString());

    facetFactory.install(project, AddonTestFacet.class);
    for (AddonId addonId : addonDependencies.getValue()) {
      DependencyBuilder dependency =
          DependencyBuilder.create(addonId.getName())
              .setVersion(addonId.getVersion().toString())
              .setScopeType("test");
      if (!dependencyInstaller.isInstalled(project, dependency)) {
        dependencyInstaller.install(project, dependency);
      }
    }
    return Results.success(
        "Project "
            + project.getFacet(MetadataFacet.class).getProjectName()
            + " is now configured for testing");
  }
Beispiel #6
0
 /** Installs the {@link FacesFacet_2_2} facet */
 public FacesFacet_2_2 installFaces_2_2(Project project) {
   return facetFactory.install(project, FacesFacet_2_2.class);
 }
Beispiel #7
0
 /** Installs the {@link ServletFacet_3_1} facet */
 public ServletFacet_3_1 installServlet_3_1(Project project) {
   return facetFactory.install(project, ServletFacet_3_1.class);
 }
Beispiel #8
0
 /** Installs the {@link ServletFacet_2_5} facet */
 public ServletFacet_2_5 installServlet_2_5(Project project) {
   return facetFactory.install(project, ServletFacet_2_5.class);
 }
Beispiel #9
0
 /** Installs the {@link EJBFacet_3_2} facet */
 public EJBFacet_3_2 installEJB_3_2(Project project) {
   return facetFactory.install(project, EJBFacet_3_2.class);
 }
Beispiel #10
0
 /** Installs the {@link RestFacet_2_0} facet */
 public RestFacet_2_0 installJAXRS_2_0(Project project, RestConfigurationStrategy strategy) {
   RestFacet_2_0 facet = facetFactory.install(project, RestFacet_2_0.class);
   facet.setConfigurationStrategy(strategy);
   return facet;
 }
Beispiel #11
0
 /** Installs the {@link ValidationFacet} facet */
 public ValidationFacet installValidation(Project project) {
   return facetFactory.install(project, ValidationFacet.class);
 }
Beispiel #12
0
 /** Installs the {@link JAXWSFacet} facet */
 public JAXWSFacet installJAXWSFacet(Project project) {
   return facetFactory.install(project, JAXWSFacet.class);
 }
Beispiel #13
0
 /** Installs the {@link WebSocketFacet_1_1} facet */
 public WebSocketFacet_1_1 installWebSocket_1_1(Project project) {
   return facetFactory.install(project, WebSocketFacet_1_1.class);
 }
Beispiel #14
0
 /** Installs the {@link CDIFacet_1_1} facet */
 public CDIFacet_1_1 installCDI_1_1(Project project) {
   return facetFactory.install(project, CDIFacet_1_1.class);
 }
Beispiel #15
0
 /** Installs the {@link JPAFacet} facet */
 public JPAFacet_2_0 installJPA_2_0(Project project) {
   return facetFactory.install(project, JPAFacet_2_0.class);
 }