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.integration;
019
020import static java.lang.Integer.MAX_VALUE;
021import static java.lang.Integer.parseInt;
022import static org.slf4j.LoggerFactory.getLogger;
023
024import org.apache.http.auth.Credentials;
025import org.apache.http.auth.UsernamePasswordCredentials;
026import org.apache.http.client.HttpClient;
027import org.apache.http.impl.client.HttpClientBuilder;
028import org.junit.Before;
029import org.slf4j.Logger;
030
031/**
032 * Base class for ITs
033 * @author awoods
034 * @author escowles
035**/
036public abstract class AbstractResourceIT {
037
038    protected Logger logger;
039
040    public static final Credentials FEDORA_ADMIN_CREDENTIALS = new UsernamePasswordCredentials("fedoraAdmin",
041            "fedoraAdmin");
042
043    @Before
044    public void setLogger() {
045        logger = getLogger(this.getClass());
046    }
047
048    private static final int SERVER_PORT = parseInt(System.getProperty(
049            "fcrepo.dynamic.test.port", "8080"));
050
051    private static final String CONTEXT_PATH = System
052            .getProperty("fcrepo.test.context.path");
053
054    private static final String HOSTNAME = "localhost";
055
056    private static final String PROTOCOL = "http";
057
058    protected static final String serverAddress = PROTOCOL + "://" + HOSTNAME + ":" +
059            SERVER_PORT + CONTEXT_PATH + "rest/";
060
061    protected static final HttpClient client = createClient();
062
063    private static HttpClient createClient() {
064        return HttpClientBuilder.create().setMaxConnPerRoute(MAX_VALUE)
065                .setMaxConnTotal(MAX_VALUE).build();
066    }
067
068}