forked from phoedos/pmd
pmd-core: convert util/database to junit 4 tests, indentation fixes
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,6 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package net.sourceforge.pmd.util.database;
|
||||
|
||||
import java.io.File;
|
||||
@ -6,114 +9,116 @@ import java.io.PrintStream;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
import java.util.ResourceBundle;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sturton
|
||||
*/
|
||||
public class DBTypeTest extends TestCase {
|
||||
|
||||
private static String TEST_FILE_NAME ="/tmp/test.properties";
|
||||
public class DBTypeTest {
|
||||
|
||||
private File absoluteFile = new File(TEST_FILE_NAME);
|
||||
private static String TEST_FILE_NAME = "/tmp/test.properties";
|
||||
|
||||
private Properties testProperties;
|
||||
private Properties includeProperties;
|
||||
private File absoluteFile = new File(TEST_FILE_NAME);
|
||||
|
||||
public DBTypeTest(String testName) {
|
||||
super(testName);
|
||||
}
|
||||
private Properties testProperties;
|
||||
private Properties includeProperties;
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite(DBTypeTest.class);
|
||||
return suite;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
testProperties = new Properties();
|
||||
testProperties.put("prop1", "value1");
|
||||
testProperties.put("prop2", "value2");
|
||||
testProperties.put("prop3", "value3");
|
||||
|
||||
testProperties = new Properties();
|
||||
testProperties.put("prop1", "value1");
|
||||
testProperties.put("prop2", "value2");
|
||||
testProperties.put("prop3", "value3");
|
||||
includeProperties = new Properties();
|
||||
includeProperties.putAll(testProperties);
|
||||
includeProperties.put("prop3", "include3");
|
||||
|
||||
includeProperties = new Properties();
|
||||
includeProperties.putAll(testProperties);
|
||||
includeProperties.put("prop3", "include3");
|
||||
PrintStream printStream = null;
|
||||
try {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(absoluteFile);
|
||||
printStream = new PrintStream(fileOutputStream);
|
||||
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(absoluteFile);
|
||||
PrintStream printStream = new PrintStream(fileOutputStream);
|
||||
|
||||
for (Entry entry : testProperties.entrySet() )
|
||||
{
|
||||
printStream.printf("%s=%s\n", entry.getKey(), entry.getValue());
|
||||
for (Entry<?, ?> entry : testProperties.entrySet()) {
|
||||
printStream.printf("%s=%s\n", entry.getKey(), entry.getValue());
|
||||
}
|
||||
} finally {
|
||||
IOUtils.closeQuietly(printStream);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
testProperties = null;
|
||||
super.tearDown();
|
||||
}
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
testProperties = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getProperties method, of class DBType.
|
||||
*/
|
||||
public void testGetPropertiesFromFile() throws Exception {
|
||||
System.out.println("getPropertiesFromFile");
|
||||
DBType instance = new DBType("/tmp/test.properties");
|
||||
Properties expResult = testProperties;
|
||||
Properties result = instance.getProperties();
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
//fail("The test case is a prototype.");
|
||||
}
|
||||
/**
|
||||
* Test of getProperties method, of class DBType.
|
||||
*/
|
||||
@Test
|
||||
public void testGetPropertiesFromFile() throws Exception {
|
||||
System.out.println("getPropertiesFromFile");
|
||||
DBType instance = new DBType("/tmp/test.properties");
|
||||
Properties expResult = testProperties;
|
||||
Properties result = instance.getProperties();
|
||||
Assert.assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to
|
||||
// fail.
|
||||
// fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getProperties method, of class DBType.
|
||||
*/
|
||||
public void testGetProperties() throws Exception {
|
||||
System.out.println("testGetProperties");
|
||||
DBType instance = new DBType("test");
|
||||
Properties expResult = testProperties;
|
||||
System.out.println("testGetProperties: expected results "+ testProperties);
|
||||
Properties result = instance.getProperties();
|
||||
System.out.println("testGetProperties: actual results "+ result);
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
//fail("The test case is a prototype.");
|
||||
}
|
||||
/**
|
||||
* Test of getProperties method, of class DBType.
|
||||
*/
|
||||
@Test
|
||||
public void testGetProperties() throws Exception {
|
||||
System.out.println("testGetProperties");
|
||||
DBType instance = new DBType("test");
|
||||
Properties expResult = testProperties;
|
||||
System.out.println("testGetProperties: expected results " + testProperties);
|
||||
Properties result = instance.getProperties();
|
||||
System.out.println("testGetProperties: actual results " + result);
|
||||
Assert.assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to
|
||||
// fail.
|
||||
// fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getProperties method, of class DBType.
|
||||
*/
|
||||
public void testGetIncludeProperties() throws Exception {
|
||||
System.out.println("testGetIncludeProperties");
|
||||
DBType instance = new DBType("include");
|
||||
Properties expResult = includeProperties;
|
||||
System.out.println("testGetIncludeProperties: expected results "+ includeProperties);
|
||||
Properties result = instance.getProperties();
|
||||
System.out.println("testGetIncludeProperties: actual results "+ result);
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
//fail("The test case is a prototype.");
|
||||
}
|
||||
/**
|
||||
* Test of getProperties method, of class DBType.
|
||||
*/
|
||||
@Test
|
||||
public void testGetIncludeProperties() throws Exception {
|
||||
System.out.println("testGetIncludeProperties");
|
||||
DBType instance = new DBType("include");
|
||||
Properties expResult = includeProperties;
|
||||
System.out.println("testGetIncludeProperties: expected results " + includeProperties);
|
||||
Properties result = instance.getProperties();
|
||||
System.out.println("testGetIncludeProperties: actual results " + result);
|
||||
Assert.assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to
|
||||
// fail.
|
||||
// fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getResourceBundleAsProperties method, of class DBType.
|
||||
*/
|
||||
public void testAsProperties() {
|
||||
System.out.println("asProperties");
|
||||
ResourceBundle bundle = ResourceBundle.getBundle(DBType.class.getCanonicalName()+".test");
|
||||
Properties expResult = testProperties;
|
||||
Properties result = DBType.getResourceBundleAsProperties(bundle);
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
//fail("The test case is a prototype.");
|
||||
}
|
||||
/**
|
||||
* Test of getResourceBundleAsProperties method, of class DBType.
|
||||
*/
|
||||
@Test
|
||||
public void testAsProperties() {
|
||||
System.out.println("asProperties");
|
||||
ResourceBundle bundle = ResourceBundle.getBundle(DBType.class.getCanonicalName() + ".test");
|
||||
Properties expResult = testProperties;
|
||||
Properties result = DBType.getResourceBundleAsProperties(bundle);
|
||||
Assert.assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to
|
||||
// fail.
|
||||
// fail("The test case is a prototype.");
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,47 +1,33 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package net.sourceforge.pmd.util.database;
|
||||
|
||||
import java.io.InputStream;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sturton
|
||||
*/
|
||||
public class ResourceLoaderTest extends TestCase {
|
||||
|
||||
public ResourceLoaderTest(String testName) {
|
||||
super(testName);
|
||||
}
|
||||
public class ResourceLoaderTest {
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite(ResourceLoaderTest.class);
|
||||
return suite;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getResourceStream method, of class ResourceLoader.
|
||||
*/
|
||||
public void testGetResourceStream() throws Exception {
|
||||
System.out.println("getResourceStream");
|
||||
String path = "";
|
||||
ResourceLoader instance = new ResourceLoader();
|
||||
InputStream expResult = null;
|
||||
InputStream result = instance.getResourceStream(path);
|
||||
assertNotNull(result);
|
||||
//assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
//fail("The test case is a prototype.");
|
||||
}
|
||||
/**
|
||||
* Test of getResourceStream method, of class ResourceLoader.
|
||||
*/
|
||||
@Test
|
||||
public void testGetResourceStream() throws Exception {
|
||||
System.out.println("getResourceStream");
|
||||
String path = "";
|
||||
ResourceLoader instance = new ResourceLoader();
|
||||
InputStream expResult = null;
|
||||
InputStream result = instance.getResourceStream(path);
|
||||
Assert.assertNotNull(result);
|
||||
// assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to
|
||||
// fail.
|
||||
// fail("The test case is a prototype.");
|
||||
}
|
||||
}
|
||||
|
@ -1,47 +1,33 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package net.sourceforge.pmd.util.database;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sturton
|
||||
*/
|
||||
public class ResourceResolverTest extends TestCase {
|
||||
|
||||
public ResourceResolverTest(String testName) {
|
||||
super(testName);
|
||||
}
|
||||
public class ResourceResolverTest {
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite(ResourceResolverTest.class);
|
||||
return suite;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of resolve method, of class ResourceResolver.
|
||||
*/
|
||||
public void testResolve() throws Exception {
|
||||
System.out.println("resolve");
|
||||
String href = "";
|
||||
String base = "";
|
||||
ResourceResolver instance = new ResourceResolver();
|
||||
Source expResult = null;
|
||||
Source result = instance.resolve(href, base);
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
//fail("The test case is a prototype.");
|
||||
}
|
||||
/**
|
||||
* Test of resolve method, of class ResourceResolver.
|
||||
*/
|
||||
@Test
|
||||
public void testResolve() throws Exception {
|
||||
System.out.println("resolve");
|
||||
String href = "";
|
||||
String base = "";
|
||||
ResourceResolver instance = new ResourceResolver();
|
||||
Source expResult = null;
|
||||
Source result = instance.resolve(href, base);
|
||||
Assert.assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to
|
||||
// fail.
|
||||
// fail("The test case is a prototype.");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user