blob: ae7371a174916655159a75c2f93258d05c6445fd [file] [log] [blame]
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
= UsingFileSystemsMasterfs
:jbake-type: wiki
:jbake-tags: wiki, devfaq, needsreview
:jbake-status: published
:syntax: true
:description: APITest SIGTest NetBeans
:icons: font
:source-highlighter: pygments
:toc: left
You can use the Filesystems API freely in unit tests. For example:
[source, java]
private FileObject d;
protected void setUp() throws Exception {
d = FileUtil.toFileObject(getWorkDir());
If you try to run the above code, by default you will get an assertion error in setUp: `toFileObject` returns `null`.
This is because you need the "Master Filesystem module" available in order to translate Files into FileObjects.
Add to your `project.xml`:
[source, xml]
<!-- if not already there:
<!-- if not already there:
Changes made using the Filesystems API should fire change events synchronously, which is helpful for testing code which listens for file changes.