@Test void attachmentJarURL() throws Exception { URL url = new URL(null, "attachmentjar: final AttachmentReference attachmentReference = new AttachmentReference("filename", new DocumentReference("wiki", "space", "page")); when(this.arf.resolve("Space.Page@filename")).thenReturn(attachmentReference); when(this.dab.getAttachmentContent(attachmentReference)) .thenReturn(new ByteArrayInputStream("content".getBytes())); URLConnection connection = url.openConnection(); InputStream input = null; try { connection.connect(); input = connection.getInputStream(); assertEquals("content", IOUtils.toString(input)); } finally { if (input != null) { input.close(); } } }
@Override protected URLConnection openConnection(URL url) throws IOException { AttachmentReference attachmentReference = this.attachmentReferenceResolver.resolve( getAttachmentReference(url)); return new AttachmentURLConnection(url, attachmentReference, this.documentAccessBridge); }
AttachmentURLStreamHandler extends URLStreamHandler implements ExtendedURLStreamHandler { @Override protected URLConnection openConnection(URL url) throws IOException { AttachmentReference attachmentReference = this.attachmentReferenceResolver.resolve( getAttachmentReference(url)); return new AttachmentURLConnection(url, attachmentReference, this.documentAccessBridge); } }
AttachmentURLStreamHandler extends URLStreamHandler implements ExtendedURLStreamHandler { @Override protected URLConnection openConnection(URL url) throws IOException { AttachmentReference attachmentReference = this.attachmentReferenceResolver.resolve( getAttachmentReference(url)); return new AttachmentURLConnection(url, attachmentReference, this.documentAccessBridge); }  }
AttachmentURLStreamHandler extends URLStreamHandler implements ExtendedURLStreamHandler { @Override protected URLConnection openConnection(URL url) throws IOException { AttachmentReference attachmentReference = this.attachmentReferenceResolver.resolve( getAttachmentReference(url)); return new AttachmentURLConnection(url, attachmentReference, this.documentAccessBridge); }  @Override String getProtocol(); }
AttachmentURLStreamHandler extends URLStreamHandler implements ExtendedURLStreamHandler { @Override protected URLConnection openConnection(URL url) throws IOException { AttachmentReference attachmentReference = this.attachmentReferenceResolver.resolve( getAttachmentReference(url)); return new AttachmentURLConnection(url, attachmentReference, this.documentAccessBridge); }  @Override String getProtocol();  }