
net.sourceforge.tink.model.test.Helper Maven / Gradle / Ivy
/**
* Copyright 2008,2009 Ivan SZKIBA
*
* 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.
* under the License.
*/
package net.sourceforge.tink.model.test;
import net.sourceforge.tink.model.Output;
import net.sourceforge.tink.model.helpers.ConsoleOutput;
import java.io.File;
public class Helper
{
public static final String PROP_WORK_DIR = "test.work.directory";
public static final String PROP_RESOURCE_DIR = "test.resource.directory";
public static final String DEFAULT_WORK_DIR = "target/test";
public static final String DEFAULT_RESOURCE_DIR = "src/test/resources";
private Output output;
private File resourceDir;
private File resourceDirBase;
private File workDir;
private File workDirBase;
public Helper(String module) throws Exception
{
setWorkDirBase(getDir(PROP_WORK_DIR, DEFAULT_WORK_DIR));
setResourceDirBase(getDir(PROP_RESOURCE_DIR, DEFAULT_RESOURCE_DIR));
setOutput(new ConsoleOutput());
setWorkDir(new File(getWorkDirBase(), module));
setResourceDir(new File(getResourceDirBase(), module));
}
public Output getOutput()
{
return output;
}
public void setOutput(Output value)
{
this.output = value;
}
public File getResourceDir()
{
return resourceDir;
}
public void setResourceDir(File value)
{
resourceDir = value;
}
public File getResourceDirBase()
{
return resourceDirBase;
}
public void setResourceDirBase(File resourceDirBase)
{
this.resourceDirBase = resourceDirBase;
}
public File getWorkDir()
{
return workDir;
}
public void setWorkDir(File value)
{
workDir = value;
}
public File getWorkDirBase()
{
return workDirBase;
}
public void setWorkDirBase(File workDirBase)
{
this.workDirBase = workDirBase;
}
public void init() throws Exception
{
if (!getWorkDirBase().exists())
{
getWorkDirBase().mkdir();
}
if (!getWorkDir().exists())
{
getWorkDir().mkdir();
}
}
protected File getDir(String propertyName, String defaultValue)
{
return new File((System.getProperty(propertyName) == null) ? defaultValue : System.getProperty(propertyName));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy