當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。