Skip to content

Commit

Permalink
FORGE-567
Browse files Browse the repository at this point in the history
  • Loading branch information
lincolnthree committed May 18, 2012
1 parent 1748bb5 commit e821c0f
Show file tree
Hide file tree
Showing 13 changed files with 330 additions and 48 deletions.
Expand Up @@ -31,6 +31,7 @@
import org.jboss.forge.project.dependencies.ScopeType;
import org.jboss.forge.project.facets.BaseFacet;
import org.jboss.forge.project.facets.DependencyFacet;
import org.jboss.forge.project.packaging.PackagingType;
import org.jboss.forge.shell.plugins.RequiresFacet;

/**
Expand All @@ -43,7 +44,7 @@
public abstract class BaseJavaEEFacet extends BaseFacet
{
public static final Dependency JAVAEE6 =
DependencyBuilder.create("org.jboss.spec:jboss-javaee-6.0:2.0.0.Final:import:basic");
DependencyBuilder.create("org.jboss.spec:jboss-javaee-6.0").setScopeType(ScopeType.IMPORT).setPackagingType(PackagingType.BASIC);

private final DependencyInstaller installer;

Expand All @@ -57,14 +58,14 @@ public BaseJavaEEFacet(final DependencyInstaller installer)
public boolean install()
{
for (Dependency requirement : getRequiredDependencies()) {
if (!installer.isInstalled(project, requirement))
if (!getInstaller().isInstalled(project, requirement))
{
DependencyFacet deps = project.getFacet(DependencyFacet.class);
if (!deps.hasEffectiveManagedDependency(requirement) && !deps.hasDirectManagedDependency(JAVAEE6))
{
deps.addDirectManagedDependency(JAVAEE6);
getInstaller().installManaged(project, JAVAEE6);
}
installer.install(project, requirement, ScopeType.PROVIDED);
getInstaller().install(project, requirement, ScopeType.PROVIDED);
}
}
return true;
Expand All @@ -84,4 +85,9 @@ public boolean isInstalled()
}

abstract protected List<Dependency> getRequiredDependencies();

public DependencyInstaller getInstaller()
{
return installer;
}
}
Expand Up @@ -21,9 +21,6 @@
*/
package org.jboss.forge.spec.javaee.jsf;

import java.util.Arrays;
import java.util.List;

import javax.inject.Inject;

import org.jboss.forge.project.dependencies.Dependency;
Expand All @@ -45,6 +42,8 @@ public class FacesAPIFacetImpl extends FacesFacetImpl implements FacesAPIFacet
{
public static final Dependency JAVAEE6_FACES = DependencyBuilder
.create("org.jboss.spec.javax.faces:jboss-jsf-api_2.0_spec");
public static final Dependency JAVAEE6_FACES_21 = DependencyBuilder
.create("org.jboss.spec.javax.faces:jboss-jsf-api_2.1_spec");

@Inject
public FacesAPIFacetImpl(final DependencyInstaller installer, final ShellPrintWriter out)
Expand All @@ -56,18 +55,25 @@ public FacesAPIFacetImpl(final DependencyInstaller installer, final ShellPrintWr
public boolean isInstalled()
{
DependencyFacet deps = project.getFacet(DependencyFacet.class);
return deps.hasEffectiveDependency(JAVAEE6_FACES);
return deps.hasEffectiveDependency(JAVAEE6_FACES) || deps.hasEffectiveDependency(JAVAEE6_FACES_21);
}

@Override
public boolean install()
{
return super.install();
}
super.install();

@Override
protected List<Dependency> getRequiredDependencies()
{
return Arrays.asList(JAVAEE6_FACES);
DependencyFacet deps = project.getFacet(DependencyFacet.class);
if(deps.hasEffectiveManagedDependency(JAVAEE6_FACES) && !deps.hasEffectiveDependency(JAVAEE6_FACES))
{
getInstaller().install(project, JAVAEE6_FACES);
}
else if(deps.hasEffectiveManagedDependency(JAVAEE6_FACES_21) && !deps.hasEffectiveDependency(JAVAEE6_FACES_21))
{
getInstaller().install(project, JAVAEE6_FACES_21);
}

return isInstalled();
}

}
Expand Up @@ -23,16 +23,18 @@ public void testSetupEJB() throws Exception
Project project = initializeJavaProject();

assertFalse(project.hasFacet(EJBFacet.class));
queueInputLines("");
getShell().execute("setup ejb");
assertTrue(project.hasFacet(EJBFacet.class));
}

@Test
public void testSetupJRA() throws Exception
public void testSetupJTA() throws Exception
{
Project project = initializeJavaProject();

assertFalse(project.hasFacet(JTAFacet.class));
queueInputLines("");
getShell().execute("setup jta");
assertTrue(project.hasFacet(JTAFacet.class));
}
Expand Down
Expand Up @@ -47,7 +47,7 @@ public class BeansPluginTest extends AbstractShellTest
public void testBeansSetup() throws Exception
{
Project project = initializeJavaProject();
queueInputLines("n");
queueInputLines("n", "");
getShell().execute("beans setup");

project.getFacet(CDIFacet.class).getConfig();
Expand All @@ -60,7 +60,7 @@ public void testBeansSetup() throws Exception
public void testBeansSetupProvidedScope() throws Exception
{
Project project = initializeJavaProject();
queueInputLines("y");
queueInputLines("y", "");
getShell().execute("beans setup");

project.getFacet(CDIFacet.class).getConfig();
Expand Down
Expand Up @@ -22,6 +22,7 @@ public void testSetup() throws Exception
Project project = initializeJavaProject();
assertFalse(project.hasFacet(JMSFacet.class));

queueInputLines("");
getShell().execute("setup jms");

assertTrue(project.hasFacet(JMSFacet.class));
Expand Down
Expand Up @@ -12,8 +12,9 @@ public class FacesPluginTest extends AbstractShellTest
@Test
public void testFacesConfig() throws Exception
{
getShell().setOutputStream(System.out);
Project project = initializeJavaProject();
queueInputLines("Y", "Y", "Y");
queueInputLines("Y", "", "Y", "Y");
getShell().execute("faces setup");
Assert.assertTrue(project.getProjectRoot().getChild("src/main/webapp/WEB-INF/web.xml").exists());
}
Expand Down
Expand Up @@ -46,7 +46,7 @@ public void testInstall() throws Exception
Project project = initializeJavaProject();

assertFalse(project.hasFacet(SoapFacet.class));
queueInputLines("");
queueInputLines("", "");
getShell().execute("setup soap");
assertTrue(project.hasFacet(SoapFacet.class));
assertTrue(project.getFacet(DependencyFacet.class).hasEffectiveDependency(
Expand Down
Expand Up @@ -45,7 +45,7 @@ public class ServletPluginTest extends AbstractShellTest
public void testServletSetupDoesNotInitiallyCreateWebXML() throws Exception
{
Project project = initializeJavaProject();
queueInputLines("y");
queueInputLines("y", "");
getShell().execute("servlet setup");

Assert.assertTrue(project.hasFacet(ServletFacet.class));
Expand All @@ -58,7 +58,7 @@ public void testServletSetupDoesNotInitiallyCreateWebXML() throws Exception
public void testServletLazilyCreatesWebXMLOnSave() throws Exception
{
Project project = initializeJavaProject();
queueInputLines("y");
queueInputLines("y", "");
getShell().execute("setup servlet");

Assert.assertTrue(project.getFacet(DependencyFacet.class).hasEffectiveDependency(
Expand Down
Expand Up @@ -46,6 +46,7 @@ public class QueuedEventsTest extends AbstractShellTest
public void testPromptBoolean() throws Exception
{
Project project = initializeJavaProject();
queueInputLines("");
getShell().execute("project install-facet forge.spec.validation");

assertTrue(project.hasFacet(ValidationFacet.class));
Expand Down
Expand Up @@ -62,7 +62,7 @@ public void beforeTest() throws Exception
@Test
public void testFacetInstalledWhenSetUp() throws Exception
{
queueInputLines("");
queueInputLines("", "");
getShell().execute(PLUGIN_NAME + " setup --provider " + HIBERNATE_VALIDATOR);

assertTrue(getProject().hasFacet(ValidationFacet.class));
Expand All @@ -72,7 +72,7 @@ public void testFacetInstalledWhenSetUp() throws Exception
public void testValidatorProviderConfigIsGeneratedWhenSetUp() throws Exception
{
// Hibernate Validator
queueInputLines("");
queueInputLines("", "");
getShell().execute(PLUGIN_NAME + " setup --provider " + HIBERNATE_VALIDATOR);

assertTrue(getProject().hasFacet(ValidationFacet.class));
Expand Down Expand Up @@ -115,7 +115,7 @@ public void testUserConfigIsAddedToGeneratedValidationDescriptorWhenSetUp() thro
shellCommand.append(" --traversableResolver ").append(providedTraversableResolver);
shellCommand.append(" --constraintValidatorFactory ").append(providedConstraintValidatorFactory);

queueInputLines("");
queueInputLines("", "");
getShell().execute(shellCommand.toString());

assertTrue(getProject().hasFacet(ValidationFacet.class));
Expand All @@ -135,7 +135,7 @@ public void testUserConfigIsAddedToGeneratedValidationDescriptorWhenSetUp() thro
public void testValidationProviderDependenciesAreInstalledWhenSetUp() throws Exception
{
// Hibernate Validator
queueInputLines("");
queueInputLines("", "");
getShell().execute(PLUGIN_NAME + " setup --provider " + HIBERNATE_VALIDATOR);

assertTrue(getProject().hasFacet(ValidationFacet.class));
Expand Down

0 comments on commit e821c0f

Please sign in to comment.