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;
027
028/**
029 * @author bbpennel
030 */
031public abstract class AbstractResourceIT {
032
033    protected static final int SERVER_PORT = Integer.parseInt(System
034            .getProperty("fcrepo.dynamic.test.port", "8080"));
035
036    protected static final String HOSTNAME = "localhost";
037
038    protected static final String serverAddress = "http://" + HOSTNAME + ":" +
039            SERVER_PORT + "/fcrepo/rest/";
040
041    protected final PoolingHttpClientConnectionManager connectionManager =
042            new PoolingHttpClientConnectionManager();
043
044    protected static FcrepoClient client;
045
046    protected AbstractResourceIT() {
047        connectionManager.setMaxTotal(Integer.MAX_VALUE);
048        connectionManager.setDefaultMaxPerRoute(20);
049        connectionManager.closeIdleConnections(3, TimeUnit.SECONDS);
050    }
051
052    protected Model getResponseModel(final FcrepoResponse resp) {
053        final Model model = ModelFactory.createDefaultModel();
054        model.read(resp.getBody(), null, "text/turtle");
055        return model;
056    }
057}