|
Struts example source code file (UrlUtilTest2.java)
The Struts UrlUtilTest2.java source codepackage com.opensymphony.xwork2.util; import junit.framework.TestCase; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.jar.JarInputStream; /** * Keep these test on a separate class, they can't be in UrlUtilTest because the * registered URLStreamHandlerFactory would make them fail */ public class UrlUtilTest2 extends TestCase { public void testOpenWithJarProtocol() throws IOException { URL url = ClassLoaderUtil.getResource("xwork-jar.jar", URLUtil.class); URL jarUrl = new URL("jar", "", url.toExternalForm() + "!/"); URL outputURL = URLUtil.normalizeToFileProtocol(jarUrl); assertNotNull(outputURL); assertUrlCanBeOpened(outputURL); } private void assertUrlCanBeOpened(URL url) throws IOException { InputStream is = url.openStream(); JarInputStream jarStream = null; try { jarStream = new JarInputStream(is); assertNotNull(jarStream); } finally { if (jarStream != null) jarStream.close(); } } } Other Struts examples (source code examples)Here is a short list of links related to this Struts UrlUtilTest2.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.