Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
Using CND file to specify namespace instead of (now-removed) fcr:node…
Browse files Browse the repository at this point in the history
…yptes rest api
  • Loading branch information
escowles committed Oct 17, 2014
1 parent b59507d commit b54da71
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 63 deletions.
Expand Up @@ -18,29 +18,18 @@
import static java.lang.Integer.MAX_VALUE;
import static java.lang.Integer.parseInt;
import static java.lang.System.getProperty;
import static java.nio.charset.Charset.defaultCharset;
import static org.slf4j.LoggerFactory.getLogger;

import java.io.File;
import java.io.IOException;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.junit.Before;

import static org.apache.http.HttpStatus.SC_NO_CONTENT;
import static org.fcrepo.indexer.IndexerGroup.INDEXER_NAMESPACE;
import static org.junit.Assert.assertEquals;
import org.slf4j.Logger;

import com.google.common.io.Files;

/**
* @author ajs6f
*/
Expand All @@ -56,62 +45,12 @@ public abstract class IndexingIT {

protected static HttpClient client;

public static final String INDEXER_TEST_NAMESPACE =
"http://fedora.info/definitions/v4/indexingtest#";


@Before
public void setUp() throws ClientProtocolException, IOException {
final PoolingClientConnectionManager connMann =
new PoolingClientConnectionManager();
connMann.setMaxTotal(MAX_VALUE);
connMann.setDefaultMaxPerRoute(MAX_VALUE);
client = new DefaultHttpClient(connMann);
LOGGER.debug("Installing indexing namespace...");
final String nsSparqlUpdate =
"INSERT { <" + INDEXER_NAMESPACE + "> <http://purl.org/vocab/vann/preferredNamespacePrefix> " +
"\"indexing\"." +
"<" + INDEXER_TEST_NAMESPACE + "> <http://purl.org/vocab/vann/preferredNamespacePrefix> " +
"\"indexingtest\"} WHERE { }";
HttpPost update = new HttpPost(serverAddress + "fcr:namespaces");
update.setEntity(new StringEntity(nsSparqlUpdate));
update.setHeader("Content-Type", "application/sparql-update");
HttpResponse response = client.execute(update);
assertEquals("Failed to install indexing namespace!",
SC_NO_CONTENT, response.getStatusLine().getStatusCode());

LOGGER.debug("Installing indexing type information...");
update = new HttpPost(serverAddress + "fcr:nodetypes");
update.setHeader("Content-Type", "text/cnd");
HttpEntity cnd =
new StringEntity(Files.toString(new File(
"target/classes/indexing.cnd"), defaultCharset()));
update.setEntity(cnd);
response = client.execute(update);
assertEquals("Failed to install indexing type information!",
SC_NO_CONTENT, response.getStatusLine().getStatusCode());

LOGGER.debug("Installing indexing test type information...");
update = new HttpPost(serverAddress + "fcr:nodetypes");
update.setHeader("Content-Type", "text/cnd");
cnd =
new StringEntity(Files.toString(new File(
"target/test-classes/indexingtest.cnd"), defaultCharset()));
update.setEntity(cnd);
response = client.execute(update);
assertEquals("Failed to install indexing test type information!",
SC_NO_CONTENT, response.getStatusLine().getStatusCode());
/*HttpGet nsRequest = new HttpGet(serverAddress + "fcr:namespaces");
nsRequest.setHeader("Content-Type", WebContent.contentTypeN3Alt1);
LOGGER.debug("Now registered namespaces include:\n{}", IOUtils
.toString(client.execute(nsRequest).getEntity().getContent()));
nsRequest = new HttpGet(serverAddress + "fcr:nodetypes");
nsRequest.setHeader("Content-Type", WebContent.contentTypeN3Alt1);
LOGGER.debug("and registered node types:\n{}", IOUtils.toString(client
.execute(nsRequest).getEntity().getContent()));*/

}



}
Expand Up @@ -15,5 +15,5 @@
{ "classname" : "org.fcrepo.auth.common.BypassSecurityServletAuthenticationProvider" }
]
},
"node-types" : ["fedora-node-types.cnd"]
}
"node-types" : ["fedora-node-types.cnd","indexingtest.cnd"]
}

0 comments on commit b54da71

Please sign in to comment.