本文整理汇总了Java中org.codehaus.plexus.util.FileUtils.fileRead方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.fileRead方法的具体用法?Java FileUtils.fileRead怎么用?Java FileUtils.fileRead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.plexus.util.FileUtils
的用法示例。
在下文中一共展示了FileUtils.fileRead方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkGeneration
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void checkGeneration(String name) throws URISyntaxException, IOException, JAXBException {
URL testfileUrl = getClass().getResource(name + ".groovy");
URL testfileResultUrl = getClass().getResource(name + ".xml");
URL testfileResultUrlYaml = getClass().getResource(name + ".yaml");
File file = new File(testfileUrl.toURI());
File resultFile = new File(testfileResultUrl.toURI());
File resultFileYaml = new File(testfileResultUrlYaml.toURI());
Node updateScriptNode = XmlGenerator.getUpdateScriptNode(getInterpretingClass(file));
StringWriter writer = new StringWriter();
getMarshaller().marshal(updateScriptNode, writer);
final String xml = writer.toString();
final String yaml = getYamlString(YamlGenerator.getUpdateYamlScript(getInterpretingClass(file)));
String expectedContent = FileUtils.fileRead(resultFile);
String expectedContentYaml = FileUtils.fileRead(resultFileYaml);
assertEquals("failed xml parsing of " + name, expectedContent, xml);
assertEquals("failed yaml parsing of " + name, expectedContentYaml, yaml);
}
示例2: getInterpretingClassStrippingCode
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public static ScriptClass getInterpretingClassStrippingCode(final File file) {
groovyClassLoader.clearCache();
String script;
try {
script = FileUtils.fileRead(file);
String imports = getAnnotationClasses().stream()
.map(clazz -> "import " + clazz.getCanonicalName() + ";")
.collect(joining());
String interpretCode = imports + script.replaceAll("import .+\n", "")
.replaceAll("package\\s.*\n", "")
.replaceAll("extends\\s.*\\{[^\\u001a]*", "{}");
interpretCode = scrubAnnotations(interpretCode);
return new ScriptClass(file, groovyClassLoader.parseClass(interpretCode), script);
} catch (IOException e) {
return null;
}
}
示例3: generateHippoEcmExtensions
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
public void generateHippoEcmExtensions() throws URISyntaxException, IOException, JAXBException {
URI resourceURI = getClass().getResource("").toURI();
File root = new File(resourceURI);
List<ScriptClass> scriptClasses = ScriptClassFactory.getScriptClasses(root);
Node node = XmlGenerator.getEcmExtensionNode(root, new File(root, "target"), scriptClasses, "my-updater-prefix-");
StringWriter writer = new StringWriter();
getMarshaller().marshal(node, writer);
final String xml = writer.toString();
URL testfileResultUrl = getClass().getResource("resulting-hippoecm-extension.xml");
File resultFile = new File(testfileResultUrl.toURI());
String expectedContent = FileUtils.fileRead(resultFile);
assertEquals(expectedContent, xml);
}
示例4: generateNewHippoEcmExtensions
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
public void generateNewHippoEcmExtensions() throws URISyntaxException, IOException, JAXBException {
URI resourceURI = getClass().getResource("sub").toURI();
File root = new File(resourceURI);
List<ScriptClass> scriptClasses = ScriptClassFactory.getScriptClasses(root);
Node node = XmlGenerator.getEcmExtensionNode(root, new File(root, "target"), scriptClasses, "my-updater-prefix-");
StringWriter writer = new StringWriter();
getMarshaller().marshal(node, writer);
final String xml = writer.toString();
URL testfileResultUrl = getClass().getResource("sub-hippoecm-extension.xml");
File resultFile = new File(testfileResultUrl.toURI());
String expectedContent = FileUtils.fileRead(resultFile);
assertEquals(expectedContent, xml);
}
示例5: generateHcmActions
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
public void generateHcmActions() throws URISyntaxException, IOException {
URI resourceURI = getClass().getResource("").toURI();
File root = new File(resourceURI);
List<File> groovyFiles = Generator.getGroovyFiles(root);
//registry or unversioned scripts
List<ScriptClass> scriptClassesToReload = groovyFiles.stream().map(ScriptClassFactory::getInterpretingClass)
.filter(this::isRegistryOrUnversioned)
.collect(toList());
String yaml = YamlGenerator.getHcmActionsList(root, new File(root, "target"), scriptClassesToReload);
URL testfileResultUrl = getClass().getResource("resulting-hcm-actions.yaml");
File resultFile = new File(testfileResultUrl.toURI());
String expectedContent = FileUtils.fileRead(resultFile);
assertEquals(expectedContent, yaml);
}
示例6: testGenerationWithChkConfig
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public void testGenerationWithChkConfig() throws Exception {
runTest( "jsw", "src/test/resources/project-10/pom.xml", "src/test/resources/project-10/descriptor.xml",
"target/output-10-jsw" );
File jswDir = getTestFile( "target/output-10-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: 2345 21 81"));
}
示例7: testGenerationWithChkConfig
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
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" ) );
}
示例8: testStripAnnotations
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
public void testStripAnnotations() throws URISyntaxException, IOException {
URL testfileUrl = getClass().getResource("updater.groovy");
URL testfileResultUrl = getClass().getResource("updater.groovy.stripped");
File file = new File(testfileUrl.toURI());
File resultFile = new File(testfileResultUrl.toURI());
String content = FileUtils.fileRead(file);
String expectedContent = FileUtils.fileRead(resultFile);
assertEquals("failed stripping", expectedContent, stripAnnotations(content));
}
示例9: normalizedLineEndingRead
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private String normalizedLineEndingRead( String file )
throws IOException
{
String expected = FileUtils.fileRead(
getTestFile( file ) );
return StringUtils.unifyLineSeparators( expected );
}
示例10: testProcessingExcludes
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* Tests the ability of the plugin to process IDE GWT module (IDE.gwt.xml) to prevent inheriting
* the GWT modules of the excluded IDE plugins.
*/
@Test
public void testProcessingExcludes() throws Exception {
File projectCopy = resources.getBasedir("project");
File pom = new File(projectCopy, "pom.xml");
assertTrue(pom.exists());
ProcessExcludesMojo mojo = (ProcessExcludesMojo) rule.lookupMojo("process-excludes", pom);
assertNotNull(mojo);
configureMojo(mojo, projectCopy);
mojo.execute();
File fullGwtXml =
new File(
projectCopy,
"classes/org/eclipse/che/ide/Full" + FULL_IDE_GWT_MODULE_SUFFIX + ".gwt.xml");
assertTrue(fullGwtXml.exists());
String fullGwtXmlContent = FileUtils.fileRead(fullGwtXml);
assertFalse(fullGwtXmlContent.contains("org.eclipse.che.ide.ext.help.HelpAboutExtension"));
File ideGwtXml = new File(projectCopy, "classes/org/eclipse/che/ide/IDE.gwt.xml");
assertTrue(ideGwtXml.exists());
String ideGwtXmlContent = FileUtils.fileRead(ideGwtXml);
assertFalse(ideGwtXmlContent.contains("<inherits name=\"org.eclipse.che.ide.Full\"/>"));
assertTrue(
ideGwtXmlContent.contains(
"<inherits name=\"org.eclipse.che.ide.Full" + FULL_IDE_GWT_MODULE_SUFFIX + "\"/>"));
}
示例11: testGenerationWithEndorsedDirectory
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
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" ) );
}
示例12: readChecksum
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
String readChecksum(Path pChecksumPath)
{
try
{
Path path = pChecksumPath.resolveSibling(pChecksumPath.getFileName() + _getPostfix());
return FileUtils.fileRead(path.toFile());
}
catch (IOException e)
{
return null;
}
}
示例13: extractAnnotation
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
public void extractAnnotation() throws URISyntaxException, IOException {
URL testfileUrl = getClass().getResource("updater.groovy");
URL testfileUrl2 = getClass().getResource("updater-noimport.groovy");
String content = FileUtils.fileRead(new File(testfileUrl.toURI()));
String content2 = FileUtils.fileRead(new File(testfileUrl2.toURI()));
String updater = getAnnotation(content, Updater.class.getSimpleName());
String bootstrap = getAnnotation(content, Bootstrap.class.getSimpleName());
String fullUpdater = getAnnotation(content, Updater.class.getName());
String fullBootstrap = getAnnotation(content, Bootstrap.class.getName());
String updater2 = getAnnotation(content2, Updater.class.getSimpleName());
String bootstrap2 = getAnnotation(content2, Bootstrap.class.getSimpleName());
String fullUpdater2 = getAnnotation(content2, Updater.class.getName());
String fullBootstrap2 = getAnnotation(content2, Bootstrap.class.getName());
String updaterExpected = "@Updater(name = \"Test Updater\",\n" +
" xpath = \"//element(*, hippo:document)\",\n" +
" description=\"\", path = \"\", parameters = \" \")";
String bootstrapExpected = "@Bootstrap(reload = true, sequence = 99999.0d)";
String updaterFull = "@nl.openweb.hippo.groovy.annotations.Updater(name = \"Test Updater\",\n" +
" xpath = \"//element(*, hippo:document)\",\n" +
" description=\"\", path = \"\", parameters = \" \")";
String bootstrapFull = "@nl.openweb.hippo.groovy.annotations.Bootstrap(reload = true, sequence = 99999.0d)";
String bootstrapFull2 = "@nl.openweb.hippo.groovy.annotations.Bootstrap(sequence = 99999.0d)";
String updaterFull2 = "@nl.openweb.hippo.groovy.annotations.Updater(name = \"Test Updater noimport\",\n" +
" xpath = \"//element(*, hippo:document)\",\n" +
" description=\"\", path = \"\", parameters = \" \")";
assertEquals(updaterExpected, updater);
assertEquals(bootstrapExpected, bootstrap);
assertEquals("", fullUpdater);
assertEquals("", fullBootstrap);
assertEquals("", updater2);
assertEquals("", bootstrap2);
assertEquals(updaterFull2, fullUpdater2);
assertEquals(bootstrapFull2, fullBootstrap2);
}
示例14: fixIndirectLibraryReferences
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
*
*
* @param projectDirectory
* @param dependentLibs
* @param log
* @throws Exception
*/
public void fixIndirectLibraryReferences(File projectDirectory, Collection<String> dependentLibs, Log log) throws Exception
{
File projectFile = new File(projectDirectory, ".project");
if (!projectFile.exists()) {
throw new Exception("unable to locate .project file at " + projectFile.getAbsolutePath());
}
String content = FileUtils.fileRead(projectFile);
String projectsStartTag = "<projects>";
String projectsEndTag = "</projects>";
String projectStartTag = "<project>";
String projectEndTag = "</project>";
// / just want to append the file at the right point
int insertionPoint = content.indexOf(projectsEndTag);
if (insertionPoint == -1)
{
log.info("unable to find " + projectsEndTag + " in .project file");
}
String firstPart = content.substring(0, insertionPoint);
String lastPart = content.substring(insertionPoint);
String projectsSection = content.substring(content.indexOf(projectsStartTag), insertionPoint);
boolean firstPartAppended = false;
for (String dependentLib : dependentLibs)
{
String libTagNeeded = projectStartTag + dependentLib + projectEndTag;
if (!projectsSection.contains(libTagNeeded))
{
firstPartAppended = true;
firstPart += "\t" + libTagNeeded;
log.info("adding direct project reference " + libTagNeeded + " to " + projectFile.getAbsolutePath());
}
}
if (firstPartAppended)
{
firstPart += "\n\t";
}
else
{
log.info("no dependent libraries fix needed for " + projectFile.getAbsolutePath());
}
content = firstPart + lastPart;
FileUtils.fileWrite(projectFile, content);
}
示例15: contentOf
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public String contentOf(String projectName, String fileName) throws IOException {
return FileUtils.fileRead(fileIn(projectName, fileName));
}