[java-shib-shared] 01/02: Fix up RepositorySupport to leverage a server redirect for unit tests.
Scott Cantor
cantor.2 at osu.edu
Sun Jul 6 17:37:44 UTC 2025
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch maint-9.1
in repository java-shib-shared.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=b54ceb18a0d2dc58584dbb832321f3ff09c0dae6
commit b54ceb18a0d2dc58584dbb832321f3ff09c0dae6
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Sun Jul 6 12:00:30 2025 -0400
Fix up RepositorySupport to leverage a server redirect for unit tests.
---
.../httpclient/resource/ConditionalResourceTest.java | 5 +++--
.../resource/FileBackedHTTPResourceTest.java | 4 ++--
.../spring/httpclient/resource/HTTPResourceTest.java | 18 +++++++++---------
.../spring/httpclient/resource/RepositorySupport.java | 7 ++-----
.../shibboleth/shared/testing/RepositorySupport.java | 8 ++------
.../shared/testing/RepositorySupportTest.java | 5 +++--
6 files changed, 21 insertions(+), 26 deletions(-)
diff --git a/shib-networking-spring/src/test/java/net/shibboleth/shared/spring/httpclient/resource/ConditionalResourceTest.java b/shib-networking-spring/src/test/java/net/shibboleth/shared/spring/httpclient/resource/ConditionalResourceTest.java
index 66af1545..af09c45c 100644
--- a/shib-networking-spring/src/test/java/net/shibboleth/shared/spring/httpclient/resource/ConditionalResourceTest.java
+++ b/shib-networking-spring/src/test/java/net/shibboleth/shared/spring/httpclient/resource/ConditionalResourceTest.java
@@ -51,7 +51,8 @@ public class ConditionalResourceTest {
client = (new HttpClientBuilder()).buildClient();
}
- @Test(enabled=RepositorySupport.ENABLE_GITWEB_TESTS) public void existsTest() throws IOException, ComponentInitializationException {
+ @Test public void existsTest() throws IOException, ComponentInitializationException {
+ System.out.println(existsURL);
final HTTPResource existsHTTPResource = new HTTPResource(client, existsURL);
final HTTPResource notExistsHTTPResource = new HTTPResource(client, nonExistsURL);
@@ -106,7 +107,7 @@ public class ConditionalResourceTest {
Assert.assertTrue(existsResource.exists());
}
- @Test(enabled=RepositorySupport.ENABLE_GITWEB_TESTS) public void testCompare() throws IOException, ComponentInitializationException {
+ @Test public void testCompare() throws IOException, ComponentInitializationException {
final HTTPResource existsHTTPResource = new HTTPResource(client, existsURL);
diff --git a/shib-networking-spring/src/test/java/net/shibboleth/shared/spring/httpclient/resource/FileBackedHTTPResourceTest.java b/shib-networking-spring/src/test/java/net/shibboleth/shared/spring/httpclient/resource/FileBackedHTTPResourceTest.java
index cd7f6311..e8d378fa 100644
--- a/shib-networking-spring/src/test/java/net/shibboleth/shared/spring/httpclient/resource/FileBackedHTTPResourceTest.java
+++ b/shib-networking-spring/src/test/java/net/shibboleth/shared/spring/httpclient/resource/FileBackedHTTPResourceTest.java
@@ -70,7 +70,7 @@ public class FileBackedHTTPResourceTest {
Assert.assertFalse(notExistsResource.exists());
}
- @Test(enabled=RepositorySupport.ENABLE_GITWEB_TESTS) public void testCompare() throws IOException {
+ @Test public void testCompare() throws IOException {
Assert.assertTrue(ResourceTestHelper.compare(new FileBackedHTTPResource(existsFile, client, existsURL),
new ClassPathResource(documentPath)));
// With that done compare via the backup
@@ -91,7 +91,7 @@ public class FileBackedHTTPResourceTest {
return builder.build();
}
- @Test(enabled=RepositorySupport.ENABLE_GITWEB_TESTS) public void testParsingNew() throws IOException {
+ @Test public void testParsingNew() throws IOException {
try (final GenericApplicationContext context = getContext("net/shibboleth/shared/spring/httpclient/resource/newStyle.xml")) {
diff --git a/shib-networking-spring/src/test/java/net/shibboleth/shared/spring/httpclient/resource/HTTPResourceTest.java b/shib-networking-spring/src/test/java/net/shibboleth/shared/spring/httpclient/resource/HTTPResourceTest.java
index dde07711..e370e1dc 100644
--- a/shib-networking-spring/src/test/java/net/shibboleth/shared/spring/httpclient/resource/HTTPResourceTest.java
+++ b/shib-networking-spring/src/test/java/net/shibboleth/shared/spring/httpclient/resource/HTTPResourceTest.java
@@ -60,7 +60,7 @@ public class HTTPResourceTest {
client = (new HttpClientBuilder()).buildClient();
}
- @Test(enabled=RepositorySupport.ENABLE_GITWEB_TESTS) public void existsTest() throws IOException {
+ @Test public void existsTest() throws IOException {
final HTTPResource existsResource = new HTTPResource(client, existsURL);
final HTTPResource notExistsResource = new HTTPResource(client, nonExistsURL);
@@ -68,7 +68,7 @@ public class HTTPResourceTest {
Assert.assertFalse(notExistsResource.exists());
}
- @Test(enabled=RepositorySupport.ENABLE_GITWEB_TESTS) public void contextHandlerNoopTest() throws IOException {
+ @Test public void contextHandlerNoopTest() throws IOException {
final HTTPResource existsResource = new HTTPResource(client, existsURL);
existsResource.setHttpClientContextHandler(new HttpClientContextHandler() {
public void invokeBefore(HttpClientContext context, ClassicHttpRequest request) throws IOException {
@@ -106,12 +106,12 @@ public class HTTPResourceTest {
Assert.assertFalse(existsResource.exists());
}
- @Test(enabled=RepositorySupport.ENABLE_GITWEB_TESTS) public void testCompare() throws IOException {
+ @Test public void testCompare() throws IOException {
Assert.assertTrue(ResourceTestHelper.compare(new HTTPResource(client, existsURL), new ClassPathResource(documentPath)));
}
- @Test(enabled=RepositorySupport.ENABLE_GITWEB_TESTS) public void testRelated() throws IOException {
+ @Test public void testRelated() throws IOException {
// Chose a file unlikely to change. Do not use the svn thing because the date will not be there
@@ -127,7 +127,7 @@ public class HTTPResourceTest {
Assert.assertEquals(size, 20784226L, "Size mismatch");
}
- @Test(enabled=RepositorySupport.ENABLE_GITWEB_TESTS) public void testCachedNoCache() throws IOException, InterruptedException {
+ @Test public void testCachedNoCache() throws IOException, InterruptedException {
final TestHTTPResource what = new TestHTTPResource(client, existsURL);
Assert.assertTrue(what.exists());
@@ -136,7 +136,7 @@ public class HTTPResourceTest {
Assert.assertNull(what.getLastCacheResponseStatus());
}
- @Test(enabled=RepositorySupport.ENABLE_GITWEB_TESTS) public void testCachedCache() throws Exception {
+ @Test public void testCachedCache() throws Exception {
final InMemoryCachingHttpClientBuilder builder = new InMemoryCachingHttpClientBuilder();
builder.setMaxCacheEntries(3);
@@ -165,7 +165,7 @@ public class HTTPResourceTest {
return context;
}
- @Test(enabled=RepositorySupport.ENABLE_GITWEB_TESTS) public void springLoadMemCache() throws IOException {
+ @Test public void springLoadMemCache() throws IOException {
final GenericApplicationContext context =
getContext("classpath:/net/shibboleth/shared/spring/httpclient/resource/MemBackedHTTPBean.xml", null);
@@ -199,7 +199,7 @@ public class HTTPResourceTest {
Assert.assertTrue(dir.delete());
}
- @Test(enabled=RepositorySupport.ENABLE_GITWEB_TESTS) public void springLoadFileCache() throws IOException {
+ @Test public void springLoadFileCache() throws IOException {
File theDir = null;
GenericApplicationContext context = null;
try {
@@ -229,7 +229,7 @@ public class HTTPResourceTest {
}
}
- @Test(timeOut = 5000, enabled=RepositorySupport.ENABLE_GITWEB_TESTS) public void testCloseResponse() {
+ @Test(timeOut = 5000) public void testCloseResponse() {
// See IDP-969. This test will timeout if the response is not closed.
try (final PoolingHttpClientConnectionManager connMgr = new PoolingHttpClientConnectionManager()) {
final HTTPResource notExistsResource = new HTTPResource(client, nonExistsURL);
diff --git a/shib-networking-spring/src/test/java/net/shibboleth/shared/spring/httpclient/resource/RepositorySupport.java b/shib-networking-spring/src/test/java/net/shibboleth/shared/spring/httpclient/resource/RepositorySupport.java
index e1e86379..5896c204 100644
--- a/shib-networking-spring/src/test/java/net/shibboleth/shared/spring/httpclient/resource/RepositorySupport.java
+++ b/shib-networking-spring/src/test/java/net/shibboleth/shared/spring/httpclient/resource/RepositorySupport.java
@@ -29,9 +29,6 @@ public final class RepositorySupport {
/** Constructor. */
private RepositorySupport() { }
-
- /** Temporarily suppress the gitweb tests until we have a long term fix. */
- public static final boolean ENABLE_GITWEB_TESTS = false;
/**
* Build an HTTPS resource URL for the selected repository name and path on the main branch.
@@ -84,9 +81,9 @@ public final class RepositorySupport {
}
if (https) {
- return String.format("https://git.shibboleth.net/view/?p=%s.git&a=blob_plain&f=%s&hb=%s", repo, path, branch);
+ return String.format("https://git.shibboleth.net/unittests/%s/%s/%s", repo, branch, path);
}
- return String.format("http://git.shibboleth.net/view/?p=%s.git&a=blob_plain&f=%s&hb=%s", repo, path, branch);
+ return String.format("http://git.shibboleth.net/unittests/%s/%s/%s", repo, branch, path);
}
}
\ No newline at end of file
diff --git a/shib-testing/src/main/java/net/shibboleth/shared/testing/RepositorySupport.java b/shib-testing/src/main/java/net/shibboleth/shared/testing/RepositorySupport.java
index af4bb646..f92859ce 100644
--- a/shib-testing/src/main/java/net/shibboleth/shared/testing/RepositorySupport.java
+++ b/shib-testing/src/main/java/net/shibboleth/shared/testing/RepositorySupport.java
@@ -29,9 +29,6 @@ public final class RepositorySupport {
/** Constructor. */
private RepositorySupport() { }
-
- /** Temporarily suppress the gitweb tests until we have a long term fix. */
- public static final boolean ENABLE_GITWEB_TESTS = false;
/**
@@ -86,10 +83,9 @@ public final class RepositorySupport {
}
if (https) {
- return String.format("https://test.shibboleth.net/git/view/?p=%s.git&a=blob_plain&f=%s&hb=%s",
- repo, path, branch);
+ return String.format("https://test.shibboleth.net/unittests/%s/%s/%s", repo, branch, path);
}
- return String.format("http://git.shibboleth.net/view/?p=%s.git&a=blob_plain&f=%s&hb=%s", repo, path, branch);
+ return String.format("http://git.shibboleth.net/unittests/%s/%s/%s", repo, branch, path);
}
}
\ No newline at end of file
diff --git a/shib-testing/src/test/java/net/shibboleth/shared/testing/RepositorySupportTest.java b/shib-testing/src/test/java/net/shibboleth/shared/testing/RepositorySupportTest.java
index 19700d75..ebd1ccf4 100644
--- a/shib-testing/src/test/java/net/shibboleth/shared/testing/RepositorySupportTest.java
+++ b/shib-testing/src/test/java/net/shibboleth/shared/testing/RepositorySupportTest.java
@@ -7,9 +7,10 @@ import java.net.URL;
import org.testng.Assert;
import org.testng.annotations.Test;
+ at SuppressWarnings("javadoc")
public class RepositorySupportTest {
- @Test(enabled=RepositorySupport.ENABLE_GITWEB_TESTS)
+ @Test
public void testBuildHTTPResourceURLTest() throws IOException {
final String s = RepositorySupport.buildHTTPResourceURL("java-support",
"src/test/java/net/shibboleth/utilities/java/support/test/repository/RepositorySupport.java", false);
@@ -18,7 +19,7 @@ public class RepositorySupportTest {
Assert.assertNotNull(u.getContent());
}
- @Test(enabled=RepositorySupport.ENABLE_GITWEB_TESTS)
+ @Test
public void testBuildHTTPSResourceURLTest() throws IOException {
final String s = RepositorySupport.buildHTTPSResourceURL("java-support",
"src/test/java/net/shibboleth/utilities/java/support/test/repository/RepositorySupport.java");
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list