Skip to content

Commit 64c9f1f

Browse files
namedgraphclaude
andcommitted
Fix install-package-422 test to not depend on external packages.linkeddatahub.com
Use a local URL for the nonexistent package URI so the test doesn't fail when the external server is unreachable. Also catch NotFoundException and ProcessingException in getPackage() so any HTTP/connection failure reliably returns null and triggers the 422 response. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9835967 commit 64c9f1f

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

http-tests/admin/packages/install-package-422.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ curl -k -w "%{http_code}\n" -o /dev/null -s \
1313
-E "$OWNER_CERT_FILE":"$OWNER_CERT_PWD" \
1414
-X POST \
1515
-H "Content-Type: application/x-www-form-urlencoded" \
16-
--data-urlencode "package-uri=https://packages.linkeddatahub.com/nonexistent/#package" \
16+
--data-urlencode "package-uri=${END_USER_BASE_URL}static/nonexistent/#package" \
1717
"${ADMIN_BASE_URL}packages/install" \
1818
| grep -q "$STATUS_UNPROCESSABLE_ENTITY"

src/main/java/com/atomgraph/linkeddatahub/resource/admin/pkg/InstallPackage.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
import java.security.MessageDigest;
5656
import java.security.NoSuchAlgorithmException;
5757
import java.util.Optional;
58+
import jakarta.ws.rs.NotFoundException;
59+
import jakarta.ws.rs.ProcessingException;
5860
import org.apache.jena.ontology.ConversionException;
5961
import org.apache.jena.update.UpdateFactory;
6062
import org.apache.jena.update.UpdateRequest;
@@ -250,7 +252,18 @@ private com.atomgraph.linkeddatahub.apps.model.Package getPackage(String package
250252
else
251253
{
252254
GraphStoreClient gsc = GraphStoreClient.create(getSystem().getClient(), getSystem().getMediaTypes());
253-
model = gsc.getModel(packageURI);
255+
try
256+
{
257+
model = gsc.getModel(packageURI);
258+
}
259+
catch (NotFoundException ex) // 404 from the package server
260+
{
261+
return null;
262+
}
263+
catch (ProcessingException ex) // connection refused, timeout, etc.
264+
{
265+
return null;
266+
}
254267
}
255268

256269
try

0 commit comments

Comments
 (0)