Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support to test the sparql recipes with both snapshot 4.0.0-beta-03 and snapshot 4.0.0-beta-04-SNAPSHOT. #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 40 additions & 11 deletions src/test/java/org/fcrepo/it/SparqlRecipesIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public class SparqlRecipesIT {

private static String CARGO_PORT = System.getProperty("cargo.port");

private static short FCREPO_SNAPSHOT_NUMBER = 4;
protected static String DATASTREAM_URL_SUFIX = "/fcr:metadata";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change protected to private ...for all data members in this class.

protected static String DATASTREAM_CONTENT_URL_SUFIX = "";

protected static HttpClient client = createClient();

protected static HttpClient createClient() {
Expand All @@ -54,8 +58,29 @@ protected static HttpClient createClient() {

@BeforeClass
public static void startFuseki() throws InterruptedException, IOException {
File commandFile = new File("target/jena-fuseki-1.0.1/fuseki-server");
ProcessBuilder b = new ProcessBuilder().inheritIO()

//Determine the snapshot used for testing and its REST api,
//make it default for snapshot 4 for the current version
final String fcrepoSnapshot = System.getProperty("fcrepo.version");
if (fcrepoSnapshot != null
&& fcrepoSnapshot.indexOf("-") > 0
&& fcrepoSnapshot.indexOf("4.0.0-beta") >= 0) {
final String[] verTokens = fcrepoSnapshot.split("-");
if (verTokens.length >= 3) {
try {
FCREPO_SNAPSHOT_NUMBER = Short.parseShort(verTokens[2]);
} catch (final NumberFormatException ne) {
FCREPO_SNAPSHOT_NUMBER = 4;
}
}
}
if (FCREPO_SNAPSHOT_NUMBER < 4) {
DATASTREAM_URL_SUFIX = "";
DATASTREAM_CONTENT_URL_SUFIX = "/fcr:content";
}

final File commandFile = new File("target/jena-fuseki-1.0.1/fuseki-server");
final ProcessBuilder b = new ProcessBuilder().inheritIO()
.directory(commandFile.getParentFile())
.command("./fuseki-server", "--update", "--mem", "/test" );
fuseki = b.start();
Expand Down Expand Up @@ -105,16 +130,20 @@ public static void setUpTestObjects() throws IOException, InterruptedException {
System.out.println("Adding test objects...");
putObject(pid101);
markAsIndexable(pid101);
putDummyDatastream(pid101 + "/master/fcr:content", "application/pdf");
putDummyDatastream(pid101 + "/master" + DATASTREAM_CONTENT_URL_SUFIX, "application/pdf");
markAsIndexable(pid101 + "/master" + DATASTREAM_URL_SUFIX);

putObject(pid102);
markAsIndexable(pid102);
putDummyDatastream(pid102 + "/master/fcr:content", "text/plain");
putDummyDatastream(pid102 + "/master" + DATASTREAM_CONTENT_URL_SUFIX, "text/plain");
markAsIndexable(pid102 + "/master" + DATASTREAM_URL_SUFIX);

putObject(pid103);
markAsIndexable(pid103);
putDummyDatastream(pid103 + "/master/fcr:content", "application/pdf");
putDummyDatastream(pid103 + "/text/fcr:content", "text/plain");
putDummyDatastream(pid103 + "/master" + DATASTREAM_CONTENT_URL_SUFIX, "application/pdf");
putDummyDatastream(pid103 + "/text" + DATASTREAM_CONTENT_URL_SUFIX, "text/plain");
markAsIndexable(pid103 + "/text" + DATASTREAM_URL_SUFIX);
markAsIndexable(pid103 + "/master" + DATASTREAM_URL_SUFIX);

putObject(pid201);
markAsIndexable(pid201);
Expand Down Expand Up @@ -158,7 +187,7 @@ public void testSparqlQueries1() throws IOException, InterruptedException {
"select ?object where { \n" +
" ?ds fcrepo:mixinTypes \"fedora:datastream\" .\n" +
" ?ds fcrepo:hasParent ?object . \n" +
" filter(str(?ds)=concat(str(?object),'/text')) \n" +
" filter(str(?ds)=concat(str(?object),'/text" + DATASTREAM_URL_SUFIX + "')) \n" +
"}";
final ByteArrayOutputStream response1b = new ByteArrayOutputStream();
queryFuseki(fusekiQuery1b).getEntity().writeTo(response1b);
Expand Down Expand Up @@ -324,11 +353,11 @@ private static class FusekiResponse {
final private List<List<String>> rows;

public FusekiResponse(final String csvResponse) {
String[] rowArray = csvResponse.split("\\n");
final String[] rowArray = csvResponse.split("\\n");
this.rows = new ArrayList<List<String>>();
for (String row : rowArray) {
ArrayList<String> rowList = new ArrayList<String>();
for (String cell : row.split(",")) {
for (final String row : rowArray) {
final ArrayList<String> rowList = new ArrayList<String>();
for (final String cell : row.split(",")) {
rowList.add(cell.trim());
}
this.rows.add(rowList);
Expand Down