[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-commons-dev
Subject: [commons-vfs] branch master updated: [VFS-783] Proper http scheme setting on webdav/webdav2 with uni
From: ggregory () apache ! org
Date: 2020-10-31 15:12:51
Message-ID: 160415717195.20137.9246842841688581467 () gitbox ! apache ! org
[Download RAW message or body]
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
The following commit(s) were added to refs/heads/master by this push:
new 8bbaed2 [VFS-783] Proper http scheme setting on webdav/webdav2 with unit \
tests #143. 8bbaed2 is described below
commit 8bbaed2c9c4c8cd8505f29907b54594e75e48e75
Author: Gary Gregory <garydgregory@gmail.com>
AuthorDate: Sat Oct 31 11:12:46 2020 -0400
[VFS-783] Proper http scheme setting on webdav/webdav2 with unit tests
#143.
As of git master today, https://github.com/apache/commons-vfs/pull/143
does not prove anything has been fixed:
- Add ONLY
`org.apache.commons.vfs2.provider.webdav4.Webdav4FileObject.getInternalURI()`
- Add `Webdav4FileObjectTest`. run it, and it passes.
Therefore, I've only committed these changes but with changes to
`Webdav4FileObjectTest` to add try-with-resources blocks.
---
.../vfs2/provider/webdav4/Webdav4FileObject.java | 8 +++
.../provider/webdav4/Webdav4FileObjectTest.java | 63 ++++++++++++++++++++++
2 files changed, 71 insertions(+)
diff --git a/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileObject.java \
b/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileObject.java
index 824c8a4..88c5a68 100644
--- a/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileObject.java
+++ b/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileObject.java
@@ -20,6 +20,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
+import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -78,6 +79,7 @@ import org.w3c.dom.Node;
* @since 2.5.0
*/
public class Webdav4FileObject extends Http4FileObject<Webdav4FileSystem> {
+
/**
* An OutputStream that writes to a Webdav resource.
* <p>
@@ -484,6 +486,12 @@ public class Webdav4FileObject extends \
Http4FileObject<Webdav4FileSystem> { return new Webdav4FileContentInfoFactory();
}
+ // Just for the unit test in the same package (package-private) to access this \
during validation. + @Override
+ protected URI getInternalURI() throws FileSystemException {
+ return super.getInternalURI();
+ }
+
DavPropertySet getProperties(final GenericURLFileName name) throws \
FileSystemException {
return getProperties(name, DavConstants.PROPFIND_ALL_PROP, new \
DavPropertyNameSet(), false); }
diff --git a/commons-vfs2-jackrabbit2/src/test/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileObjectTest.java \
b/commons-vfs2-jackrabbit2/src/test/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileObjectTest.java
new file mode 100644
index 0000000..c46b0af
--- /dev/null
+++ b/commons-vfs2-jackrabbit2/src/test/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileObjectTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs2.provider.webdav4;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+
+import org.apache.commons.vfs2.FileObject;
+import org.apache.commons.vfs2.FileSystemException;
+import org.apache.commons.vfs2.FileSystemManager;
+import org.apache.commons.vfs2.VFS;
+import org.junit.Test;
+
+public class Webdav4FileObjectTest {
+
+ private static final String WEBDAV4_URL = \
"webdav4://www.apache.org/licenses/LICENSE-2.0.txt"; + private static final String \
INTERNAL_WEBDAV4_URL = "http://www.apache.org/licenses/LICENSE-2.0.txt"; +
+ private static final String WEBDAV4S_URL = \
"webdav4s://www.apache.org/licenses/LICENSE-2.0.txt"; + private static final \
String INTERNAL_WEBDAV4S_URL = "https://www.apache.org/licenses/LICENSE-2.0.txt"; +
+ @Test
+ public void testWebdav4FileObjectURLs() throws FileSystemException {
+ final FileSystemManager fsm = VFS.getManager();
+ try (final FileObject file = fsm.resolveFile(WEBDAV4_URL)) {
+
+ assertEquals(WEBDAV4_URL, file.getURL().toString());
+ assertTrue(file instanceof Webdav4FileObject);
+
+ final Webdav4FileObject webdav4File = (Webdav4FileObject) file;
+ assertEquals(URI.create(INTERNAL_WEBDAV4_URL), \
webdav4File.getInternalURI()); + }
+ }
+
+ @Test
+ public void testWebdav4sFileObjectURLs() throws FileSystemException {
+ final FileSystemManager fsm = VFS.getManager();
+ try (final FileObject file = fsm.resolveFile(WEBDAV4S_URL)) {
+
+ assertEquals(WEBDAV4S_URL, file.getURL().toString());
+ assertTrue(file instanceof Webdav4FileObject);
+
+ final Webdav4FileObject webdav4File = (Webdav4FileObject) file;
+ assertEquals(URI.create(INTERNAL_WEBDAV4S_URL), \
webdav4File.getInternalURI()); + }
+ }
+}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic