/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 4313887 6838333
* @summary Unit test for java.nio.file.DirectoryStream
* @library ..
*/
public class Basic {
static boolean found;
// test that directory is empty
throw new RuntimeException("directory not empty");
}
// create file in directory
// iterate over directory and check there is one entry
found = false;
try {
if (found)
throw new RuntimeException("entry already found");
found = true;
} else {
" not expected");
}
}
} finally {
}
if (!found)
throw new RuntimeException("entry not found");
// check filtering: f* should match foo
private PathMatcher matcher =
}
};
throw new RuntimeException("entry not expected");
}
}
// check filtering: z* should not match any files
private PathMatcher matcher =
}
};
throw new RuntimeException("no matching entries expected");
}
// check that an IOException thrown by a filter is propagated
}
};
try {
throw new RuntimeException("DirectoryIteratorException expected");
} catch (DirectoryIteratorException x) {
throw new RuntimeException("Expected IOException not propagated");
} finally {
}
// check that exception or error thrown by filter is not thrown
// by newDirectoryStream or iterator method.
throw new RuntimeException("Should not be visible");
}
});
try {
} finally {
}
// test NotDirectoryException
try {
throw new RuntimeException("NotDirectoryException not thrown");
} catch (NotDirectoryException x) {
}
// test UnsupportedOperationException
i.next();
try {
i.remove();
throw new RuntimeException("UnsupportedOperationException expected");
} catch (UnsupportedOperationException uoe) {
}
// test IllegalStateException
try {
// attempt to obtain second iterator
throw new RuntimeException("IllegalStateException not thrown as expected");
} catch (IllegalStateException x) {
}
try {
// attempt to obtain iterator after stream is closed
throw new RuntimeException("IllegalStateException not thrown as expected");
} catch (IllegalStateException x) {
}
// test that iterator reads to end of stream when closed
while (i.hasNext())
i.next();
try {
for (;;) i.next();
} catch (NoSuchElementException expected) { }
}
try {
} finally {
}
}
}