@Test public void readFileTest() throws IOException { TransformationOperation transformationOperation = getNewTestTransformationOperation().relative("pom.xml"); File readFile = transformationOperation.getOrCreateReadFile(transformedAppFolder, transformationContext); FileUtils.contentEquals(new File(transformedAppFolder, "pom.xml"), readFile); }
protected final File getOrCreateReadFile(File transformedAppFolder, TransformationContext transformationContext) throws IOException { if (readFile == null) { File originalFile = getAbsoluteFile(transformedAppFolder, transformationContext); if (!originalFile.exists()) { throw new IOException("Specified file does not exist: " + originalFile.getAbsolutePath()); } if (originalFile.isDirectory()) { throw new IOException("Specified file is a directory: " + originalFile.getAbsolutePath()); } readFile = File.createTempFile(READ_FILE_PREFIX, null); FileUtils.copyFile(originalFile, readFile); readFile.setReadOnly(); } return readFile; }
TransformationOperation extends TransformationUtility<T> { protected final File getOrCreateReadFile(File transformedAppFolder, TransformationContext transformationContext) throws IOException { if (readFile == null) { File originalFile = getAbsoluteFile(transformedAppFolder, transformationContext); if (!originalFile.exists()) { throw new IOException("Specified file does not exist: " + originalFile.getAbsolutePath()); } if (originalFile.isDirectory()) { throw new IOException("Specified file is a directory: " + originalFile.getAbsolutePath()); } readFile = File.createTempFile(READ_FILE_PREFIX, null); FileUtils.copyFile(originalFile, readFile); readFile.setReadOnly(); } return readFile; } }
TransformationOperation extends TransformationUtility<T> { protected final File getOrCreateReadFile(File transformedAppFolder, TransformationContext transformationContext) throws IOException { if (readFile == null) { File originalFile = getAbsoluteFile(transformedAppFolder, transformationContext); if (!originalFile.exists()) { throw new IOException("Specified file does not exist: " + originalFile.getAbsolutePath()); } if (originalFile.isDirectory()) { throw new IOException("Specified file is a directory: " + originalFile.getAbsolutePath()); } readFile = File.createTempFile(READ_FILE_PREFIX, null); FileUtils.copyFile(originalFile, readFile); readFile.setReadOnly(); } return readFile; } TransformationOperation(); }
TransformationOperation extends TransformationUtility<T> { protected final File getOrCreateReadFile(File transformedAppFolder, TransformationContext transformationContext) throws IOException { if (readFile == null) { File originalFile = getAbsoluteFile(transformedAppFolder, transformationContext); if (!originalFile.exists()) { throw new IOException("Specified file does not exist: " + originalFile.getAbsolutePath()); } if (originalFile.isDirectory()) { throw new IOException("Specified file is a directory: " + originalFile.getAbsolutePath()); } readFile = File.createTempFile(READ_FILE_PREFIX, null); FileUtils.copyFile(originalFile, readFile); readFile.setReadOnly(); } return readFile; } TransformationOperation(); @Override final PerformResult perform(File transformedAppFolder, TransformationContext transformationContext); }
TransformationOperation extends TransformationUtility<T> { protected final File getOrCreateReadFile(File transformedAppFolder, TransformationContext transformationContext) throws IOException { if (readFile == null) { File originalFile = getAbsoluteFile(transformedAppFolder, transformationContext); if (!originalFile.exists()) { throw new IOException("Specified file does not exist: " + originalFile.getAbsolutePath()); } if (originalFile.isDirectory()) { throw new IOException("Specified file is a directory: " + originalFile.getAbsolutePath()); } readFile = File.createTempFile(READ_FILE_PREFIX, null); FileUtils.copyFile(originalFile, readFile); readFile.setReadOnly(); } return readFile; } TransformationOperation(); @Override final PerformResult perform(File transformedAppFolder, TransformationContext transformationContext);  }