当前位置: 首页>>代码示例>>Java>>正文


Java ContextProperties类代码示例

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


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

示例1: test

import de.invesdwin.context.ContextProperties; //导入依赖的package包/类
@Test
public void test() throws IOException {
    final String providedInstanceProperty = "-D" + ProvidedScriptTaskRunnerR.PROVIDED_INSTANCE_KEY + "="
            + RCallerScriptTaskRunnerR.class.getName();
    final String inputFile = new ClassPathResource(MainTest.class.getSimpleName() + "_input.csv", MainTest.class)
            .getFile().getAbsolutePath();
    final String outputFile = new File(ContextProperties.TEMP_DIRECTORY,
            MainTest.class.getSimpleName() + "_output.csv").getAbsolutePath();
    Main.main(new String[] { providedInstanceProperty, "-i", inputFile, "-o", outputFile });
    final List<String> optimalFStrs = FileUtils.readLines(new File(outputFile), Charset.defaultCharset());
    final List<Decimal> optimalFs = new ArrayList<Decimal>();
    for (final String optimalFStr : optimalFStrs) {
        optimalFs.add(new Decimal(optimalFStr).round(3));
    }
    Assertions.assertThat(optimalFs).isEqualTo(Arrays.asList(new Decimal("0.052"), new Decimal("0.213")));
}
 
开发者ID:subes,项目名称:invesdwin-context-r,代码行数:17,代码来源:MainTest.java

示例2: test

import de.invesdwin.context.ContextProperties; //导入依赖的package包/类
@Test
public void test() throws IOException {
    final String providedInstanceProperty = "-D" + ProvidedScriptTaskRunnerMatlab.PROVIDED_INSTANCE_KEY + "="
            + JavaOctaveScriptTaskRunnerMatlab.class.getName();
    final String inputFile = new ClassPathResource(MainTest.class.getSimpleName() + "_input.csv", MainTest.class)
            .getFile().getAbsolutePath();
    final String outputFile = new File(ContextProperties.TEMP_DIRECTORY,
            MainTest.class.getSimpleName() + "_output.csv").getAbsolutePath();
    Main.main(new String[] { providedInstanceProperty, "-i", inputFile, "-o", outputFile });
    final List<String> optimalFStrs = FileUtils.readLines(new File(outputFile), Charset.defaultCharset());
    final List<Decimal> optimalFs = new ArrayList<Decimal>();
    for (final String optimalFStr : optimalFStrs) {
        optimalFs.add(new Decimal(optimalFStr).round(3));
    }
    Assertions.assertThat(optimalFs).isEqualTo(Arrays.asList(new Decimal("0.052"), new Decimal("0.213")));
}
 
开发者ID:subes,项目名称:invesdwin-context-matlab,代码行数:17,代码来源:MainTest.java

示例3: testItWorks

import de.invesdwin.context.ContextProperties; //导入依赖的package包/类
@Test
public void testItWorks() {
    final ADelegateMapDB<String, Integer> map = new ADelegateMapDB<String, Integer>("testItWorks") {
        @Override
        protected File getBaseDirectory() {
            return ContextProperties.TEMP_DIRECTORY;
        }
    };
    Assertions.assertThat(map).isEmpty();
    Assertions.assertThat(map.put("1", 1)).isNull();
    Assertions.assertThat(map.get("1")).isEqualTo(1);
    Assertions.assertThat(map).isNotEmpty();
    map.close();
    Assertions.assertThat(map.isEmpty()).isFalse();
    map.clear();
    Assertions.assertThat(map.isEmpty()).isTrue();
    map.close();
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:19,代码来源:ADelegateMapDBTest.java

示例4: newFile

import de.invesdwin.context.ContextProperties; //导入依赖的package包/类
private File newFile(final String name, final boolean tmpfs, final FileChannelType pipes) {
    final File baseFolder;
    if (tmpfs) {
        baseFolder = SynchronousChannels.getTmpfsFolderOrFallback();
    } else {
        baseFolder = ContextProperties.TEMP_DIRECTORY;
    }
    final File file = new File(baseFolder, name);
    FileUtils.deleteQuietly(file);
    Assertions.checkFalse(file.exists(), "%s", file);
    if (pipes == FileChannelType.PIPE) {
        Assertions.checkTrue(SynchronousChannels.createNamedPipe(file));
    } else if (pipes == FileChannelType.MAPPED) {
        try {
            FileUtils.touch(file);
        } catch (final IOException e) {
            throw new RuntimeException(e);
        }
    } else {
        throw UnknownArgumentException.newInstance(FileChannelType.class, pipes);
    }
    Assertions.checkTrue(file.exists());
    return file;
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:25,代码来源:ChannelPerformanceTest.java

示例5: testConversion

import de.invesdwin.context.ContextProperties; //导入依赖的package包/类
@Test
public void testConversion() throws IOException {
    final String pattern = "classpath*:" + de.invesdwin.context.matlab.runtime.contract.InputsAndResultsTests.class
            .getPackage().getName().replace(".", "/") + "/**/*.m";
    final Resource[] mFiles = PreMergedContext.getInstance().getResources(pattern);
    for (final Resource mFile : mFiles) {
        final String sciStr = new MFileToSciScriptTask(mFile.getInputStream()).run();
        FileUtils.writeStringToFile(
                new File(ContextProperties.getCacheDirectory(), mFile.getFilename().replace(".m", ".sce")), sciStr,
                Charset.defaultCharset());
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-matlab,代码行数:13,代码来源:MFileToSciScriptTaskTest.java

示例6: getTempFolder

import de.invesdwin.context.ContextProperties; //导入依赖的package包/类
private File getTempFolder() {
    final File tempFolder = new File(ContextProperties.TEMP_DIRECTORY, SerializingCollection.class.getSimpleName());
    try {
        FileUtils.forceMkdir(tempFolder);
    } catch (final IOException e) {
        throw Err.process(e);
    }
    return tempFolder;
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:10,代码来源:SerializingCollection.java

示例7: getTmpfsFolderOrFallback

import de.invesdwin.context.ContextProperties; //导入依赖的package包/类
public static synchronized File getTmpfsFolderOrFallback() {
    if (tmpfsFolderOrFallback == null) {
        if (TMPFS_FOLDER.exists()) {
            tmpfsFolderOrFallback = DynamicInstrumentationProperties.newTempDirectory(TMPFS_FOLDER);
        } else {
            tmpfsFolderOrFallback = ContextProperties.TEMP_DIRECTORY;
        }
    }
    return tmpfsFolderOrFallback;
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:11,代码来源:SynchronousChannels.java

示例8: isNamedPipeSupported

import de.invesdwin.context.ContextProperties; //导入依赖的package包/类
public static synchronized boolean isNamedPipeSupported() {
    if (namedPipeSupportedCached == null) {
        final File namedPipeTestFile = new File(ContextProperties.TEMP_DIRECTORY,
                SynchronousChannels.class.getSimpleName() + "_NamedPipeTest.pipe");
        namedPipeSupportedCached = namedPipeTestFile.exists() || createNamedPipe(namedPipeTestFile);
        FileUtils.deleteQuietly(namedPipeTestFile);
    }
    return namedPipeSupportedCached;
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:10,代码来源:SynchronousChannels.java

示例9: testLevelDB

import de.invesdwin.context.ContextProperties; //导入依赖的package包/类
@Test
public void testLevelDB() {
    final Db ezdb = new EzLevelDb(ContextProperties.getCacheDirectory(), new EzLevelDbJniFactory());
    final Table<String, String> table = ezdb.getTable(getClass().getSimpleName(), StringSerde.get, StringSerde.get);
    table.put(HASHKEY, "value");
    Assertions.assertThat(table.get(HASHKEY)).isEqualTo("value");
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:8,代码来源:LevelDBTest.java

示例10: writePersistenceXml

import de.invesdwin.context.ContextProperties; //导入依赖的package包/类
private void writePersistenceXml() {
    try {
        final File metaInfDir = new File(ContextProperties.TEMP_CLASSPATH_DIRECTORY, "META-INF");
        FileUtils.forceMkdir(metaInfDir);
        final File file = new File(metaInfDir, "persistence.xml");
        FileUtils.deleteQuietly(file);
        final String content = generatePersistenceXml();
        FileUtils.write(file, content);
    } catch (final IOException e) {
        throw Err.process(e);
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:13,代码来源:ClasspathScanningPersistenceUnitManager.java

示例11: getContextResources

import de.invesdwin.context.ContextProperties; //导入依赖的package包/类
@Override
public List<PositionedResource> getContextResources() {
    try {
        final String content = generateContextXml();
        final File xmlFile = new File(ContextProperties.TEMP_DIRECTORY, "ctx.jpa.repository.scan.xml");
        FileUtils.writeStringToFile(xmlFile, content);
        final FileSystemResource fsResource = new FileSystemResource(xmlFile);
        xmlFile.deleteOnExit();
        return Arrays.asList(PositionedResource.of(fsResource, ResourcePosition.END));
    } catch (final IOException e) {
        throw Err.process(e);
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:14,代码来源:JpaRepositoryScanContextLocation.java

示例12: generateContextXml

import de.invesdwin.context.ContextProperties; //导入依赖的package包/类
private String generateContextXml() throws IOException {
    final StringBuilder sb = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    sb.append("\n<beans default-lazy-init=\"false\"");
    sb.append(" xmlns=\"http://www.springframework.org/schema/beans\"");
    sb.append(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
    sb.append(" xmlns:jpa=\"http://www.springframework.org/schema/data/jpa\"");
    sb.append(" xmlns:repository=\"http://www.springframework.org/schema/data/repository\"");
    sb.append(
            " xsi:schemaLocation=\"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd");
    sb.append(
            " http://www.springframework.org/schema/data/repository http://www.springframework.org/schema/data/repository/spring-repository.xsd");
    sb.append(
            " http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd\">");

    for (final String basePackage : ContextProperties.getBasePackages()) {
        final Map<String, Set<Class<?>>> entitiesMap = PersistenceUnitAnnotationUtil.scanForEntities(basePackage);
        final Map<Class<?>, Set<Class<?>>> jpaRepositoriesMap = scanForJpaRepositories(basePackage);
        for (final Entry<String, Set<Class<?>>> entitiesElement : entitiesMap.entrySet()) {
            final String persistenceUnitName = entitiesElement.getKey();
            final Set<Class<?>> entities = entitiesElement.getValue();
            final String jpaRepositoriesContent = generateJpaRepositoriesXml(basePackage, jpaRepositoriesMap,
                    persistenceUnitName, entities);
            sb.append(jpaRepositoriesContent);
        }
    }

    sb.append("\n</beans>");

    return sb.toString();
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:31,代码来源:JpaRepositoryScanContextLocation.java

示例13: getContextResources

import de.invesdwin.context.ContextProperties; //导入依赖的package包/类
@Override
public List<PositionedResource> getContextResources() {
    if (ContextProperties.IS_TEST_ENVIRONMENT) {
        return null;
    } else {
        return Arrays.asList(PersistenceContext.PROD_SERVER.getContextLocationResource());
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:9,代码来源:ProdPersistenceContextLocation.java

示例14: validateContextLocations

import de.invesdwin.context.ContextProperties; //导入依赖的package包/类
@Override
public void validateContextLocations(final List<PositionedResource> contextLocations) {
    boolean contextFound = false;
    for (final Resource location : contextLocations) {
        final String locationName = "/META-INF/" + location.getFilename();
        final PersistenceContext persistenceContext = PersistenceContext.fromContextLocation(locationName);
        if (persistenceContext != null) {
            if (contextFound) {
                throw new IllegalArgumentException("More than one " + PersistenceContext.class.getSimpleName()
                        + "s found, please choose only one! Contexts: " + contextLocations);
            } else {
                activePersistenceContext = persistenceContext;
                contextFound = true;
            }
        }
    }
    if (!contextFound) {
        if (ContextProperties.IS_TEST_ENVIRONMENT) {
            //add default location, since this might be a test where ATest was not used as the base class...
            activePersistenceContext = PersistenceContext.TEST_MEMORY;
            contextLocations.add(activePersistenceContext.getContextLocationResource());
        } else {
            throw new IllegalArgumentException(
                    "Production persistence context not found even though this is not a test environment?!?");
        }
    }
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:28,代码来源:ProdPersistenceContextLocation.java

示例15: getBaseDirectory

import de.invesdwin.context.ContextProperties; //导入依赖的package包/类
protected File getBaseDirectory() {
    return ContextProperties.getHomeDirectory();
}
 
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:4,代码来源:ADelegateMapDB.java


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