Java 类java.nio.file.ClosedFileSystemException 实例源码

项目:openjdk-jdk10    文件:T8147801.java   
void test(boolean withOption) {
    System.err.println("Testing " + (withOption ? "with" : "without") + " option");
    try {
        String dump = "";
        RootDoc root = getRootDoc(withOption);
        for (ClassDoc cd: root.specifiedClasses()) {
            dump += dump(cd);
        }
        if (dump.contains("lib.Lib2.i")) {
            if (!withOption) {
                error("control case failed: Lib2 class file was read, unexpectedly, without using option");
            }
        } else {
            if (withOption) {
                error("test case failed: could not read Lib2 class file, using option");
            }
        }
    } catch (ClosedFileSystemException e) {
        error("Unexpected exception: " + e);
    }
    System.err.println();
}
项目:openjdk9    文件:T8147801.java   
void test(boolean withOption) {
    System.err.println("Testing " + (withOption ? "with" : "without") + " option");
    try {
        RootDoc root = getRootDoc(withOption);
        for (ClassDoc cd: root.specifiedClasses()) {
            dump("", cd);
        }
        if (!withOption) {
            error("expected option did not occur");
        }
    } catch (ClosedFileSystemException e) {
        if (withOption) {
            error("Unexpected exception: " + e);
        } else {
            System.err.println("Exception received as expected: " + e);
        }
    }
    System.err.println();
}
项目:java-cloud-filesystem-provider    文件:CloudFileSystemTest.java   
@Test
public void testCloseWillThrowAnExceptionForSubsequentCalls() throws IOException {
    context.checking(new Expectations() {{
        allowing(cloudHostSettings).getName();
        will(returnValue("unit-test"));

        exactly(1).of(blobStoreContext).close();
    }});

    impl.close();
    Assert.assertFalse(impl.isOpen());

    try {
        impl.getBlobStoreContext();
        Assert.fail("Expected an exception");
    } catch (ClosedFileSystemException e) {
        // OK
    }
}
项目:incubator-taverna-engine    文件:RunServiceImpl.java   
@Override
public void close(String runID) throws InvalidRunIdException, InvalidExecutionIdException {
    Run run = getRun(runID);
    try {
        Bundle dataBundle = run.getDataBundle();
        DataBundles.closeBundle(dataBundle);
    } catch (IOException | ClosedFileSystemException e) {
        logger.log(Level.WARNING, "Error closing data bundle for run " + runID, e);
    }
    runMap.remove(runID);
    postEvent(RUN_CLOSED, runID);
}
项目:incubator-taverna-language    文件:BundleFileSystem.java   
/**
 * Thread-safe ClosedFileSystemException test
 * 
 * @return
 */
protected FileSystem getOrigFS() {
    FileSystem orig = origFS;
    if (orig == null || !orig.isOpen()) {
        throw new ClosedFileSystemException();
    }
    return orig;
}
项目:incubator-taverna-language    文件:BundleFileSystem.java   
@Override
public Set<String> supportedFileAttributeViews() {
    if (origFS == null) {
        throw new ClosedFileSystemException();
    }
    return origFS.supportedFileAttributeViews();
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category( Closable.class )
public void testClosedFSnewByteChannel() throws Exception {
    getClosedFS();

    FS.provider().newByteChannel( getClosedFileA(), Sets.asSet( READ ) );
}
项目:jimfs    文件:FileSystemStateTest.java   
@Test
public void testCheckOpen() throws IOException {
  state.checkOpen(); // does not throw
  state.close();
  try {
    state.checkOpen();
    fail();
  } catch (ClosedFileSystemException expected) {
  }
}
项目:crnk-framework    文件:ExceptionMapperRegistryTest.java   
@Test
public void shouldFindDescendantExceptionMapperFromException() throws Exception {
    Optional<JsonApiExceptionMapper> mapper = exceptionMapperRegistry.findMapperFor(ClosedFileSystemException.class);
    assertThat(mapper.isPresent()).isTrue();
    assertThat(mapper.get()).isExactlyInstanceOf(IllegalStateExceptionMapper.class);
}
项目:openjdk-jdk10    文件:FileSystemClosedTest.java   
void run() throws Exception {
    ToolBox tb = new ToolBox();
    Path jar = createJar(tb);

    Path src = Paths.get("src");
    tb.writeJavaFiles(src, "class C { p1.C1 c1; }");

    JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
    PrintWriter out = new PrintWriter(System.err, true);
    StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
    List<String> options = Arrays.asList("-classpath", jar.toString(), "-proc:none");
    Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(src.resolve("C.java"));
    com.sun.source.util.JavacTask task =
            (com.sun.source.util.JavacTask) comp.getTask(out, fm, null, options, null, files);
    task.parse();

    Elements elems = task.getElements();

    try {
        // Use  p1, p1.C1 as a control to verify normal behavior
        PackageElement p1 = elems.getPackageElement("p1");
        TypeElement p1C1 = elems.getTypeElement("p1.C1");
        System.err.println("p1: " + p1 + ";  p1C1: " + p1C1);
        if (p1C1 == null) {
            throw new Exception("p1.C1 not found");
        }

        // Now repeat for p2, p2.C2, closing the file manager early
        PackageElement p2 = elems.getPackageElement("p2");
        System.err.println("closing file manager");
        fm.close();
        TypeElement p2C2 = elems.getTypeElement("p2.C2");
        System.err.println("p2: " + p2 + ";  p2C2: " + p2C2);
        if (p2C2 != null) {
            throw new Exception("p2.C2 found unexpectedly");
        }
    } catch (ClosedFileSystemException e) {
        throw new Exception("unexpected exception thrown", e);
    }

}
项目:openjdk-jdk10    文件:JrtFileSystem.java   
final void ensureOpen() throws IOException {
    if (!isOpen()) {
        throw new ClosedFileSystemException();
    }
}
项目:openjdk9    文件:JrtFileSystem.java   
final void ensureOpen() throws IOException {
    if (!isOpen()) {
        throw new ClosedFileSystemException();
    }
}
项目:java-cloud-filesystem-provider    文件:CloudFileSystem.java   
void checkClosed() throws ClosedFileSystemException {
    if (closed.get()) {
        throw new ClosedFileSystemException();
    }
}
项目:katharsis-framework    文件:ExceptionMapperRegistryTest.java   
@Test
public void shouldFindDescendantExceptionMapperFromException() throws Exception {
    Optional<JsonApiExceptionMapper> mapper = exceptionMapperRegistry.findMapperFor(ClosedFileSystemException.class);
    assertThat(mapper.isPresent()).isTrue();
    assertThat(mapper.get()).isExactlyInstanceOf(IllegalStateExceptionMapper.class);
}
项目:ParallelGit    文件:GfsStatusProvider.java   
private void checkClosed() {
  if(closed) throw new ClosedFileSystemException();
}
项目:ParallelGit    文件:GfsObjectService.java   
private void checkClosed() {
  if(closed) throw new ClosedFileSystemException();
}
项目:jigsaw-jrtfs    文件:JrtFileSystem.java   
private void ensureOpen() throws IOException {
    if (!isOpen) {
        throw new ClosedFileSystemException();
    }
}
项目:ParallelGit    文件:GfsStatusProvider.java   
private void checkClosed() {
  if(closed) throw new ClosedFileSystemException();
}
项目:ParallelGit    文件:GfsObjectService.java   
private void checkClosed() {
  if(closed) throw new ClosedFileSystemException();
}
项目:jsr203-hadoop    文件:HadoopFileSystem.java   
private void ensureOpen() throws IOException {
    if (!isOpen)
        throw new ClosedFileSystemException();
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category( Closable.class )
public void testClosedFSCantRead() throws Exception {
    Files.readAllBytes( getClosedFileA() );
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category( Closable.class )
public void testClosedFSCantReadDir() throws Exception {
    Files.newDirectoryStream( getClosedDirB() );
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category( Closable.class )
public void testClosedFSGetBasicFileAttributeViewProvider() throws IOException {
    getClosedFS();
    FS.provider().getFileAttributeView( getClosedFileA(), BasicFileAttributeView.class );
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category( Closable.class )
public void testClosedFSCreateDirectoryOtherProvider() throws IOException {
    getClosedFSProvider().createDirectory( getClosedFileA() );
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category({ Closable.class, FileChannelT.class })
public void testClosedFSNewFileChannel() throws IOException {
    getClosedFSProvider().newFileChannel( getClosedFileA(), Collections.<OpenOption> emptySet() );
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category( Closable.class )
public void testClosedFSCheckAccess() throws IOException {
    getClosedFS();
    FS.provider().checkAccess( getClosedFileA() );
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category({ Closable.class, Writable.class })
public void testCopyFromClosedFS() throws IOException {
    getClosedFSProvider().copy( getClosedFileA(), dirTA() );
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category({ Closable.class, Writable.class })
public void testCopyToClosedFS() throws IOException {
    getClosedFSProvider().copy( fileTA(), getClosedFileA() );
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category({ Closable.class, Writable.class, Move.class })
public void testMoveToClosedFS() throws IOException {
    getClosedFSProvider().move( fileTA(), getClosedFileA() );
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category( Closable.class )
public void testClosedFSCreateHardLink() throws IOException {
    getClosedFSProvider().createLink( getClosedFileA(), getClosedFileA() );
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category( Closable.class )
public void testClosedFSDelete() throws IOException {
    getClosedFSProvider().delete( getClosedFileA() );
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category( Closable.class )
public void testClosedFSGetFileStore() throws IOException {
    getClosedFSProvider().getFileStore( getClosedFileA() );
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category( Closable.class )
public void testClosedFSIsHidden() throws IOException {
    getClosedFSProvider().isHidden( getClosedFileA() );
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category( Closable.class )
public void testClosedFSNewInputStream() throws IOException {
    getClosedFSProvider().newOutputStream( getClosedFileA() );
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category( Closable.class )
public void testClosedFSNewOutputStream() throws IOException {
    getClosedFSProvider().newOutputStream( getClosedFileA() );
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category( Closable.class )
public void testClosedFSReadAttributes() throws IOException {
    getClosedFSProvider().readAttributes( getClosedFileA(), BasicFileAttributes.class );
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category( Closable.class )
public void testClosedFSReadAttributesString() throws IOException {
    getClosedFSProvider().readAttributes( getClosedFileA(), "*" );
}
项目:niotest    文件:Tests07Closed.java   
@Test( expected = ClosedFileSystemException.class )
@Category( Closable.class )
public void testAppendFilesInClosedFSThrows() throws IOException {
    Files.write( getClosedFileA(), CONTENT_OTHER, APPEND );
}
项目:jimfs    文件:FileSystemState.java   
/**
 * Checks that the file system is open, throwing {@link ClosedFileSystemException} if it is not.
 */
public void checkOpen() {
  if (!open.get()) {
    throw new ClosedFileSystemException();
  }
}
项目:smb-nio    文件:SMBFileStore.java   
/**
 * Returns the total capacity of the share represented by this {@link SMBFileStore} instance.
 *
 * @return  Total capacity of the share represented by this {@link SMBFileStore} instance
 * @throws IOException If total capacity cannot be determined.
 */
@Override
public long getTotalSpace() throws IOException {
    if (!this.fileSystem.isOpen()) throw new ClosedFileSystemException();
    return new SmbFile(this.name()).length();
}