rapture.repo.integration.PgUnversionedRepoTest.java Source code

Java tutorial

Introduction

Here is the source code for rapture.repo.integration.PgUnversionedRepoTest.java

Source

/**
 * Copyright (C) 2011-2015 Incapture Technologies LLC
 *
 * This is an autogenerated license statement. When copyright notices appear below
 * this one that copyright supercedes this statement.
 *
 * Unless required by applicable law or agreed to in writing, software is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied.
 *
 * Unless explicit permission obtained in writing this software cannot be distributed.
 */
package rapture.repo.integration;

import rapture.repo.UnversionedRepoTest;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.junit.AfterClass;
import org.junit.BeforeClass;

import rapture.config.MultiValueConfigLoader;

/**
 * @author bardhi
 * @since 4/6/15.
 */
public class PgUnversionedRepoTest extends UnversionedRepoTest {
    private static final Logger log = Logger.getLogger(PgUnversionedRepoTest.class);

    @BeforeClass
    public static void beforeClass() throws Exception {
        String cmd = "createdb " + getDbName();
        log.info(String.format("running [%s]", cmd));
        Runtime.getRuntime().exec(cmd.split(" "));
    }

    @AfterClass
    public static void afterClass() throws Exception {
        String cmd = "dropdb " + getDbName();
        log.info(String.format("running [%s]", cmd));
        Runtime.getRuntime().exec(cmd.split(" "));
    }

    public static String getDbName() {
        return "integration";
    }

    @Override
    protected String getConfig(String authority) {
        return String.format("REP {} USING POSTGRES { prefix=\"%s\" }", StringUtils.stripStart(authority, "/"));
    }

}