Path: blob/master/test/jdk/java/net/UnixDomainSocketAddress/AddressTest.java
41149 views
/*1* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 823135826* @compile ../../nio/file/spi/TestProvider.java AddressTest.java27* @run testng/othervm AddressTest28*/2930import java.net.UnixDomainSocketAddress;31import java.net.URI;32import java.nio.file.FileSystems;33import java.nio.file.spi.FileSystemProvider;34import java.nio.file.Path;3536import org.testng.annotations.Test;3738import static org.testng.Assert.assertThrows;3940/**41* Verify that UnixDomainSocketAddress.of(path) throws IAE42* if given a Path that does not originate from system default43* file system.44*/45public class AddressTest {4647// Expected exception48private static final Class<IllegalArgumentException> IAE =49IllegalArgumentException.class;5051@Test52public static void runTest() throws Exception {53TestProvider prov = new TestProvider(FileSystems.getDefault().provider());54Path path = prov.getPath(URI.create("file:/"));55assertThrows(IAE, () -> UnixDomainSocketAddress.of(path));56}57}585960