001/* 002 * Licensed to DuraSpace under one or more contributor license agreements. 003 * See the NOTICE file distributed with this work for additional information 004 * regarding copyright ownership. 005 * 006 * DuraSpace licenses this file to you under the Apache License, 007 * Version 2.0 (the "License"); you may not use this file except in 008 * compliance with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.fcrepo.client.integration; 019 020import java.util.concurrent.TimeUnit; 021 022import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; 023import org.apache.jena.rdf.model.Model; 024import org.apache.jena.rdf.model.ModelFactory; 025import org.fcrepo.client.FcrepoClient; 026import org.fcrepo.client.FcrepoResponse; 027import org.junit.runner.RunWith; 028import org.springframework.test.context.ContextConfiguration; 029import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 030 031/** 032 * @author bbpennel 033 */ 034@RunWith(SpringJUnit4ClassRunner.class) 035@ContextConfiguration("/spring-test/test-container.xml") 036public abstract class AbstractResourceIT { 037 038 protected static final int SERVER_PORT = Integer.parseInt(System 039 .getProperty("fcrepo.dynamic.test.port", "8080")); 040 041 protected static final String HOSTNAME = "localhost"; 042 043 protected static final String serverAddress = "http://" + HOSTNAME + ":" + 044 SERVER_PORT + "/rest/"; 045 046 protected final PoolingHttpClientConnectionManager connectionManager = 047 new PoolingHttpClientConnectionManager(); 048 049 protected static FcrepoClient client; 050 051 protected AbstractResourceIT() { 052 connectionManager.setMaxTotal(Integer.MAX_VALUE); 053 connectionManager.setDefaultMaxPerRoute(20); 054 connectionManager.closeIdleConnections(3, TimeUnit.SECONDS); 055 } 056 057 protected Model getResponseModel(final FcrepoResponse resp) { 058 final Model model = ModelFactory.createDefaultModel(); 059 model.read(resp.getBody(), null, "text/turtle"); 060 return model; 061 } 062}