// So, first deploy the typical demo.war we have been using before.
copyDeployables();
autoDeployment.fireDeploymentEvent();
verifyDemoAppCreated(TEST_PORTLET_APP_NAME, demoApp);
DirectoryHelper demoAppDeployedDir = new DirectoryHelper(demoAppDeployed);
long beforeSize = new File(demoAppDeployedDir.getRootDirectory(), "WEB-INF/portlet.xml").length();
// Trigger re-deployment using a demo.war that has a slightly larger portlet.xml
// then the one we just deployed. We will use size comparisons as or litmus test.
File redeployDemoWar = new File("./test/deployment/redeploy/demo.war");
FileChannel srcDemoWarChannel = new FileInputStream(redeployDemoWar).getChannel();
FileChannel dstDemoWarChannel = new FileOutputStream(demoWar).getChannel();
dstDemoWarChannel.transferFrom(srcDemoWarChannel, 0, srcDemoWarChannel.size());
srcDemoWarChannel.close();
dstDemoWarChannel.close();
// Make sure the demo.war that will trigger redeploy has a larger portlet.xml then the current one
JarHelper rdDemoWar = new JarHelper(demoWar, true);
assertTrue(new File(rdDemoWar.getRootDirectory(), "WEB-INF/portlet.xml").length() > beforeSize);
// Need to slow it down so the timestamp check works
Thread.sleep(500);
demoWar.setLastModified(System.currentTimeMillis());
autoDeployment.fireRedeploymentEvent();
long afterSize = new File(demoAppDeployedDir.getRootDirectory(), "WEB-INF/portlet.xml").length();
// The portlet.xml in re-deploy has an additional portlet entry in portlet.xml, so it should be bigger
assertTrue(afterSize > beforeSize);
autoDeployment.stop();
}