Codota Logo
LocalContainer.stop
Code IndexAdd Codota to your IDE (free)

How to use
stop
method
in
org.codehaus.cargo.container.LocalContainer

Best Java code snippets using org.codehaus.cargo.container.LocalContainer.stop (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: codehaus-cargo/cargo

  @Override
  public void run()
  {
    try 
    {
      if (ContainerRunMojo.this.localContainer != null
        && (org.codehaus.cargo.container.State.STARTED
          == ContainerRunMojo.this.localContainer.getState()
        ||
          org.codehaus.cargo.container.State.STARTING
          == ContainerRunMojo.this.localContainer.getState()))
      {
        ContainerRunMojo.this.localContainer.stop();
      }
    }
    catch (Exception e)
    {
      ContainerRunMojo.this.getLog().warn("Failed stopping the container", e);
    }
  }
});
origin: codehaus-cargo/cargo

  /**
   * {@inheritDoc}
   */
  @Override
  public void doExecute() throws MojoExecutionException
  {
    Container container = createContainer();

    if (!container.getType().isLocal())
    {
      throw new MojoExecutionException("Only local containers can be stopped");
    }

    try
    {
      ((LocalContainer) container).stop();
      waitDeployableMonitor(container, false);
    }
    catch (Exception ex)
    {
      throw new MojoExecutionException(
          "Cannot start container [" + container + "]", ex);
    }
  }
}
origin: codehaus-cargo/cargo

  @Override
  public void run()
  {
    try
    {
      if (org.codehaus.cargo.container.State.STARTED
        == localContainer.getState()
        ||
        org.codehaus.cargo.container.State.STARTING
        == localContainer.getState())
      {
        localContainer.stop();
      }
    }
    catch (Exception e)
    {
      throw new CargoException("Failed stopping the container.", e);
    }
  }
});
origin: org.codehaus.cargo/cargo-ant

  @Override
  public void run()
  {
    try 
    {
      if (org.codehaus.cargo.container.State.STARTED
        == localContainer.getState()
        ||
        org.codehaus.cargo.container.State.STARTING
        == localContainer.getState())
      {
        localContainer.stop();
        waitDeployableMonitor(false);
      }
    }
    catch (Exception e)
    {
      CargoTask.this.log(
        "Failed stopping the container", e, Project.MSG_WARN);
    }
  }
});
origin: codehaus-cargo/cargo

  /**
   * Start, test and stop WAR.
   * @param warPingURL WAR ping URL.
   */
  protected void startAndStop(URL warPingURL)
  {
    getLocalContainer().start();
    PingUtils.assertPingTrue(warPingURL.getPath() + " not started", warPingURL, getLogger());

    getLocalContainer().stop();
    PingUtils.assertPingFalse(warPingURL.getPath() + " not stopped", warPingURL, getLogger());
  }
}
origin: codehaus-cargo/cargo

  /**
   * Start container with port offset.
   * @throws Exception If anything goes wrong.
   */
  public void testStartWithPortOffset() throws Exception
  {
    int offsetValue = Integer.valueOf(OFFSET);
    int portWithOffset = getTestData().port + offsetValue;

    Deployable war = new DefaultDeployableFactory().createDeployable(getContainer().getId(),
        getTestData().getTestDataFileFor("simple-war"), DeployableType.WAR);

    getLocalContainer().getConfiguration().addDeployable(war);

    URL warPingURL = new URL("http://localhost:" + portWithOffset + "/simple-war/index.jsp");

    getLocalContainer().start();
    PingUtils.assertPingTrue(warPingURL.getPath() + " not started", warPingURL, getLogger());

    getLocalContainer().stop();
    PingUtils.assertPingFalse(warPingURL.getPath() + " not stopped", warPingURL, getLogger());
  }
}
origin: codehaus-cargo/cargo

  /**
   * Test expanded WAR with a <code>context.xml</code> file.
   * @throws Exception If anything goes wrong.
   */
  public void testExpandedWarWithContextXmlFile() throws Exception
  {
    // Copy the war from the Maven local repository in order to expand it
    File artifactDir = new File(getTestData().targetDir).getParentFile();
    Expand expandTask = (Expand) new AntUtils().createProject().createTask("unwar");
    expandTask.setDest(new File(artifactDir, "tomcat-context"));
    expandTask.setSrc(new File(getTestData().getTestDataFileFor("tomcatcontext-war")));
    expandTask.execute();

    Deployable war = new DefaultDeployableFactory().createDeployable(getContainer().getId(),
      new File(artifactDir, "tomcat-context").getPath(), DeployableType.WAR);

    getLocalContainer().getConfiguration().addDeployable(war);

    URL warPingURL = new URL("http://localhost:" + getTestData().port + "/tomcat-context/");

    getLocalContainer().start();
    PingUtils.assertPingTrue("tomcat context war not started", "Test value is [test value]",
      warPingURL, getLogger());

    getLocalContainer().stop();
    PingUtils.assertPingFalse("tomcat context war not stopped", warPingURL, getLogger());
  }
}
origin: codehaus-cargo/cargo

/**
 * Test WAR with a <code>context.xml</code> file.
 * @throws Exception If anything goes wrong.
 */
public void testWarWithContextXmlFile() throws Exception
{
  // Copies the tomcat context war in order to rename it so that it matches the context
  // path defined in its context.xml file.
  File artifactDir = new File(getTestData().targetDir).getParentFile();
  Copy copyTask = (Copy) new AntUtils().createProject().createTask("copy");
  copyTask.setTofile(new File(artifactDir, "tomcat-context.war"));
  copyTask.setFile(new File(getTestData().getTestDataFileFor("tomcatcontext-war")));
  copyTask.execute();
  Deployable war = new DefaultDeployableFactory().createDeployable(getContainer().getId(),
    new File(artifactDir, "tomcat-context.war").getPath(), DeployableType.WAR);
  getLocalContainer().getConfiguration().addDeployable(war);
  URL warPingURL = new URL("http://localhost:" + getTestData().port + "/tomcat-context/");
  getLocalContainer().start();
  PingUtils.assertPingTrue("tomcat context war not started", "Test value is [test value]",
    warPingURL, getLogger());
  getLocalContainer().stop();
  PingUtils.assertPingFalse("tomcat context war not stopped", warPingURL, getLogger());
}
origin: codehaus-cargo/cargo

  /**
   * Start spawned container.
   * @throws Exception If anything goes wrong.
   */
  public void testStartSpawned() throws Exception
  {
    Deployable war = new DefaultDeployableFactory().createDeployable(getContainer().getId(),
        getTestData().getTestDataFileFor("simple-war"), DeployableType.WAR);

    getLocalContainer().getConfiguration().addDeployable(war);

    URL pingURL = new URL("http://localhost:" + getTestData().port + "/simple-war/index.jsp");

    getLocalContainer().start();
    PingUtils.assertPingTrue(pingURL.getPath() + " not started", pingURL, getLogger());

    getLocalContainer().stop();
    PingUtils.assertPingFalse(pingURL.getPath() + " not stopped", pingURL, getLogger());
  }
}
origin: codehaus-cargo/cargo

/**
 * {@inheritDoc}
 */
@Override
public void startAndStop(URL warPingURL)
{
  String testFileName = "cargo-test/test.file";
  File testFile = new File(getLocalContainer().getConfiguration().getHome(), testFileName);
  assertFalse("File " + testFile + " already exists", testFile.exists());
  FileConfig fileConfig = new FileConfig();
  fileConfig.setFile(getTestData().getTestDataFileFor("simple-war"));
  fileConfig.setToFile(testFileName);
  getLocalContainer().getConfiguration().setConfigFileProperty(fileConfig);
  getLocalContainer().start();
  PingUtils.assertPingTrue(warPingURL.getPath() + " not started", warPingURL, getLogger());
  // CARGO-1195: DeployableFiles should be setup for ExistingLocalConfiguration
  assertTrue("File " + testFile + " was not configured", testFile.exists());
  getLocalContainer().stop();
  PingUtils.assertPingFalse(warPingURL.getPath() + " not stopped", warPingURL, getLogger());
}
origin: codehaus-cargo/cargo

/**
 * Test deployment of a WAR with root path.
 * @throws Exception If anything goes wrong.
 */
public void testDeployWarDefinedWithRootPath() throws Exception
{
  WAR war = (WAR) new DefaultDeployableFactory().createDeployable(getContainer().getId(),
    getTestData().getTestDataFileFor("simple-war"), DeployableType.WAR);
  war.setContext("/");
  getLocalContainer().getConfiguration().addDeployable(war);
  URL warPingURL = new URL("http://localhost:" + getTestData().port + "/index.jsp");
  getLocalContainer().start();
  PingUtils.assertPingTrue(warPingURL.getPath() + " not started", "Sample page for testing",
    warPingURL, getLogger());
  getLocalContainer().stop();
  PingUtils.assertPingFalse(warPingURL.getPath() + " not stopped", warPingURL, getLogger());
}
origin: codehaus-cargo/cargo

/**
 * Test deployment of a WAR with multi path.
 * @throws Exception If anything goes wrong.
 */
public void testDeployWarDefinedWithMultipleContextPath() throws Exception
{
  WAR war = (WAR) new DefaultDeployableFactory().createDeployable(getContainer().getId(),
    getTestData().getTestDataFileFor("simple-war"), DeployableType.WAR);
  war.setContext("/a/b");
  getLocalContainer().getConfiguration().addDeployable(war);
  URL warPingURL = new URL("http://localhost:" + getTestData().port + "/a/b/index.jsp");
  getLocalContainer().start();
  PingUtils.assertPingTrue(warPingURL.getPath() + " not started", "Sample page for testing",
    warPingURL, getLogger());
  getLocalContainer().stop();
  PingUtils.assertPingFalse(warPingURL.getPath() + " not stopped", warPingURL, getLogger());
}
origin: codehaus-cargo/cargo

  /**
   * Tests loading with a {@link javax.sql.DataSource} class. The
   * {@link javax.sql.XADataSource} is not tested because that configuration cannot
   * be tested in {@link ConfigurationType#STANDALONE}
   * 
   * @throws Exception If anything goes wrong.
   */
  public void testDataSourceClass() throws Exception
  {
    Configuration configuration = createConfiguration(ConfigurationType.STANDALONE);
    configuration.setProperty("cargo.datasource.datasource.derby", 
      "cargo.datasource.type=javax.sql.DataSource|"
      + "cargo.datasource.driver=org.apache.derby.jdbc.EmbeddedDataSource|"
      + "cargo.datasource.jndi=jdbc/cargoembedded|"
      + "cargo.datasource.url=jdbc:derby:memory:myDB;create=true|"
      + "cargo.datasource.username=sa|"
      + "cargo.datasource.password=sa");
    setContainer(createContainer(configuration));
    getLocalContainer().start();
    getLocalContainer().stop();
  }
}
origin: codehaus-cargo/cargo

  /**
   * Test HAR deployment.
   * @throws Exception If anything goes wrong.
   */
  public void testDeployHarStatically() throws Exception
  {
    Deployable har =
      new DefaultDeployableFactory().createDeployable(getContainer().getId(), getTestData()
        .getTestDataFileFor("simple-har"), DeployableType.HAR);

    getLocalContainer().getConfiguration().addDeployable(har);

    getLocalContainer().start();
    assertEquals(State.STARTED, getContainer().getState());

    // We're verifying that the HAR is successfully deployed by querying it via jmx
    MBeanServerConnection server = createMBeanServerConnection();
    ObjectName objectName = ObjectName.getInstance(SIMPLE_HAR_OBJECT_NAME);
    // getMBeanInfo will throw exception if not found
    MBeanInfo mbeanInfo = server.getMBeanInfo(objectName);
    getLogger().debug("The HAR MBean found: " + mbeanInfo.getDescription(),
      this.getClass().getName());
    assertNotNull("MBean description is null", mbeanInfo.getDescription());

    getLocalContainer().stop();
  }
}
origin: codehaus-cargo/cargo

  /**
   * Start container with an EAR containing one WAR.
   * @throws Exception If anything goes wrong.
   */
  public void testStartWithOneEarWithOneWarDeployed() throws Exception
  {
    Deployable ear = new DefaultDeployableFactory().createDeployable(getContainer().getId(),
      getTestData().getTestDataFileFor("simple-ear"), DeployableType.EAR);

    getLocalContainer().getConfiguration().addDeployable(ear);

    URL earPingURL =
      new URL("http://localhost:" + getTestData().port + "/simpleweb/index.jsp");

    getLocalContainer().start();
    PingUtils.assertPingTrue("simple ear not started", earPingURL, getLogger());

    getLocalContainer().stop();
    PingUtils.assertPingFalse("simple ear not stopped", earPingURL, getLogger());
  }
}
origin: codehaus-cargo/cargo

/**
 * Tests that a servlet has access to a class in added to the extraclasspath
 * @throws MalformedURLException If the WAR URL cannot be built.
 */
public void testLoadClass() throws MalformedURLException
{
  Deployable war =
    new DefaultDeployableFactory().createDeployable(getContainer().getId(), getTestData()
      .getTestDataFileFor("classpath-war"), DeployableType.WAR);
  getLocalContainer().getConfiguration().addDeployable(war);
  URL warPingURL =
    new URL("http://localhost:" + getTestData().port + "/" + "classpath-war/test");
  getLocalContainer().start();
  PingUtils.assertPingTrue("simple war should have been started at this point", warPingURL,
    getLogger());
  getLocalContainer().stop();
  PingUtils.assertPingFalse("simple war should have been stopped at this point", warPingURL,
      getLogger());
}
origin: codehaus-cargo/cargo

/**
 * Smoke test: startup with no deployable.
 * @throws Exception If anything goes wrong.
 */
public void testStartWithNoDeployable() throws Exception
{
  setContainer(createContainer(createConfiguration(ConfigurationType.STANDALONE)));
  getLocalContainer().start();
  assertEquals(State.STARTED, getContainer().getState());
  try
  {
    getLocalContainer().start();
    fail("the second start attempt did not fail");
  }
  catch (ContainerException expected)
  {
    assertTrue(expected.getMessage() + " does not contain the word 'restart'",
      expected.getMessage().contains("restart"));
  }
  getLocalContainer().stop();
  assertEquals(State.STOPPED, getContainer().getState());
}
origin: codehaus-cargo/cargo

/**
 * Start container with an empty EAR.
 * @throws Exception If anything goes wrong.
 */
public void testStartWithOneEmptyEarDeployed() throws Exception
{
  // The Apache Geronimo server doesn't like empty EARs
  if (getContainer().getId().startsWith("geronimo"))
  {
    return;
  }
  Deployable ear = new DefaultDeployableFactory().createDeployable(getContainer().getId(),
    getTestData().getTestDataFileFor("empty-ear"), DeployableType.EAR);
  getLocalContainer().getConfiguration().addDeployable(ear);
  getLocalContainer().start();
  assertEquals(State.STARTED, getContainer().getState());
  getLocalContainer().stop();
  assertEquals(State.STOPPED, getContainer().getState());
}
origin: codehaus-cargo/cargo

  /**
   * Test static EJB deployment.
   * @throws Exception If anything goes wrong.
   */
  public void testDeployEjbStatically() throws Exception
  {
    setContainer(createContainer(createConfiguration(ConfigurationType.STANDALONE)));

    Deployable ejb = new DefaultDeployableFactory().createDeployable(getContainer().getId(),
      getTestData().getTestDataFileFor("simple-ejb"), DeployableType.EJB);

    getLocalContainer().getConfiguration().addDeployable(ejb);

    getLocalContainer().start();

    SampleHome home = jndiLookup("SampleEJB");
    Sample sample = home.create();
    assertTrue("Should have returned true", sample.isWorking());

    getLocalContainer().stop();
  }
}
origin: codehaus-cargo/cargo

  /**
   * Test WAR hot deployment.
   * @throws Exception If anything goes wrong.
   */
  public void testWarHotDeployment() throws Exception
  {
    setContainer(createContainer(createConfiguration(ConfigurationType.STANDALONE)));

    WAR war = (WAR) new DefaultDeployableFactory().createDeployable(getContainer().getId(),
      getTestData().getTestDataFileFor("simple-war"), DeployableType.WAR);
    war.setContext("simple");

    URL warPingURL = new URL("http://localhost:" + getTestData().port + "/" + war.getContext()
      + "/index.jsp");

    getLocalContainer().start();
    PingUtils.assertPingFalse("simple war should not be started at this point", warPingURL,
      getLogger());

    Deployer deployer = createDeployer(getContainer());
    DeployableMonitor deployableMonitor = new URLDeployableMonitor(warPingURL);
    deployableMonitor.setLogger(this.getLogger());
    deployer.deploy(war, deployableMonitor);

    PingUtils.assertPingTrue("simple war should have been started at this point", warPingURL,
      getLogger());

    getLocalContainer().stop();
  }
}
org.codehaus.cargo.containerLocalContainerstop

Popular methods of LocalContainer

  • getConfiguration
  • getId
  • getState
  • getName
  • restart
  • setTimeout
  • start
  • getCapability
  • getFileHandler
  • isAppend
  • setOutput
  • getLogger
  • setOutput,
  • getLogger,
  • getOutput,
  • getTimeout,
  • getType,
  • setAppend,
  • setConfiguration

Popular in Java

  • Reading from database using SQL prepared statement
  • putExtra (Intent)
  • getSystemService (Context)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now