private void checkForFileExistance(String warLocation, List<String> files) { for (String file : files) { File file0 = new TFile(warLocation + file); assertTrue("The file/dir " + file + " does not exist in the WAR.", file0.exists()); } }
public void testNoWar() throws Exception { String noWar = "noWar"; String ampLocation = getFileLocation(".amp", "module/test_v1.amp"); try { this.manager.installModule(ampLocation, noWar,false,false, false); } catch (ModuleManagementToolException exception) { assertTrue(exception.getMessage().endsWith("does not exist.")); } try { this.manager.installModule(ampLocation, noWar,false,false, true); //backup war } catch (ModuleManagementToolException exception) { assertTrue(exception.getMessage().endsWith("does not exist.")); } }
private void checkContentsOfFile(String location, String expectedContents) throws IOException { File file = new TFile(location); assertTrue(file.exists()); BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(new TFileInputStream(file))); String line = reader.readLine(); assertNotNull(line); assertEquals(expectedContents, line.trim()); } finally { if (reader != null) { try { reader.close(); } catch (Throwable e ) {} } } } }
public void testExistingFilesInWar() throws Exception { manager.setVerbose(true); String warLocation = getFileLocation(".war", "module/test.war"); //Version 4.0.1 String ampLocation = getFileLocation(".amp", "module/test_v4.amp"); try { this.manager.installModule(ampLocation, warLocation, false, false, true); } catch(ModuleManagementToolException exception) { assertTrue(exception.getMessage().contains("will overwrite an existing file in the war")); } this.manager.installModule(ampLocation, warLocation, false, true, true); //Now force it checkContentsOfFile(warLocation + "/jsp/relogin.jsp", "VERSIONONE"); checkContentsOfFile(warLocation + "/css/main.css", "p{margin-bottom:1em;}"); this.manager.installModule(ampLocation, warLocation, false, true, false); //install it again }
assertTrue(e.getMessage().contains("The amp will overwrite an existing file"));