Search in sources :

Example 71 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project cdap by caskdata.

the class DatasetFrameworkTestUtil method before.

@Override
protected void before() throws Throwable {
    this.tmpFolder = new TemporaryFolder();
    tmpFolder.create();
    File localDataDir = tmpFolder.newFolder();
    cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, localDataDir.getAbsolutePath());
    injector = Guice.createInjector(new ConfigModule(cConf), new NonCustomLocationUnitTestModule().getModule(), new SystemDatasetRuntimeModule().getInMemoryModules(), new TransactionModules().getInMemoryModules(), new TransactionExecutorModule(), new PrivateModule() {

        @Override
        protected void configure() {
            install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
            bind(DatasetFramework.class).to(InMemoryDatasetFramework.class);
            expose(DatasetFramework.class);
        }
    });
    txManager = injector.getInstance(TransactionManager.class);
    txManager.startAndWait();
    framework = injector.getInstance(DatasetFramework.class);
}
Also used : TransactionModules(org.apache.tephra.runtime.TransactionModules) TransactionExecutorModule(co.cask.cdap.data.runtime.TransactionExecutorModule) ConfigModule(co.cask.cdap.common.guice.ConfigModule) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) TransactionManager(org.apache.tephra.TransactionManager) TemporaryFolder(org.junit.rules.TemporaryFolder) SystemDatasetRuntimeModule(co.cask.cdap.data.runtime.SystemDatasetRuntimeModule) NonCustomLocationUnitTestModule(co.cask.cdap.common.guice.NonCustomLocationUnitTestModule) File(java.io.File) PrivateModule(com.google.inject.PrivateModule)

Example 72 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project cdap by caskdata.

the class MetricsSuiteTestBase method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    if (!runBefore) {
        return;
    }
    tmpFolder = new TemporaryFolder();
    conf = CConfiguration.create();
    conf.set(Constants.Metrics.ADDRESS, hostname);
    conf.set(Constants.AppFabric.OUTPUT_DIR, System.getProperty("java.io.tmpdir"));
    conf.set(Constants.AppFabric.TEMP_DIR, System.getProperty("java.io.tmpdir"));
    conf.setBoolean(Constants.Dangerous.UNRECOVERABLE_RESET, true);
    conf.setBoolean(Constants.Metrics.CONFIG_AUTHENTICATION_REQUIRED, true);
    conf.set(Constants.Metrics.CLUSTER_NAME, CLUSTER);
    Injector injector = startMetricsService(conf);
    store = injector.getInstance(Store.class);
    locationFactory = injector.getInstance(LocationFactory.class);
    metricStore = injector.getInstance(MetricStore.class);
    tmpFolder.create();
}
Also used : MetricStore(co.cask.cdap.api.metrics.MetricStore) Injector(com.google.inject.Injector) TemporaryFolder(org.junit.rules.TemporaryFolder) MetricStore(co.cask.cdap.api.metrics.MetricStore) DefaultStore(co.cask.cdap.internal.app.store.DefaultStore) Store(co.cask.cdap.app.store.Store) LocationFactory(org.apache.twill.filesystem.LocationFactory) BeforeClass(org.junit.BeforeClass)

Example 73 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project activemq-artemis by apache.

the class EmbeddedBrokerTestSupport method setUp.

@Override
protected void setUp() throws Exception {
    BrokerService.disableWrapper = disableWrapper;
    File tmpRoot = new File("./target/tmp");
    tmpRoot.mkdirs();
    temporaryFolder = new TemporaryFolder(tmpRoot);
    temporaryFolder.create();
    if (artemisBroker == null) {
        artemisBroker = createArtemisBroker();
    }
    startBroker();
    connectionFactory = createConnectionFactory();
    destination = createDestination();
    template = createJmsTemplate();
    template.setDefaultDestination(destination);
    template.setPubSubDomain(useTopic);
    template.afterPropertiesSet();
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) File(java.io.File)

Example 74 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project activemq-artemis by apache.

the class BrokerService method start.

@Override
public void start() throws Exception {
    File targetTmp = new File("./target/tmp");
    targetTmp.mkdirs();
    tmpfolder = new TemporaryFolder(targetTmp);
    tmpfolder.create();
    Exception e = new Exception();
    startBroker(startAsync);
    map.put(broker, e);
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) File(java.io.File) URISyntaxException(java.net.URISyntaxException) MalformedObjectNameException(javax.management.MalformedObjectNameException) IOException(java.io.IOException)

Example 75 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project accumulo by apache.

the class SortedLogRecoveryTest method recover.

private static List<Mutation> recover(Map<String, KeyValue[]> logs, Set<String> files, KeyExtent extent) throws IOException {
    TemporaryFolder root = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
    root.create();
    final String workdir = root.getRoot().getAbsolutePath() + "/workdir";
    VolumeManager fs = VolumeManagerImpl.getLocal(workdir);
    final Path workdirPath = new Path("file://" + workdir);
    fs.deleteRecursively(workdirPath);
    ArrayList<Path> dirs = new ArrayList<>();
    try {
        for (Entry<String, KeyValue[]> entry : logs.entrySet()) {
            String path = workdir + "/" + entry.getKey();
            FileSystem ns = fs.getVolumeByPath(new Path(path)).getFileSystem();
            @SuppressWarnings("deprecation") Writer map = new MapFile.Writer(ns.getConf(), ns, path + "/log1", LogFileKey.class, LogFileValue.class);
            for (KeyValue lfe : entry.getValue()) {
                map.append(lfe.key, lfe.value);
            }
            map.close();
            ns.create(SortedLogState.getFinishedMarkerPath(path)).close();
            dirs.add(new Path(path));
        }
        // Recover
        SortedLogRecovery recovery = new SortedLogRecovery(fs);
        CaptureMutations capture = new CaptureMutations();
        recovery.recover(extent, dirs, files, capture);
        return capture.result;
    } finally {
        root.delete();
    }
}
Also used : Path(org.apache.hadoop.fs.Path) VolumeManager(org.apache.accumulo.server.fs.VolumeManager) ArrayList(java.util.ArrayList) FileSystem(org.apache.hadoop.fs.FileSystem) TemporaryFolder(org.junit.rules.TemporaryFolder) MapFile(org.apache.hadoop.io.MapFile) File(java.io.File) Writer(org.apache.hadoop.io.MapFile.Writer)

Aggregations

TemporaryFolder (org.junit.rules.TemporaryFolder)106 File (java.io.File)40 Before (org.junit.Before)28 Test (org.junit.Test)28 BeforeClass (org.junit.BeforeClass)13 URL (java.net.URL)7 Path (java.nio.file.Path)7 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)3 UserState (alluxio.security.user.UserState)2 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)2 RocksDBPersistenceProvider (com.iota.iri.storage.rocksDB.RocksDBPersistenceProvider)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 URISyntaxException (java.net.URISyntaxException)2 BdpDataPlanePlugin (org.batfish.bdp.BdpDataPlanePlugin)2 Batfish (org.batfish.main.Batfish)2 NotNull (org.jetbrains.annotations.NotNull)2 DefaultSafeModeManager (alluxio.master.DefaultSafeModeManager)1 InMemoryReferenceSequenceFile (au.edu.wehi.idsv.picard.InMemoryReferenceSequenceFile)1 SynchronousReferenceLookupAdapter (au.edu.wehi.idsv.picard.SynchronousReferenceLookupAdapter)1