Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Created no-op integration test class.
Removed RBACL-based test class. Added license header, and move WebACRecipesIT into the correct package.
- Loading branch information
1 parent
79ac5ce
commit ac1bc9c
Showing
1 changed file
with
95 additions
and
0 deletions.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
src/test/java/org/fcrepo/integration/auth/webac/WebACRecipesIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/** | ||
* Copyright 2015 DuraSpace, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.fcrepo.integration.auth.webac; | ||
|
||
import static org.slf4j.LoggerFactory.getLogger; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.apache.commons.codec.binary.Base64; | ||
import org.apache.http.HttpResponse; | ||
import org.apache.http.client.ClientProtocolException; | ||
import org.apache.http.client.methods.HttpPost; | ||
import org.apache.http.entity.InputStreamEntity; | ||
import org.apache.http.impl.client.CloseableHttpClient; | ||
import org.apache.http.impl.client.HttpClientBuilder; | ||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.slf4j.Logger; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
|
||
/** | ||
* @author Peter Eichman | ||
* @since September 4, 2015 | ||
*/ | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@ContextConfiguration("/spring-test/test-container.xml") | ||
public class WebACRecipesIT { | ||
|
||
private static Logger logger = getLogger(WebACRecipesIT.class); | ||
|
||
protected static final int SERVER_PORT = Integer.parseInt(System.getProperty("fcrepo.dynamic.test.port", "8080")); | ||
|
||
protected static final String HOSTNAME = "localhost"; | ||
|
||
protected static final String serverAddress = "http://" + HOSTNAME + ":" + SERVER_PORT + "/rest/"; | ||
|
||
protected final PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); | ||
|
||
protected static CloseableHttpClient client; | ||
|
||
public WebACRecipesIT() { | ||
connectionManager.setMaxTotal(Integer.MAX_VALUE); | ||
connectionManager.setDefaultMaxPerRoute(20); | ||
connectionManager.closeIdleConnections(3, TimeUnit.SECONDS); | ||
client = HttpClientBuilder.create().setConnectionManager(connectionManager).build(); | ||
} | ||
|
||
@Before | ||
public void setUp() throws ClientProtocolException, IOException { | ||
// TODO: this should be factored out into a repeatable method to set up each scenario | ||
final HttpPost postRequest = new HttpPost(serverAddress); | ||
|
||
final String creds = "username:password"; | ||
// in test configuration we don't need real passwords | ||
final String encCreds = new String(Base64.encodeBase64(creds.getBytes())); | ||
final String basic = "Basic " + encCreds; | ||
postRequest.setHeader("Authorization", basic); | ||
|
||
final InputStream acl = this.getClass().getResourceAsStream("/acls/01/acl.ttl"); | ||
final InputStreamEntity acl_entity = new InputStreamEntity(acl); | ||
postRequest.setEntity(acl_entity); | ||
postRequest.setHeader("Content-Type", "text/turtle;charset=UTF-8"); | ||
|
||
// XXX: this is currently failing in the test repository with a | ||
// "java.lang.VerifyError: Bad type on operand stack" | ||
// see https://gist.github.com/peichman-umd/7f2eb8833ef8cd0cdfc1#gistcomment-1566271 | ||
final HttpResponse res = client.execute(postRequest); | ||
System.err.println(res.getStatusLine()); | ||
|
||
logger.debug("setup complete"); | ||
} | ||
|
||
@Test | ||
public void test() { | ||
} | ||
|
||
} |