/**
  * If the project's packaging is war, ear or ejb and there is no deployer specified and the user
  * has not defined the auto-deployable inside the <code>&lt;deployables&gt;</code> element, then
  * add the generated artifact to the list of deployables to deploy statically.
  *
  * <p>Note that the reason we check that a deployer element has not been specified is because if
  * it has then the auto deployable will be deployed by the specified deployer.
  *
  * @param container the local container to which to add the project's artifact
  * @throws MojoExecutionException if an error occurs
  */
 protected void addAutoDeployDeployable(LocalContainer container) throws MojoExecutionException {
   if ((getDeployerElement() == null)
       && (getCargoProject().getPackaging() != null)
       && getCargoProject().isJ2EEPackaging()) {
     // Has the auto-deployable already been specified as part of the <deployables> config
     // element?
     if ((getConfigurationElement() == null)
         || (getConfigurationElement().getDeployables() == null)
         || !containsAutoDeployable(getConfigurationElement().getDeployables())) {
       LocalConfiguration configuration = container.getConfiguration();
       configuration.addDeployable(createAutoDeployDeployable(container));
     }
   }
 }
Esempio n. 2
0
  /** Test the creation of a container with one deployable. */
  public void testMakeContainerWithOneDeployable() {
    CargoTask task = new CargoTask();
    task.setContainerId("resin2x");
    task.setType(ContainerType.INSTALLED);

    ConfigurationElement configurationElement = task.createConfiguration();
    configurationElement.setType("standalone");
    DeployableElement warElement = new DeployableElement();
    warElement.setType(DeployableType.WAR.getType());
    warElement.setFile("some/war");
    configurationElement.addConfiguredDeployable(warElement);
    configurationElement.setHome("somewhere");

    LocalContainer container = (LocalContainer) task.makeContainer();

    assertEquals(
        Resin2xStandaloneLocalConfiguration.class.getName(),
        container.getConfiguration().getClass().getName());
    assertEquals(1, container.getConfiguration().getDeployables().size());

    Deployable deployable = container.getConfiguration().getDeployables().get(0);
    assertEquals(WAR.class.getName(), deployable.getClass().getName());
    assertEquals("some/war", deployable.getFile());
  }