Java Code Examples for org.apache.commons.vfs2.FileObject#getFileOperations()

The following examples show how to use org.apache.commons.vfs2.FileObject#getFileOperations() . 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: BasicOperationsTestCase.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
/**
 * Ensure proper response for not found FileOperation.
 *
 * @throws FileSystemException for runtime problems
 */
@Test
public void testNotFoundOperation() throws FileSystemException {
    final MyFileOprationProviderBase myop = new MyFileOperationProviderNoncomp();
    manager.addOperationProvider("file", myop);
    final FileObject fo = manager.toFileObject(new File("."));

    final FileOperations ops = fo.getFileOperations();
    assertNotNull(ops);

    try {
        final FileOperation logop = ops.getOperation(VcsLog.class);
        fail("Must throw but returned " + logop);
    } catch (final FileSystemException e) {
        assertEquals("vfs.operation/operation-not-supported.error", e.getCode());
    }
    assertSame(32, myop.ops); // getOperation was called
}
 
Example 2
Source File: BasicOperationsTestCase.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Ensures getOperations calls collect and allows empty response.
 *
 * @throws FileSystemException for runtime problems
 */
@Test
public void testNotFoundAny() throws FileSystemException {
    final MyFileOprationProviderBase myop = new MyFileOperationProviderNoncomp();
    manager.addOperationProvider("file", myop);
    final FileObject fo = manager.toFileObject(new File("."));

    final FileOperations ops = fo.getFileOperations();
    assertNotNull(ops);

    final Class<? extends FileOperation>[] oparray = ops.getOperations();
    assertSame("no ops should be found", 0, oparray.length);
    assertSame(16, myop.ops); // collect
}