Not required

This commit is contained in:
Oliver Burn 2002-12-01 05:20:33 +00:00
parent d98c96c4dd
commit 6a30bbf329
4 changed files with 0 additions and 190 deletions

View File

@ -21,14 +21,11 @@ public class AllTests {
suite.addTest(new TestSuite(AvoidStarImportTest.class));
suite.addTest(new TestSuite(ConfigurationLoaderTest.class));
suite.addTest(new TestSuite(ConfigurationSerializationTest.class));
suite.addTest(new TestSuite(ConfigurationTest.class));
suite.addTest(new TestSuite(ConstantNameCheckTest.class));
suite.addTest(new TestSuite(EmptyBlockCheckTest.class));
suite.addTest(new TestSuite(EqualsHashCodeCheckTest.class));
suite.addTest(new TestSuite(FileLengthCheckTest.class));
suite.addTest(new TestSuite(GenericIllegalRegexpCheckTest.class));
suite.addTest(new TestSuite(GlobalPropertiesSerializationTest.class));
suite.addTest(new TestSuite(GlobalPropertiesTest.class));
suite.addTest(new TestSuite(HeaderCheckTest.class));
suite.addTest(new TestSuite(HiddenFieldCheckTest.class));
suite.addTest(new TestSuite(IllegalImportCheckTest.class));

View File

@ -1,96 +0,0 @@
package com.puppycrawl.tools.checkstyle;
import junit.framework.TestCase;
import java.util.Locale;
import java.util.Properties;
public class ConfigurationTest
extends TestCase
{
private final String BASEDIR = "basedir";
private final String CACHE_FILE = "cache_file";
private final int TAB_WIDTH = 8;
private Properties mProps = null;
private GlobalProperties mGlobalProps = null;
private Configuration mConfig = null;
public void setUp()
throws Exception
{
mProps = new Properties();
mProps.setProperty(Defn.BASEDIR_PROP, BASEDIR);
mProps.setProperty(Defn.CACHE_FILE_PROP, CACHE_FILE);
mProps.setProperty(Defn.TAB_WIDTH_PROP, "" + TAB_WIDTH);
mGlobalProps = new GlobalProperties(mProps, System.out);
mConfig = new Configuration(mGlobalProps, new CheckConfiguration[0]);
mConfig.setClassLoader(this.getClass().getClassLoader());
}
public void testConstructor() throws Exception
{
assertNotNull(mConfig);
}
public void testEmptyProperties()
throws Exception
{
Properties props = new Properties();
GlobalProperties globalProps = new GlobalProperties(props, System.out);
Configuration config =
new Configuration(globalProps, new CheckConfiguration[0]);
Properties defaultProps = config.getProperties();
assertEquals(3, defaultProps.size());
}
public void testGetCacheFile()
{
assertEquals(CACHE_FILE, mConfig.getCacheFile());
}
public void testGetClassLoader()
{
assertEquals(this.getClass().getClassLoader(),
mConfig.getClassLoader());
}
public void testGetLocaleCountry()
{
assertEquals(Locale.getDefault().getCountry(),
mConfig.getLocaleCountry());
}
public void testGetLocaleLanguage()
{
assertEquals(Locale.getDefault().getLanguage(),
mConfig.getLocaleLanguage());
}
public void testGetProperties()
{
Properties props = mConfig.getProperties();
int expectedSize = Defn.ALL_STRING_PROPS.length
+ Defn.ALL_INT_PROPS.length;
assertEquals("size", expectedSize, props.size());
for (int i = 0; i < Defn.ALL_INT_PROPS.length; i++) {
final String key = Defn.ALL_INT_PROPS[i];
assertTrue("Missing property: " + key,
props.containsKey(key));
}
for (int i = 0; i < Defn.ALL_STRING_PROPS.length; i++) {
final String key = Defn.ALL_STRING_PROPS[i];
assertTrue("Missing property: " + key,
props.containsKey(key));
}
}
public void testGetTabWidth()
{
assertEquals(TAB_WIDTH, mConfig.getTabWidth());
}
}

View File

@ -1,68 +0,0 @@
package com.puppycrawl.tools.checkstyle;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.IOException;
import java.lang.reflect.Method;
import junit.framework.TestCase;
import org.apache.regexp.RE;
public class GlobalPropertiesSerializationTest
extends TestCase
{
/**
* Copy mConfig using in-memory serialization
* @param aConfig the original
* @return a copy of aConfig obtained by in-memory serialization
*/
private GlobalProperties copyBySerialization(GlobalProperties aConfig)
throws IOException, ClassNotFoundException
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(aConfig);
oos.flush();
oos.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
GlobalProperties configCopy = (GlobalProperties) ois.readObject();
ois.close();
return configCopy;
}
/**
* Tests that all RE fields are restored during deserialization.
* This test is designed to prevent addition of transient RE
* fields to GlobalProperties without modification of
* GlobalProperties.readObject().
*/
public void testAllRegexpsNotNull()
throws Exception
{
GlobalProperties configOrig = new GlobalProperties();
GlobalProperties configCopy = copyBySerialization(configOrig);
assertNotNull(configCopy);
// ensure that none of the getSomeRE() methods (even the ones
// we don't know yet) of the configCopy returns null
Method[] configMethods = GlobalProperties.class.getMethods();
for (int i = 0; i < configMethods.length; i++)
{
Method method = configMethods[i];
String methodName = method.getName();
if (methodName.startsWith("get") &&
method.getReturnType().equals(RE.class) &&
method.getParameterTypes().length == 0)
{
Object[] noArgs = {};
Object obj = method.invoke(configCopy, noArgs);
assertNotNull(methodName + "() returned null", obj);
}
}
}
}

View File

@ -1,23 +0,0 @@
package com.puppycrawl.tools.checkstyle;
import junit.framework.TestCase;
import java.util.Properties;
public class GlobalPropertiesTest
extends TestCase
{
public void test1() throws Exception
{
final Properties p = new Properties();
final GlobalProperties c = new GlobalProperties(p, System.out);
assertNotNull(c);
}
public void test2() throws Exception
{
final Properties p = new Properties();
final GlobalProperties c = new GlobalProperties(p, System.out);
assertNotNull(c);
}
}