本文整理了Java中org.codehaus.cargo.container.deployable.WAR.setContext()
方法的一些代码示例,展示了WAR.setContext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WAR.setContext()
方法的具体详情如下:
包路径:org.codehaus.cargo.container.deployable.WAR
类名称:WAR
方法名:setContext
暂无
代码示例来源:origin: apache/geode
/**
* Deploys the {@link #warFile} to the cargo container ({@link #container}).
*/
public void deployWar() {
// Get the cargo war from the war file
WAR war = new WAR(warFile.getAbsolutePath());
// Set context access to nothing
war.setContext("");
// Deploy the war the container's configuration
getConfiguration().addDeployable(war);
logger.info("Deployed WAR file at {}", war.getFile());
}
代码示例来源:origin: stackoverflow.com
// (1) Optional step to install the container from a URL pointing to its distribution
Installer installer = new ZipURLInstaller(new URL("http://www.apache.org/dist/tomcat/tomcat-6/v6.0.20/bin/apache-tomcat-6.0.20.zip"));
installer.install();
// (2) Create the Cargo Container instance wrapping our physical container
LocalConfiguration configuration = (LocalConfiguration) new DefaultConfigurationFactory()
.createConfiguration("tomcat6x"), ContainerType.INSTALLED, ConfigurationType.STANDALONE);
container = (InstalledLocalContainer) new DefaultContainerFactory()
.createContainer("tomcat6x", ContainerType.INSTALLED, configuration);
container.setHome(installer.getHome());
// (3) Statically deploy some WAR (optional)
WAR deployable = new WAR("./webapp-testing-webapp/target/webapp-testing-webapp-1.0.war");
deployable.setContext("ROOT");
configuration.addDeployable(deployable);
// (4) Start the container
container.start();
代码示例来源:origin: codehaus-cargo/cargo
/**
* Extract the context name from the WAR file name (without the file extension). For example if
* the WAR is named <code>test.war</code> then the context name is <code>test</code>.
*/
private void parseContext()
{
if (this.context == null)
{
String ctx = getFileHandler().getName(getFile());
int warIndex = ctx.toLowerCase().lastIndexOf(".war");
if (warIndex >= 0)
{
ctx = ctx.substring(0, warIndex);
}
getLogger().debug("Parsed web context = [" + ctx + "]", this.getClass().getName());
setContext(ctx);
}
}
代码示例来源:origin: org.jenkins-ci.plugins/deploy
protected void deploy(DeployerFactory deployerFactory, final BuildListener listener, Container container, File f, String contextPath) {
Deployer deployer = deployerFactory.createDeployer(container);
listener.getLogger().println("Deploying " + f + " to container " + container.getName());
deployer.setLogger(new LoggerImpl(listener.getLogger()));
String extension = FilenameUtils.getExtension(f.getAbsolutePath());
if ("WAR".equalsIgnoreCase(extension)) {
WAR war = createWAR(f);
if (!StringUtils.isEmpty(contextPath)) {
war.setContext(contextPath);
}
deployer.redeploy(war);
} else if ("EAR".equalsIgnoreCase(extension)) {
EAR ear = createEAR(f);
deployer.redeploy(ear);
} else {
throw new RuntimeException("Extension File Error.");
}
}
代码示例来源:origin: codehaus-cargo/cargo
/**
* Test WAR context overriden with a leading slash.
*/
public void testGetContextWhenOverrideAndLeadingSlash()
{
WAR war = new WAR("c:/some/path/to/war/test.war");
war.setContext("/");
assertEquals("", war.getContext());
}
代码示例来源:origin: codehaus-cargo/cargo
/**
* Test WAR context overriden with a slash in the middhe.
*/
public void testGetContextWhenOverrideAndMiddleSlash()
{
WAR war = new WAR("c:/some/path/to/war/test.war");
war.setContext("/a/b");
assertEquals("a/b", war.getContext());
}
代码示例来源:origin: codehaus-cargo/cargo
/**
* Test name when WAR context is overriden.
*/
public void testGetNameWhenOverride()
{
WAR war = new WAR("c:/some/path/to/war/test.war");
war.setContext("context");
assertEquals("context", war.getName());
}
}
代码示例来源:origin: codehaus-cargo/cargo
/**
* Test overriden WAR context.
*/
public void testGetContextWhenOverride()
{
WAR war = new WAR("c:/some/path/to/war/test.war");
war.setContext("context");
assertEquals("context", war.getContext());
}
代码示例来源:origin: com.atlassian.sdk/ap3-api
deployable.setContext(ctx.getContextPath());
代码示例来源:origin: stackoverflow.com
// (1) Optional step to install the container from a URL pointing to its distribution
Installer installer = new ZipURLInstaller(
new URL("http://repo1.maven.org/maven2/com/ibm/websphere/appserver/runtime/wlp-javaee7/8.5.5.9/wlp-javaee7-8.5.5.9.zip"));
installer.install();
// (2) Create the Cargo Container instance wrapping our physical container
LocalConfiguration configuration = (LocalConfiguration) new DefaultConfigurationFactory().createConfiguration(
"liberty", ContainerType.INSTALLED, ConfigurationType.STANDALONE);
InstalledLocalContainer container =
(InstalledLocalContainer) new DefaultContainerFactory().createContainer(
"liberty", ContainerType.INSTALLED, configuration);
container.setHome(installer.getHome());
// (3) Statically deploy some WAR (optional)
WAR war = new WAR("cargo.war");
// (4) Set the context root for the application
war.setContext("/myContext");
configuration.addDeployable(war);
// (5) Start the container
container.start();
代码示例来源:origin: codehaus-cargo/cargo
/**
* Verify that WAR context change works.
* @throws Exception If anything goes wrong.
*/
public void testChangeWarContextAndDeployUndeployRemotely() throws Exception
{
this.war.setContext("simple");
URL warPingURL = new URL("http://localhost:" + getTestData().port + "/"
+ this.war.getContext() + "/index.jsp");
deployer.deploy(this.war);
PingUtils.assertPingTrue("simple war not correctly deployed", warPingURL, getLogger());
deployer.undeploy(this.war);
PingUtils.assertPingFalse("simple war not correctly undeployed", warPingURL, getLogger());
}
代码示例来源:origin: codehaus-cargo/cargo
war.setContext(context);
代码示例来源: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
/**
* Test deployment of a WAR in a custom context.
* @throws Exception If anything goes wrong.
*/
public void testDeployWhenWarWithCustomContext() throws Exception
{
WAR war = new WAR("ram:///some/warfile.war");
this.fsManager.resolveFile("ram:///some/warfile.war").createFile();
war.setContext("context");
AbstractCopyingInstalledLocalDeployer deployer = new TestableCopyingDeployer(
createContainer(createContainerCapability(DeployableType.WAR), null));
assertFalse(this.fsManager.resolveFile("ram:///webapps/context.war").exists());
deployer.deploy(war);
assertTrue(this.fsManager.resolveFile("ram:///webapps/context.war").exists());
}
代码示例来源:origin: codehaus-cargo/cargo
/**
* Test deployment of an expanded WAR in a custom context.
* @throws Exception If anything goes wrong.
*/
public void testDeployWhenExpandedWarWithCustomContext() throws Exception
{
// Create an expanded WAR
WAR war = new WAR("ram:///some/expanded/warfile");
war.setContext("context");
war.setFileHandler(this.fileHandler);
this.fsManager.resolveFile(war.getFile()).createFolder();
AbstractCopyingInstalledLocalDeployer deployer = new TestableCopyingDeployer(
createContainer(createContainerCapability(DeployableType.WAR), null));
assertFalse(this.fsManager.resolveFile("ram:///webapps/context").exists());
deployer.deploy(war);
assertTrue(this.fsManager.resolveFile("ram:///webapps/context").exists());
}
代码示例来源: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();
}
}
内容来源于网络,如有侵权,请联系作者删除!