• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Utils4J类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.fuin.utils4j.Utils4J的典型用法代码示例。如果您正苦于以下问题:Java Utils4J类的具体用法?Java Utils4J怎么用?Java Utils4J使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Utils4J类属于org.fuin.utils4j包,在下文中一共展示了Utils4J类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testwriteInitialLogbackXml

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
@Test
public void testwriteInitialLogbackXml() throws IOException {

    // PREPARE
    final File logbackXmlFile = File
            .createTempFile(this.getClass().getSimpleName() + "-testwriteInitialLogbackXml-", ".xml");

    // TEST
    LogbackStandalone.writeInitialLogbackXml(logbackXmlFile, Level.WARN,
            this.getClass().getPackage().getName(), Level.INFO,
            "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n", "ext4logback-2");

    // VERIFY
    final String expectedXml = IOUtils.toString(Utils4J.url("classpath:logback-expected-2.xml"),
            Charset.forName("utf-8"));
    assertThat(logbackXmlFile).hasContent(expectedXml);

}
 
开发者ID:fuinorg,项目名称:ext4logback,代码行数:19,代码来源:LogbackStandaloneTest.java


示例2: validate

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
private static void validate(final Model model) {
    final List<Dependency> dependencies = model.getDependencies();
    for (final Dependency dependency : dependencies) {
        if (dependency.getVersion() == null) {
            final DependencyManagement dm = model.getDependencyManagement();
            final String version = findVersion(dm, dependency);
            if (version == null) {
                throw new IllegalStateException(
                        "Dependency version not set for '"
                                + dependency.getGroupId() + ":"
                                + dependency.getArtifactId() + "' in '"
                                + model.getGroupId() + ":"
                                + model.getArtifactId() + ":"
                                + model.getVersion() + "'");
            }
            dependency.setVersion(Utils4J.replaceVars(version,
                    createVarMap(model)));
        }
    }
}
 
开发者ID:fuinorg,项目名称:utils4maven,代码行数:21,代码来源:MavenPomReader.java


示例3: readAtomFeed

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
@Override
public final List<URI> readAtomFeed(final InputStream in) {

    final Document doc = parseDocument(createDocumentBuilder(), in);
    final XPath xPath = createXPath("ns", "http://www.w3.org/2005/Atom");
    final NodeList nodeList = findNodes(doc, xPath, "/ns:feed/ns:entry/ns:id");

    final List<URI> uris = new ArrayList<>();
    for (int i = 0; i < nodeList.getLength(); i++) {
        final Node node = nodeList.item(i);
        final String text = node.getTextContent();
        try {
            uris.add(Utils4J.url(text).toURI());
        } catch (final URISyntaxException ex) {
            throw new RuntimeException("Couldn't create URI: " + text);
        }
    }
    return uris;
}
 
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:20,代码来源:AtomFeedXmlReader.java


示例4: readAtomFeed

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
@Override
public final List<URI> readAtomFeed(final InputStream in) {

    final List<URI> uris = new ArrayList<>();

    final JsonReader jsonReader = Json.createReader(new InputStreamReader(in));
    final JsonObject jsonObj = jsonReader.readObject();
    final JSONArray read = JsonPath.read(jsonObj, "$.entries..id");
    if (read != null) {
        for (int i = 0; i < read.size(); i++) {
            final JsonString id = (JsonString) read.get(i);
            final String uri = id.getString();
            try {
                uris.add(Utils4J.url(uri).toURI());
            } catch (final URISyntaxException ex) {
                throw new RuntimeException("Couldn't create URI: " + uri);
            }
        }
    }

    return uris;

}
 
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:24,代码来源:AtomFeedJsonReader.java


示例5: downloadEventStoreArchive

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
private File downloadEventStoreArchive() throws MojoExecutionException {

        final URL url = createDownloadURL();
        try {
            final File file = getDownloadFile();
            if (file.exists()) {
                LOG.info("Archive already exists in target directory: " + file);
            } else {
                LOG.info("Dowloading archive: " + url);
                // Cache the file locally in the temporary directory
                final File tmpFile = new File(Utils4J.getTempDir(), file.getName());
                if (!tmpFile.exists()) {
                    download(url, tmpFile);
                    LOG.info("Archive downloaded to: " + tmpFile);
                }
                FileUtils.copyFile(tmpFile, file);
                LOG.info("Archive copied from '" + tmpFile + "' to:" + file);
            }
            return file;
        } catch (final IOException ex) {
            throw new MojoExecutionException("Error downloading event store archive: " + url, ex);
        }
    }
 
开发者ID:fuinorg,项目名称:event-store-maven-plugin,代码行数:24,代码来源:EventStoreDownloadMojo.java


示例6: testUnTarGz

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
@Test
public void testUnTarGz() throws MojoExecutionException, IOException {

    // PREPARE
    final String name = this.getClass().getSimpleName() + "-testUnTarGz";
    final File archive = File.createTempFile(name + "-", ".tar.gz");
    final File destDir = new File(Utils4J.getTempDir(), name);
    init("example.tar.gz", archive, destDir);

    // TEST
    EventStoreDownloadMojo.unTarGz(archive, destDir);

    // VERIFY
    assertAllExists(destDir);

}
 
开发者ID:fuinorg,项目名称:event-store-maven-plugin,代码行数:17,代码来源:EventStoreDownloadMojoTest.java


示例7: testUnTarGzFilesOnly

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
@Test
public void testUnTarGzFilesOnly() throws MojoExecutionException, IOException {

    // PREPARE
    final String name = this.getClass().getSimpleName() + "-testUnTarGzFilesOnly";
    final File archive = File.createTempFile(name + "-", ".tar.gz");
    final File destDir = new File(Utils4J.getTempDir(), name);
    init("files-only.tar.gz", archive, destDir);

    // TEST
    EventStoreDownloadMojo.unTarGz(archive, destDir);

    // VERIFY
    assertAllExists(destDir);

}
 
开发者ID:fuinorg,项目名称:event-store-maven-plugin,代码行数:17,代码来源:EventStoreDownloadMojoTest.java


示例8: testUnzip

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
@Test
public void testUnzip() throws MojoExecutionException, IOException {

    // PREPARE
    final String name = this.getClass().getSimpleName() + "-testUnzip";
    final File archive = File.createTempFile(name + "-", ".zip");
    final File destDir = new File(Utils4J.getTempDir(), name);
    init("example.zip", archive, destDir);

    // TEST
    EventStoreDownloadMojo.unzip(archive, destDir);

    // VERIFY
    assertAllExists(destDir);

}
 
开发者ID:fuinorg,项目名称:event-store-maven-plugin,代码行数:17,代码来源:EventStoreDownloadMojoTest.java


示例9: testDownload

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
@Test
public void testDownload() throws IOException {

    // PREPARE
    final URL versionURL = new URL(AbstractEventStoreMojo.VERSION_URL);
    final Downloads testee = new Downloads(versionURL,
            new File(Utils4J.getTempDir(),
                    "event-store-versions-" + UUID.randomUUID() + ".json"));

    // TEST
    testee.parse();

    // VERIFY
    assertThat(testee.getOsList()).containsExactlyInAnyOrder(
            new DownloadOS("ubuntu-16.04"), new DownloadOS("ubuntu-14.04"),
            new DownloadOS("osx-10.10"), new DownloadOS("win"));
    final DownloadOS ubuntu = testee.findOS("ubuntu-16.04");
    assertThat(ubuntu.getOS()).isEqualTo("ubuntu-16.04");
    assertThat(ubuntu.getCurrentVersion()).isNotNull();

}
 
开发者ID:fuinorg,项目名称:event-store-maven-plugin,代码行数:22,代码来源:DownloadsTest.java


示例10: parseDir

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
/**
 * Parse the directory and it's sub directory.
 * 
 * @param dir
 *            Directory to parse.
 */
private void parseDir(final File dir) {
    LOG.debug("Parse: " + dir);
    final File[] files = getFiles(dir);
    if ((files == null) || (files.length == 0)) {
        LOG.debug("No files found in directory: " + dir);
    } else {
        for (final File file : files) {
            if (file.isFile()) {
                final Resource resource = resourceSet.getResource(
                        URI.createFileURI(Utils4J.getCanonicalPath(file)),
                        true);
                LOG.debug("Parsed: " + resource.getURI());
            } else {
                parseDir(file);
            }
        }
    }
}
 
开发者ID:fuinorg,项目名称:srcgen4j-core,代码行数:25,代码来源:AbstractEMFParser.java


示例11: createAndInit

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
/**
 * Creates and initializes a SrcGen4J configuration from a configuration
 * file that contains ONLY generators/parsers of type
 * {@link ParameterizedTemplateParser} and
 * {@link ParameterizedTemplateGenerator}.
 * 
 * @param context
 *            Current context - Cannot be NULL.
 * @param configFile
 *            XML configuration file to read - Cannot be NULL.
 * 
 * @return New configuration instance.
 * 
 * @throws UnmarshalObjectException
 *             Error reading the configuration.
 */
public static SrcGen4JConfig createAndInit(final SrcGen4JContext context,
        final File configFile) throws UnmarshalObjectException {
    try {
        final JaxbHelper helper = new JaxbHelper();
        final SrcGen4JConfig config = helper.create(configFile, JAXBContext
                .newInstance(SrcGen4JConfig.class,
                        VelocityGeneratorConfig.class,
                        ParameterizedTemplateParserConfig.class,
                        ParameterizedTemplateGeneratorConfig.class));
        config.init(context,
                Utils4J.getCanonicalFile(configFile.getParentFile()));
        return config;
    } catch (final JAXBException ex) {
        throw new UnmarshalObjectException(
                "Error reading the configuration: " + configFile, ex);
    }
}
 
开发者ID:fuinorg,项目名称:srcgen4j-core,代码行数:34,代码来源:PTGenHelper.java


示例12: init

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
/**
 * Initializes the model.
 * 
 * @param context
 *            Current context.
 * @param vars
 *            Variables to use.
 */
public final void init(final SrcGen4JContext context,
        final Map<String, String> vars) {

    if (template != null) {
        template = Utils4J.replaceVars(template, vars);
    }
    if (arguments != null) {
        for (final Argument argument : arguments) {
            argument.init(vars);
        }
    }
    if (targetFiles != null) {
        for (final TargetFile targetFile : targetFiles) {
            targetFile.init(vars);
        }
    }
    if (tflProducerConfig != null) {
        tflProducerConfig.init(context, this, vars);
    }
}
 
开发者ID:fuinorg,项目名称:srcgen4j-core,代码行数:29,代码来源:ParameterizedTemplateModel.java


示例13: create

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
@Override
public final GeneratedArtifact create(@NotNull final Greeting greeting,
        @NotNull final Map<String, Object> context,
        final boolean preparationRun) throws GenerateException {
    try {
        final String src = FileUtils.readFileToString(new File(
                "src/test/resources/AbstractHello.template"));
        final Map<String, String> vars = new HashMap<>();
        vars.put("name", greeting.getName());
        final String pkg = varMap.get("package");
        final String path = pkg.replace('.', '/');
        vars.put("package", pkg);
        return new GeneratedArtifact(artifact, path + "/AbstractHello"
                + greeting.getName() + ".java", Utils4J.replaceVars(src,
                vars).getBytes());
    } catch (final IOException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:fuinorg,项目名称:srcgen4j-core,代码行数:20,代码来源:AbstractHelloTstGen.java


示例14: create

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
@Override
public final GeneratedArtifact create(@NotNull final Greeting greeting,
        @NotNull final Map<String, Object> context,
        final boolean preparationRun) throws GenerateException {
    try {
        final String src = FileUtils.readFileToString(new File(
                "src/test/resources/Hello.template"));
        final Map<String, String> vars = new HashMap<>();
        vars.put("name", greeting.getName());
        return new GeneratedArtifact(artifact, "a/b/c/Hello"
                + greeting.getName() + ".java", Utils4J.replaceVars(src,
                vars).getBytes());
    } catch (final IOException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:fuinorg,项目名称:srcgen4j-core,代码行数:17,代码来源:ManualHelloTstGen.java


示例15: beforeClass

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws IOException {
    testDir = getTestDir(HiddenFileFilterTest.class.getName());
    testDir.mkdir();

    visibleFile = new File(testDir, "visible.txt");
    FileUtils.touch(visibleFile);
    visibleFileInfo = createFSI(visibleFile);

    hiddenFile = new File(testDir, "hidden.txt");
    // TODO xxx In Java 6 there is no way to hide a file
    // hiddenFile.setVisible(false);
    hiddenFileInfo = createFSI(hiddenFile);

    notExistingFile = new File(testDir, "not-existing-file.txt");
    notExistingFileInfo = createFSI(notExistingFile);

    // Zip the test directory
    zipFile = new File(getTempDir(), HiddenFileFilterTest.class.getName() + ".zip");
    Utils4J.zipDir(testDir, "", zipFile);
    zipFileObj = getZipFileObject(zipFile);

}
 
开发者ID:fuinorg,项目名称:commons-vfs2-filters,代码行数:24,代码来源:HiddenFileFilterTest.java


示例16: beforeClass

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws IOException {

    testDir = getTestDir(DirectoryAndFileFilterTest.class.getName());
    testDir.mkdir();

    dir = new File(testDir, DIR);
    dir.mkdir();
    dirInfo = createFSI(dir);

    file = new File(dir, FILE);
    FileUtils.touch(file);
    fileInfo = createFSI(file);

    notExistingFile = new File(testDir, "not-existing-file.txt");
    notExistingFileInfo = createFSI(notExistingFile);

    zipFile = new File(getTempDir(), DirectoryAndFileFilterTest.class.getName() + ".zip");
    Utils4J.zipDir(testDir, "", zipFile);
    zipFileObj = getZipFileObject(zipFile);

}
 
开发者ID:fuinorg,项目名称:commons-vfs2-filters,代码行数:23,代码来源:DirectoryAndFileFilterTest.java


示例17: beforeClass

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws IOException {

    testDir = getTestDir(CanReadFileFilterTest.class.getName());

    writeableFile = new File(testDir, WRITEABLE);
    writeableFileInfo = createFSI(writeableFile);
    FileUtils.touch(writeableFile);

    readOnlyFile = new File(testDir, READONLY);
    readOnlyFileInfo = createFSI(readOnlyFile);
    FileUtils.touch(readOnlyFile);
    readOnlyFile.setReadable(true);
    readOnlyFile.setWritable(false);

    notExistingFile = new File(testDir, "not-existing-file.txt");
    notExistingFileInfo = createFSI(notExistingFile);

    zipFile = new File(getTempDir(), CanReadFileFilterTest.class.getName() + ".zip");
    Utils4J.zipDir(testDir, "", zipFile);
    zipFileObj = getZipFileObject(zipFile);

}
 
开发者ID:fuinorg,项目名称:commons-vfs2-filters,代码行数:24,代码来源:CanReadFileFilterTest.java


示例18: beforeClass

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws IOException {
    testDir = getTestDir(SizeFileFilterTest.class.getName());

    // 2 characters
    minFile = new File(testDir, "min.txt");
    FileUtils.write(minFile, "12");
    minFileInfo = createFSI(minFile);

    // 4 characters
    optFile = new File(testDir, "opt.txt");
    FileUtils.write(optFile, "1234");
    optFileInfo = createFSI(optFile);

    // 6 characters
    maxFile = new File(testDir, "max.txt");
    FileUtils.write(maxFile, "123456");
    maxFileInfo = createFSI(maxFile);

    // Zip the test directory
    zipFile = new File(getTempDir(), SizeFileFilterTest.class.getName() + ".zip");
    Utils4J.zipDir(testDir, "", zipFile);
    zipFileObj = getZipFileObject(zipFile);

}
 
开发者ID:fuinorg,项目名称:commons-vfs2-filters,代码行数:26,代码来源:SizeFileFilterTest.java


示例19: beforeClass

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws IOException {

    testDir = getTestDir(CanWriteFileFilterTest.class.getName());

    writeableFile = new File(testDir, WRITEABLE);
    writeableFileInfo = createFSI(writeableFile);
    FileUtils.touch(writeableFile);

    readOnlyFile = new File(testDir, READONLY);
    readOnlyFileInfo = createFSI(readOnlyFile);
    FileUtils.touch(readOnlyFile);
    readOnlyFile.setReadable(true);
    readOnlyFile.setWritable(false);

    notExistingFile = new File(testDir, "not-existing-file.txt");
    notExistingFileInfo = createFSI(notExistingFile);

    zipFile = new File(getTempDir(), CanWriteFileFilterTest.class.getName() + ".zip");
    Utils4J.zipDir(testDir, "", zipFile);
    zipFileObj = getZipFileObject(zipFile);

}
 
开发者ID:fuinorg,项目名称:commons-vfs2-filters,代码行数:24,代码来源:CanWriteFileFilterTest.java


示例20: assertMethodsNotUsed

import org.fuin.utils4j.Utils4J; //导入依赖的package包/类
/**
 * Asserts that a set of methods is not used.
 * 
 * @param classesDir
 *            Directory with the ".class" files to check - Cannot be
 *            <code>null</code> and must be a valid directory.
 * @param filter
 *            File filter or NULL (process all '*.class' files).
 * @param methodsToFind
 *            List of methods to find - Cannot be NULL.
 */
public static final void assertMethodsNotUsed(final File classesDir,
        final FileFilter filter, final List<MCAMethod> methodsToFind) {

    Utils4J.checkNotNull("classesDir", classesDir);
    Utils4J.checkValidDir(classesDir);
    Utils4J.checkNotNull("methodsToFind", methodsToFind);

    final MethodCallAnalyzer analyzer = new MethodCallAnalyzer(
            methodsToFind);
    analyzer.findCallingMethodsInDir(classesDir, filter);

    final List<MCAMethodCall> methodCalls = analyzer.getMethodCalls();
    if (methodCalls.size() > 0) {
        final StringBuffer sb = new StringBuffer(
                "Illegal method call(s) found:");
        for (final MCAMethodCall methodCall : methodCalls) {
            sb.append("\n");
            sb.append(methodCall);
        }
        Assert.fail(sb.toString());
    }

}
 
开发者ID:fuinorg,项目名称:units4j,代码行数:35,代码来源:AssertUsage.java



注:本文中的org.fuin.utils4j.Utils4J类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ASMData类代码示例发布时间:2022-05-22
下一篇:
Java InteractiveCallback类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap