Java Code Examples for org.codehaus.plexus.util.FileUtils#fileRead()
The following examples show how to use
org.codehaus.plexus.util.FileUtils#fileRead() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BuildFrontendMojoTest.java From flow with Apache License 2.0 | 6 votes |
private void assertContainsImports(boolean contains, String... imports) throws IOException { String content = FileUtils.fileRead(importsFile); if (contains) { Arrays.asList(imports) .forEach(s -> Assert.assertTrue( s + " not found in:\n" + content, content.contains(addWebpackPrefix(s)))); } else { Arrays.asList(imports) .forEach(s -> Assert.assertFalse( s + " found in:\n" + content, content.contains(addWebpackPrefix(s)))); } }
Example 2
Source File: JavaServiceWrapperDaemonGeneratorTest.java From appassembler with MIT License | 6 votes |
public void testGenerationWithChkConfig() throws Exception { runTest( "jsw", "src/test/resources/project-12/pom.xml", "src/test/resources/project-12/descriptor.xml", "target/output-12-jsw" ); File jswDir = getTestFile( "target/output-12-jsw/app" ); File wrapper = new File( jswDir, "conf/wrapper.conf" ); String wrapperContents = FileUtils.fileRead( wrapper ); assertFalse( "Wrapper conf contains chkconfig.start", wrapperContents.contains( "chkconfig.start" ) ); assertFalse( "Wrapper conf contains chkconfig.stop", wrapperContents.contains( "chkconfig.stop" ) ); File script = new File( jswDir, "bin/app" ); String scriptContents = FileUtils.fileRead( script ); assertTrue( "Chkconfig replace did not work", scriptContents.contains( "chkconfig: 3 21 81" ) ); }
Example 3
Source File: ApiBootMybatisEnhanceCodegen.java From beihu-boot with Apache License 2.0 | 5 votes |
/** * load codegen.setting.json parse to CodegenSetting entity */ private String loadCodegenSetting() { try { // formatter codegen.setting.json path String settingJsonPath = String.format("%s%s", EnhanceCodegenConstant.CLASSES_PATH.replace(EnhanceCodegenConstant.POINT, File.separator), EnhanceCodegenConstant.SETTING_JSON); // read codegen.setting.json content File file = new File(projectBaseDir + settingJsonPath); return FileUtils.fileRead(file); } catch (Exception e) { getLog().error(e); } return null; }
Example 4
Source File: ApiBootMybatisEnhanceCodegen.java From api-boot with Apache License 2.0 | 5 votes |
/** * load codegen.setting.json parse to CodegenSetting entity * read codegen.setting.json content */ private String loadCodegenSetting() { try { // formatter codegen.setting.json path String settingJsonPath = String.format("%s%s", EnhanceCodegenConstant.CLASSES_PATH.replace(EnhanceCodegenConstant.POINT, File.separator), EnhanceCodegenConstant.SETTING_JSON); File file = new File(projectBaseDir + settingJsonPath); if (file.exists()) { return FileUtils.fileRead(file); } } catch (Exception e) { getLog().error(e); } return null; }
Example 5
Source File: JaxbUtil.java From DevToolBox with GNU Lesser General Public License v2.1 | 5 votes |
/** * 加载系统设置 * * @param c * @param file * @return */ public static Object loadXMLToBean(Class c, String file) { try { String xml = FileUtils.fileRead(file); return converyToJavaBean(xml, c); } catch (Exception ex) { try { return c.newInstance(); } catch (Exception ex1) { return null; } } }
Example 6
Source File: AbstractFormatterTest.java From formatter-maven-plugin with Apache License 2.0 | 5 votes |
protected void doTestFormat(Map<String, String> options, Formatter formatter, String fileUnderTest, String expectedSha512, LineEnding lineEnding) throws IOException { // Set original file and file to use for test File originalSourceFile = new File("src/test/resources/", fileUnderTest); File sourceFile = new File(TEST_OUTPUT_DIR, fileUnderTest); // Copy file to new location Files.copy(originalSourceFile, sourceFile); // Read file to be formatted String originalCode = FileUtils.fileRead(sourceFile, StandardCharsets.UTF_8.name()); // Format the file and make sure formatting worked formatter.init(options, new TestConfigurationSource(TEST_OUTPUT_DIR)); String formattedCode = formatter.formatFile(sourceFile, originalCode, lineEnding); assertNotNull(formattedCode); assertNotEquals(originalCode, formattedCode); // Write the file we formatte4d FileUtils.fileWrite(sourceFile, StandardCharsets.UTF_8.name(), formattedCode); // We are hashing this as set in stone in case for some reason our source file changes unexpectedly. byte[] sha512 = Files.asByteSource(sourceFile).hash(Hashing.sha512()).asBytes(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < sha512.length; i++) { sb.append(Integer.toString((sha512[i] & 0xff) + 0x100, 16).substring(1)); } assertEquals(expectedSha512, sb.toString()); }
Example 7
Source File: AbstractCommunityEnvFactoryTest.java From maven-native with MIT License | 5 votes |
@Override protected Map<String, String> executeCommandLine(Commandline command) throws NativeBuildException { try { recordedCommandFile = FileUtils.fileRead( command.getLiteralExecutable() ); } catch ( IOException e ) { throw new NativeBuildException( "Failed to capture file output" ); } return new HashMap<>(); }
Example 8
Source File: JavaServiceWrapperDaemonGeneratorTest.java From appassembler with MIT License | 5 votes |
public void testGenerationWithEndorsedDirectory() throws Exception { runTest( "jsw", "src/test/resources/project-15/pom.xml", "src/test/resources/project-15/descriptor.xml", "target/output-15-jsw" ); File jswDir = getTestFile( "target/output-15-jsw/app" ); assertFileExists( jswDir, "conf/wrapper.conf" ); File wrapper = new File( jswDir, "conf/wrapper.conf" ); String wrapperContents = FileUtils.fileRead( wrapper ); assertTrue( "Wrapper conf does not contain lib-endorsed", wrapperContents.contains( "lib-endorsed" ) ); }
Example 9
Source File: POM.java From pomutils with Apache License 2.0 | 5 votes |
private void initialize() throws IOException, XMLStreamException { StringBuilder input = new StringBuilder(FileUtils.fileRead(pomFile)); pom = new ModifiedPomXMLEventReader(input, XML_INPUT_FACTORY); rawModel = PomHelper.getRawModel(pom); projectIdentifier = calculateProjectIdentifier(); projectVersion = rawModel.getVersion(); parentVersion = rawModel.getParent() != null ? rawModel.getParent().getVersion() : null; scmTag = rawModel.getScm() != null ? rawModel.getScm().getTag() : null; }
Example 10
Source File: JavaServiceWrapperDaemonGeneratorTest.java From appassembler with MIT License | 4 votes |
private String normalizedLineEndingRead( String file ) throws IOException { String expected = FileUtils.fileRead( getTestFile( file ) ); return StringUtils.unifyLineSeparators( expected ); }