Skip to content

Fix: Automatically resolve 301 redirects in comp module tests (#266)#307

Open
dyrpsf wants to merge 2 commits intosbmlteam:masterfrom
dyrpsf:fix/comp-module-redirects
Open

Fix: Automatically resolve 301 redirects in comp module tests (#266)#307
dyrpsf wants to merge 2 commits intosbmlteam:masterfrom
dyrpsf:fix/comp-module-redirects

Conversation

@dyrpsf
Copy link
Copy Markdown
Contributor

@dyrpsf dyrpsf commented May 3, 2026

Fixes #266.

Problem

The comp module tests were failing due to WstxParsingException errors. This was caused by external resources (such as the Spec Example XML) returning 301 Moved Permanently status codes. Because Java's default URL.openStream() does not automatically follow redirects across protocol changes (e.g., HTTP to HTTPS), the parser was attempting to read the HTML redirection page instead of the actual SBML XML file.

Solution

  • Introduced a recursive openStreamWithRedirects(URL url) helper method in ExternalModelDefinition.java.
  • This logic explicitly inspects the HttpURLConnection status code and follows the Location header for 301, 302, 307, and 308 redirects.
  • Replaced the standard openStream() call with this new method to ensure robust fetching of external model definitions.

Testing

Ran mvn test in the extensions/comp directory. All 20 tests in TestExternalModelDefinition and TestModelDefinitionCloning now pass successfully with 0 errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Module Comp Failing It's Tests

1 participant