/** * Sets a configuration file property for the container's configuration * * This function is currently only used to specify a different context.xml file from the one * located in the installations 'conf' folder. * * @param filePath The path to the new configuration file * @param configDirDest The name of the directory that the configuration file be placed in * @param configFileDestName The name of destination file for the new configuration file */ private void setConfigFile(String filePath, String configDirDest, String configFileDestName) { FileConfig configFile = new FileConfig(); configFile.setFile(filePath); configFile.setToDir(configDirDest); configFile.setToFile(configFileDestName); getConfiguration().setConfigFileProperty(configFile); } }
FileConfig fc = new FileConfig(); fc.setFile(path); fc.setToDir(toDir);
FileConfig fc = new FileConfig(); fc.setFile(path); fc.setToDir(toDir);
/** * Test simple file copy. * @throws Exception If anything goes wrong. */ public void testSimpleCopyFile() throws Exception { // simplest test for file copy String fileName = "simpleCopy1"; String fileContents = "@foo@"; File file1 = createFile(configFileDirectory, fileName, fileContents); FileConfig configFile = new FileConfig(); configFile.setFile(getAbsolutePath(file1)); testCopy(configFile, fileName, "@foo@"); }
/** * Test file copy with overwrite. * @throws Exception If anything goes wrong. */ public void testOverwite() throws Exception { File configHome = new File(configuration.getHome()); assertTrue("Could not find a proper configuration home.", configHome.exists() && configHome.isDirectory()); File existingFile = createFile(configHome, "existingfile", "helloworld"); // make sure the file exists and contains the proper information. assertEquals("helloworld", readFile(existingFile)); String fileName = "simpleCopyWithOverwrite"; String fileContents = "goodbye"; File file1 = createFile(configFileDirectory, fileName, fileContents); FileConfig configFile = new FileConfig(); configFile.setFile(getAbsolutePath(file1)); configFile.setToFile("existingfile"); configFile.setOverwrite("true"); testCopy(configFile, "existingfile", "goodbye"); assertEquals("goodbye", readFile(existingFile)); }
/** * {@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()); }
FileConfig configFile = new FileConfig(); configFile.setFile(getAbsolutePath(configFileDirectory));
/** * Test file copy with replacement tokens. * @throws Exception If anything goes wrong. */ public void testCopyWithTokens() throws Exception { // test that token replacement for "@foo@" results in "bar" String fileName = "simpleCopyWT1"; String fileContents = "@token1@ "; File file1 = createFile(configFileDirectory, fileName, fileContents); FileConfig configFile = new FileConfig(); configFile.setFile(getAbsolutePath(file1)); // set the property so that "@foo@" is replaced with "bar" configuration.setProperty("token1", "value1"); // not set as a configuration file yet so token replacement shouldn't happen testCopy(configFile, fileName, "@token1@ "); configFile.setConfigfile("true"); testCopy(configFile, fileName, "value1 "); }
/** * Test configuration file property. * @throws Exception If anything goes wrong. */ public void testConfigFileProperty() throws Exception { File configHome = new File(configuration.getHome()); assertTrue("Could not find a proper configuration home.", configHome.exists() && configHome.isDirectory()); File existingFile = createFile(configHome, "existingfile", "helloworld"); // make sure the file exists and contains the proper information. assertEquals("helloworld", readFile(existingFile)); String fileName = "testConfigfile"; String fileContents = "Hello @message@ "; File file = createFile(configFileDirectory, fileName, fileContents); FileConfig configFile = new FileConfig(); configFile.setFile(getAbsolutePath(file)); configFile.setToFile("existingfile"); // if using the setConfigFilePropery then its should always be set // to overwrite and that its a configfile regardless of the what the // FileConfig is set as. configFile.setOverwrite(false); configFile.setConfigfile(false); configuration.setProperty("message", "world"); configuration.setConfigFileProperty(configFile); configuration.doConfigure(null); File copiedFile = new File(configuration.getHome() + "/existingfile"); assertTrue("Cannot find the expected copied file", copiedFile.exists()); assertEquals("Hello world ", readFile(copiedFile)); }
/** * Test file copy with overwrite and replacement tokens. * @throws Exception If anything goes wrong. */ public void testOverwriteWithTokens() throws Exception { File configHome = new File(configuration.getHome()); assertTrue("Could not find a proper configuration home.", configHome.exists() && configHome.isDirectory()); File existingFile = createFile(configHome, "existingfile2", "helloworld"); // make sure the file exists and contains the proper information. assertEquals("helloworld", readFile(existingFile)); String fileName = "simpleCopyWithOverwrite"; String fileContents = "goodbye@token1@."; File file1 = createFile(configFileDirectory, fileName, fileContents); FileConfig configFile = new FileConfig(); configFile.setFile(getAbsolutePath(file1)); configFile.setToFile("existingfile2"); configFile.setOverwrite("true"); configFile.setConfigfile("true"); configuration.setProperty("token1", " everyone"); testCopy(configFile, "existingfile2", "goodbye everyone."); assertEquals("goodbye everyone.", readFile(existingFile)); }
FileConfig fc = new FileConfig(); fc.setFile(path); fc.setToDir("common/lib"); FileConfig fc = new FileConfig(); fc.setFile(path); fc.setToDir("shared/lib");
FileConfig fc = new FileConfig(); fc.setFile(path); fc.setToDir("common/lib"); FileConfig fc = new FileConfig(); fc.setFile(path); fc.setToDir("shared/lib");
File file1 = createFile(configFileDirectory, fileName, fileContents); FileConfig configFile = new FileConfig(); configFile.setFile(getAbsolutePath(file1));