Skip to content

Commit

Permalink
GH-5041 register glassfish implementation of Jakarta JSON with SPI
Browse files Browse the repository at this point in the history
  • Loading branch information
hmottestad committed Jun 20, 2024
1 parent 4554510 commit 81d2d78
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.glassfish.json.JsonProviderImpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
import static org.eclipse.rdf4j.rio.helpers.JSONLDSettings.SECURE_MODE;
import static org.eclipse.rdf4j.rio.helpers.JSONLDSettings.WHITELIST;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.commons.io.FileUtils;
import org.eclipse.rdf4j.model.IRI;
Expand All @@ -44,6 +48,7 @@
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Test;

import jakarta.json.spi.JsonProvider;
import no.hasmac.jsonld.document.Document;
import no.hasmac.jsonld.document.JsonDocument;

Expand Down Expand Up @@ -354,4 +359,15 @@ public void testRemoteContextException() throws Exception {
assertEquals("Could not load document from https://example.org/context.jsonld", rdfParseException.getMessage());
}

@Test
public void testSPI() {
ServiceLoader<JsonProvider> load = ServiceLoader.load(JsonProvider.class);
List<String> collect = load.stream()
.map(ServiceLoader.Provider::get)
.map(t -> t.getClass().getName())
.collect(Collectors.toList());
assertFalse(collect.isEmpty());
assertEquals("org.glassfish.json.JsonProviderImpl", collect.stream().findFirst().orElse(""));
}

}

0 comments on commit 81d2d78

Please sign in to comment.