Advertisement
Guest User

Untitled

a guest
Feb 24th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1.     @Test
  2.     public void shouldBeAbleToImportFromUrl() {
  3.  
  4.         final String targetURL = "https://repository.jboss.org/nexus/content/groups/public/org/jboss/shrinkwrap/shrinkwrap-api/1.2.2/shrinkwrap-api-1.2.2.jar";
  5.  
  6.         final URL url;
  7.         try {
  8.             url = new URL(targetURL);
  9.         } catch (final MalformedURLException murle) {
  10.             throw new RuntimeException(murle);
  11.         }
  12.         final InputStream remoteContents;
  13.         try {
  14.             remoteContents = url.openStream();
  15.         } catch (final IOException ioe) {
  16.             throw new RuntimeException(ioe);
  17.         }
  18.  
  19.         // Represent as SW
  20.         final JavaArchive archive = ShrinkWrap.create(ZipImporter.class).importFrom(remoteContents).as(JavaArchive.class);
  21.  
  22.         // Print out
  23.         System.out.println(archive.toString(true));
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement