@Inject public Uploader(ArchiveUploadService archiveUploadService){ this.archiveUploadService = archiveUploadService; tmpRoot = Os.newTempDir("brooklyn-a4c"); Os.deleteOnExitRecursively(tmpRoot); }
@Inject public Alien4CloudFacade(ICSARRepositorySearchService repositorySearchService, TopologyTreeBuilderService treeBuilder, ICsarRepositry csarFileRepository, TopologyServiceCore topologyService, TopologyTemplateVersionService topologyTemplateVersionService, DeploymentTopologyService deploymentTopologyService, ApplicationService applicationService) { this.repositorySearchService = repositorySearchService; this.treeBuilder = treeBuilder; this.csarFileRepository = csarFileRepository; this.topologyService = topologyService; this.topologyTemplateVersionService = topologyTemplateVersionService; this.deploymentTopologyService = deploymentTopologyService; this.applicationService = applicationService; tmpRoot = Os.newTempDir("brooklyn-a4c"); Os.deleteOnExitRecursively(tmpRoot); }
/** as {@link #newTempDir(String)}, using the class as the basis for a prefix */ public static File newTempDir(Class<?> clazz) { return newTempDir(JavaClassNames.cleanSimpleClassName(clazz)); }
@Inject public Alien4CloudToscaPlatform(BeanFactory beanFactory, ToscaFacade alien4CloudFacade, Uploader uploader) { this.beanFactory = beanFactory; this.alien4CloudFacade = alien4CloudFacade; this.uploader = uploader; tmpRoot = Os.newTempDir("brooklyn-a4c"); Os.deleteOnExitRecursively(tmpRoot); loadDefaultTypes(); }
@BeforeMethod public void setUp() { mementoDir = Os.newTempDir(getClass()); managementContextForTermination = new ArrayList<>(); }
@BeforeMethod(alwaysRun = true) @Override public void setUp() throws Exception { super.setUp(); sourceFileDir = Os.newTempDir(getClass().getSimpleName()); sourceTemplateDir = Os.newTempDir(getClass().getSimpleName()); installDir = Os.newTempDir(getClass().getSimpleName()); runDir = Os.newTempDir(getClass().getSimpleName()); location = app.newLocalhostProvisioningLocation(); }
@BeforeMethod(alwaysRun = true) public void setUp() throws Exception { storageTempDir = Os.newTempDir("osgi-standalone"); framework = Osgis.getFramework(storageTempDir.getAbsolutePath(), true); }
@Override protected FileBasedObjectStore newPersistenceObjectStore() { if (dir!=null) throw new IllegalStateException("Test does not support multiple object stores"); dir = Os.newTempDir(getClass()); return new FileBasedObjectStore(dir); }
@Test public void testDeleteRecursivelySubDirs() throws Exception { File dir = Os.newTempDir(OsTest.class); File subdir = new File(dir, "mysubdir"); File subfile = new File(subdir, "mysubfile"); subdir.mkdirs(); Files.write("abc".getBytes(), subfile); DeletionResult result = Os.deleteRecursively(dir); assertTrue(result.wasSuccessful()); assertFalse(dir.exists()); } }
@BeforeMethod(alwaysRun=true) public void setUp() throws Exception { mementoDir = Os.newTempDir(getClass()); File mementoDirParent = mementoDir.getParentFile(); mementoDirBackup = new File(mementoDirParent, mementoDir.getName()+"."+Identifiers.makeRandomId(4)+".bak"); origApp = null; newApp = null; newManagementContext = null; origManagementContext = createOrigManagementContext(); origApp = createApp(); LOG.info("Test "+getClass()+" persisting to "+mementoDir); }
private File newZip(Map<String, String> files) throws Exception { File parentDir = Os.newTempDir(getClass().getSimpleName()+"-archive"); for (Map.Entry<String, String> entry : files.entrySet()) { File subFile = new File(Os.mergePaths(parentDir.getAbsolutePath(), entry.getKey())); subFile.getParentFile().mkdirs(); Files.write(entry.getValue(), subFile, Charsets.UTF_8); } return ArchiveBuilder.zip().addDirContentsAt(parentDir, ".").create(); }
@BeforeMethod(alwaysRun=true) public void setup() throws Exception { mgmt = new LocalManagementContext(); clearExpectedFailure(); tempDir = Os.newTempDir(getClass()); }
@Test public void testDeleteRecursivelyEmptyDir() throws Exception { File dir = Os.newTempDir(OsTest.class); DeletionResult result = Os.deleteRecursively(dir); assertTrue(result.wasSuccessful()); assertFalse(dir.exists()); }
@BeforeClass public void createTmpDirAndFiles() throws IOException { parentDir = Os.newTempDir(getClass().getSimpleName()); Os.deleteOnExitRecursively(parentDir); tmpDir = new File(parentDir, Identifiers.makeRandomId(4)); Os.mkdirs(tmpDir); Files.write("abcdef", new File(tmpDir, "data01.txt"), Charsets.US_ASCII); Files.write("123456", new File(tmpDir, "data02.txt"), Charsets.US_ASCII); Files.write("qqqqqq", new File(tmpDir, "data03.txt"), Charsets.US_ASCII); tmpDir2 = new File(parentDir, Identifiers.makeRandomId(4)); Os.mkdirs(tmpDir2); Files.write("zzzzzz", new File(tmpDir2, "data04.txt"), Charsets.US_ASCII); }
private String createJar(File dir, String parentDirInJar) { if (dir.isDirectory()) { File jarFile = ArchiveBuilder.jar().addAt(dir, parentDirInJar).create(Os.newTempDir(getClass())+"/topologies.jar"); return jarFile.getAbsolutePath(); } else { return dir.getAbsolutePath(); // An existing Jar archive? } }
@BeforeMethod(alwaysRun=true) @Override public void setUp() throws Exception { super.setUp(); machine = app.newLocalhostProvisioningLocation().obtain(); resourceUtils = ResourceUtils.create(ArchiveUtilsTest.class); destDir = Os.newTempDir(getClass().getSimpleName()); }
@Override @BeforeMethod(alwaysRun=true) public void setUp() throws Exception { mementoDir = Os.newTempDir(getClass()); File mementoDirParent = mementoDir.getParentFile(); mementoDirBackup = new File(mementoDirParent, mementoDir.getName()+"."+Identifiers.makeRandomId(4)+".bak"); origManagementContext = createOrigManagementContext(); origApp = origManagementContext.getEntityManager().createEntity(EntitySpec.create(BasicApplication.class)); LOG.info("Test "+getClass()+" persisting to "+mementoDir); super.setUp(); initNodeCreatorAndJcloudsLocation(newNodeCreator(), ImmutableMap.of()); }
@BeforeMethod(alwaysRun=true) public void setup() throws Exception { mgmt = new LocalManagementContext(); LocalhostMachineProvisioningLocation lhc = mgmt.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)); host = lhc.obtain(); clearExpectedFailure(); tempDir = Os.newTempDir(getClass()); }
protected File persist(BrooklynMementoRawData rawData) throws Exception { File newMementoDir = Os.newTempDir(getClass()); FileBasedObjectStore objectStore = new FileBasedObjectStore(newMementoDir); objectStore.injectManagementContext(origManagementContext); objectStore.prepareForSharedUse(PersistMode.CLEAN, HighAvailabilityMode.DISABLED); BrooklynMementoPersisterToObjectStore persister = new BrooklynMementoPersisterToObjectStore( objectStore, origManagementContext); persister.enableWriteAccess(); PersistenceExceptionHandler exceptionHandler = PersistenceExceptionHandlerImpl.builder().build(); persister.checkpoint(rawData, exceptionHandler); LOG.info("Test "+getClass()+" persisted raw data to "+newMementoDir); return newMementoDir; }
@Override protected ManagementContext newPersistingManagementContext() { mementoDir = Os.newTempDir(JavaClassNames.cleanSimpleClassName(this)); Os.deleteOnExitRecursively(mementoDir); return RebindTestUtils.managementContextBuilder(classLoader, new FileBasedObjectStore(mementoDir)) .persistPeriod(Duration.millis(10)).buildStarted(); }