Issue #3906 - Introducing Testcase to demonstrate issue
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
parent
6f9495f5c1
commit
24b2ca4c32
|
@ -0,0 +1,71 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.eclipse.jetty.util.resource;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.nio.channels.ReadableByteChannel;
|
||||||
|
import java.nio.file.FileSystem;
|
||||||
|
import java.nio.file.FileSystems;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
import static org.hamcrest.Matchers.not;
|
||||||
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
|
|
||||||
|
public class PathResourceTest
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testNonDefaultFileSystem_GetInputStream() throws URISyntaxException, IOException
|
||||||
|
{
|
||||||
|
Path exampleJar = MavenTestingUtils.getTestResourcePathFile("example.jar");
|
||||||
|
|
||||||
|
URI uri = new URI("jar", exampleJar.toUri().toASCIIString(), null);
|
||||||
|
System.err.println("URI = " + uri);
|
||||||
|
|
||||||
|
Map<String, Object> env = new HashMap<>();
|
||||||
|
env.put("multi-release", "runtime");
|
||||||
|
|
||||||
|
try (FileSystem zipfs = FileSystems.newFileSystem(uri, env))
|
||||||
|
{
|
||||||
|
Path manifestPath = zipfs.getPath("/META-INF/MANIFEST.MF");
|
||||||
|
assertThat(manifestPath, is(not(nullValue())));
|
||||||
|
|
||||||
|
PathResource resource = new PathResource(manifestPath);
|
||||||
|
|
||||||
|
try (ReadableByteChannel channel = resource.getReadableByteChannel())
|
||||||
|
{
|
||||||
|
assertThat("ReadableByteChannel", channel, is(not(nullValue())));
|
||||||
|
}
|
||||||
|
|
||||||
|
try (InputStream inputStream = resource.getInputStream())
|
||||||
|
{
|
||||||
|
assertThat("InputStream", inputStream, is(not(nullValue())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue