Java Code Examples for org.apache.brooklyn.util.os.Os#mkdirs()

The following examples show how to use org.apache.brooklyn.util.os.Os#mkdirs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RebindFailuresTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test
public void testFailureRebindingBecauseDirectoryCorrupt() throws Exception {
    RebindFailureMode danglingRefFailureMode = RebindManager.RebindFailureMode.CONTINUE;
    RebindFailureMode rebindFailureMode = RebindManager.RebindFailureMode.FAIL_AT_END;
    
    origManagementContext.getRebindManager().stopPersistence();
    if (mementoDir != null) RebindTestUtils.deleteMementoDir(mementoDir);
    File entitiesDir = Os.mkdirs(new File(mementoDir, "entities"));
    Files.write("invalid text", new File(entitiesDir, "mycorruptfile"), Charsets.UTF_8);
    
    LocalManagementContext newManagementContext = LocalManagementContextForTests.newInstance();
    RecordingRebindExceptionHandler exceptionHandler = new RecordingRebindExceptionHandler(danglingRefFailureMode, rebindFailureMode);
    try {
        newApp = rebind(RebindOptions.create().newManagementContext(newManagementContext).exceptionHandler(exceptionHandler));
        fail();
    } catch (Exception e) {
        assertFailureRebindingError(e);
    }
    
    // exception handler should have been told about failure
    assertFalse(exceptionHandler.loadMementoFailures.isEmpty(), "exceptions="+exceptionHandler.loadMementoFailures);
}
 
Example 2
Source File: ArchiveBuilderTest.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@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);
}