USRE-76 add test case fo

This commit is contained in:
YuCheng Hu 2021-11-24 07:59:49 -05:00
parent e98c062137
commit f663ab8866
7 changed files with 136 additions and 33 deletions

View File

@ -4,10 +4,14 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="7c2295ed-8e00-4073-a402-bff68b86a0c3" name="Changes" comment="USRE-76 Add .gitignore for project">
<list default="true" id="7c2295ed-8e00-4073-a402-bff68b86a0c3" name="Changes" comment="USRE-76 re-compile and add logger">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/org/realtor/rets/validation/RETSUpdateValidator.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/org/realtor/rets/validation/RETSUpdateValidator.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/org/realtor/rets/validation/UpdateField.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/org/realtor/rets/validation/UpdateField.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/test/java/org/realtor/rets/validation/tests/DateIntervalTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/org/realtor/rets/validation/tests/DateIntervalTest.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/test/java/org/realtor/rets/validation/tests/ParserTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/org/realtor/rets/validation/tests/ParserTest.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/test/java/org/realtor/rets/validation/tests/RETSUpdateValidatorTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/org/realtor/rets/validation/tests/RETSUpdateValidatorTest.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/test/java/org/realtor/rets/validation/tests/TokenizerTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/org/realtor/rets/validation/tests/TokenizerTest.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst" beforeDir="false" afterPath="$PROJECT_DIR$/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -54,6 +58,28 @@
<recent name="org.realtor.rets.validation.tests" />
</key>
</component>
<component name="RunManager">
<configuration name="ParserTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="rets-io-validation" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="org.realtor.rets.validation.tests.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="org.realtor.rets.validation.tests" />
<option name="MAIN_CLASS_NAME" value="org.realtor.rets.validation.tests.ParserTest" />
<option name="TEST_OBJECT" value="class" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="JUnit.ParserTest" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
@ -62,7 +88,7 @@
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1637724413061</updated>
<workItem from="1637724415528" duration="5428000" />
<workItem from="1637724415528" duration="5744000" />
</task>
<task id="LOCAL-00001" summary="USRE-76 init repo and re-create project as maven project">
<created>1637725048156</created>
@ -99,7 +125,14 @@
<option name="project" value="LOCAL" />
<updated>1637758239444</updated>
</task>
<option name="localTasksCounter" value="6" />
<task id="LOCAL-00006" summary="USRE-76 re-compile and add logger">
<created>1637758455035</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1637758455035</updated>
</task>
<option name="localTasksCounter" value="7" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -122,6 +155,7 @@
<MESSAGE value="USRE-76 Add missing file for IJ" />
<MESSAGE value="USRE-76 Add missing file and add rets-io-common package" />
<MESSAGE value="USRE-76 Add .gitignore for project" />
<option name="LAST_COMMIT_MESSAGE" value="USRE-76 Add .gitignore for project" />
<MESSAGE value="USRE-76 re-compile and add logger" />
<option name="LAST_COMMIT_MESSAGE" value="USRE-76 re-compile and add logger" />
</component>
</project>

15
pom.xml
View File

@ -44,6 +44,21 @@
<artifactId>xalan</artifactId>
<version>2.7.2</version>
</dependency>
<!-- TESTS -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>

View File

@ -1,12 +1,13 @@
/* $Header: /usr/local/cvsroot/rets/validation/src/org/realtor/rets/validation/tests/DateIntervalTest.java,v 1.1.1.1 2003/11/21 16:20:05 rsegelman Exp $ */
package org.realtor.rets.validation.tests;
import junit.framework.TestCase;
import org.junit.jupiter.api.Test;
import org.realtor.rets.validation.terms.DateIntervalTerm;
import java.text.ParseException;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* DateIntervalTest.java Created Sep 18, 2003
@ -16,9 +17,10 @@ import java.text.ParseException;
* @version $Revision: 1.1.1.1 $
* @author scohen
*/
public class DateIntervalTest extends TestCase {
public class DateIntervalTest {
private DateIntervalTerm term;
@Test
public void testDays() throws ParseException {
term.setInterval("P15D");
assertEquals(new Integer(15), new Integer(term.getDays()));

View File

@ -1,7 +1,7 @@
/* $Header: /usr/local/cvsroot/rets/validation/src/org/realtor/rets/validation/tests/ParserTest.java,v 1.2 2003/12/04 15:28:33 rsegelman Exp $ */
package org.realtor.rets.validation.tests;
import junit.framework.TestCase;
import org.junit.jupiter.api.Test;
import org.realtor.rets.validation.ValidationExpressionEvaluator;
import org.realtor.rets.validation.terms.*;
@ -11,18 +11,22 @@ import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* ParserTest.java Created Sep 5, 2003
* ParserTest.java Created Sep 5, 2003
* <p>
* <p>
* Copyright 2003, Avantia inc.
*
*
* Copyright 2003, Avantia inc.
* @version $Revision: 1.2 $
* @author scohen
* @author scohen
* @version $Revision: 1.2 $
*/
public class ParserTest extends TestCase {
public class ParserTest {
private ValidationExpressionEvaluator evaluator;
@Test
public void testSingleTerm() {
NumericTerm rv = (NumericTerm) evaluateExpression("5");
@ -246,7 +250,7 @@ public class ParserTest extends TestCase {
try {
assertEquals(expr, new DateTerm("2002-09-15").getValue(),
term.getValue());
term.getValue());
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@ -284,11 +288,11 @@ public class ParserTest extends TestCase {
String expr = "(2003-09-15 + P1D)";
Term term = evaluateExpression(expr);
assertEquals(expr, new DateTerm("2003-09-16").getValue(),
term.getValue());
term.getValue());
expr = "(2003-09-15 - P1D)";
term = evaluateExpression(expr);
assertEquals(expr, new DateTerm("2003-09-14").getValue(),
term.getValue());
term.getValue());
}
public void testDateSubtraction() {
@ -327,7 +331,7 @@ public class ParserTest extends TestCase {
expr = "(2003-09-19 - P1D)";
term = evaluateExpression(expr);
assertEquals(expr, new DateTerm("2003-09-18").getValue(),
term.getValue());
term.getValue());
}
public void testComplexDateMath() throws Exception {

View File

@ -1,7 +1,7 @@
/* $Header: /usr/local/cvsroot/rets/validation/src/org/realtor/rets/validation/tests/RETSUpdateValidatorTest.java,v 1.1.1.1 2003/11/21 16:20:05 rsegelman Exp $ */
package org.realtor.rets.validation.tests;
import junit.framework.TestCase;
import org.junit.jupiter.api.Test;
import org.realtor.rets.util.XMLUtils;
import org.realtor.rets.validation.RETSUpdateValidator;
@ -19,6 +19,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* RETSUpdateValidatorTest.java Created Sep 26, 2003
@ -28,7 +30,7 @@ import java.util.Map;
* @version $Revision: 1.1.1.1 $
* @author scohen
*/
public class RETSUpdateValidatorTest extends TestCase {
public class RETSUpdateValidatorTest {
private static boolean setUp = false;
private static Document doc;
private static List list;

View File

@ -1,29 +1,34 @@
/* $Header: /usr/local/cvsroot/rets/validation/src/org/realtor/rets/validation/tests/TokenizerTest.java,v 1.1.1.1 2003/11/21 16:20:05 rsegelman Exp $ */
package org.realtor.rets.validation.tests;
import junit.framework.TestCase;
import org.junit.jupiter.api.Test;
import org.realtor.rets.validation.RetsTokenParser;
import org.realtor.rets.validation.operators.*;
import org.realtor.rets.validation.terms.*;
import java.text.ParseException;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
/**
* TokenizerTest.java Created Sep 10, 2003
* TokenizerTest.java Created Sep 10, 2003
* <p>
* <p>
* Copyright 2003, Avantia inc.
*
*
* Copyright 2003, Avantia inc.
* @version $Revision: 1.1.1.1 $
* @author scohen
* @author scohen
* @version $Revision: 1.1.1.1 $
*/
public class TokenizerTest extends TestCase {
public class TokenizerTest {
private RetsTokenParser tokenizer;
public TokenizerTest() {
}
@Test
public void testNullExpression() {
tokenizer.setExpression("");
assertNull(tokenizer.nextToken());
@ -195,7 +200,7 @@ public class TokenizerTest extends TestCase {
String expr = "P1M";
tokenizer.setExpression(expr);
assertEquals(expr, DateIntervalTerm.class,
tokenizer.nextToken().getClass());
tokenizer.nextToken().getClass());
}
public void testVariables() {
@ -234,14 +239,14 @@ public class TokenizerTest extends TestCase {
tokenizer.setExpression(expr);
assertCorrectOperator(tokenizer.nextToken(), new OpenParen());
assertEquals(((Term) tokenizer.nextToken()).getValue(),
new DateTerm("2003-09-18").getValue());
new DateTerm("2003-09-18").getValue());
assertCorrectOperator(tokenizer.nextToken(), new SubtractionOperator());
assertEquals(((Term) tokenizer.nextToken()).getValue(),
new DateIntervalTerm("P1D").getValue());
new DateIntervalTerm("P1D").getValue());
assertCorrectOperator(tokenizer.nextToken(), new CloseParen());
assertCorrectOperator(tokenizer.nextToken(), new GreaterThanOperator());
assertEquals(new DateTerm("2003-09-17").getValue(),
((DateTerm) tokenizer.nextToken()).getValue());
((DateTerm) tokenizer.nextToken()).getValue());
}
public void assertCorrectOperator(Object toTest, Operator expected) {

View File

@ -0,0 +1,41 @@
org\realtor\rets\validation\operators\SubtractionOperator.class
org\realtor\rets\validation\ParseTree.class
org\realtor\rets\validation\ValidationError.class
org\realtor\rets\validation\operators\EqualsOperator.class
org\realtor\rets\validation\UpdateField.class
org\realtor\rets\validation\terms\BooleanTerm.class
org\realtor\rets\validation\operators\ContainsOperator.class
org\realtor\rets\validation\operators\OpenParen.class
org\realtor\rets\validation\terms\InvalidTermException.class
org\realtor\rets\validation\OperatorMap.class
org\realtor\rets\validation\RetsTokenParser.class
org\realtor\rets\validation\ValidationExpressionEvaluator.class
org\realtor\rets\validation\terms\DateTerm.class
org\realtor\rets\validation\operators\ModOperator.class
org\realtor\rets\validation\terms\TermConverter.class
org\realtor\rets\validation\operators\NotOperator.class
org\realtor\rets\validation\operators\Parenthetical.class
org\realtor\rets\validation\operators\NotEqualsOperator.class
org\realtor\rets\validation\operators\Operator.class
org\realtor\rets\validation\operators\LogicOperator.class
org\realtor\rets\validation\terms\DateIntervalTerm.class
org\realtor\rets\validation\operators\LessThanOrEqualToOperator.class
org\realtor\rets\validation\operators\GreaterThanOrEqualToOperator.class
org\realtor\rets\validation\operators\DivisionOperator.class
org\realtor\rets\validation\terms\TermFactory.class
org\realtor\rets\validation\ValidationExpression.class
org\realtor\rets\validation\operators\ComparisonOperator.class
org\realtor\rets\validation\terms\StringTerm.class
org\realtor\rets\validation\RETSUpdateValidator.class
org\realtor\rets\validation\terms\NumericTerm.class
org\realtor\rets\validation\operators\MathematicOperator.class
org\realtor\rets\validation\operators\AdditionOperator.class
org\realtor\rets\validation\terms\Term.class
org\realtor\rets\validation\operators\AndOperator.class
org\realtor\rets\validation\terms\VariableTerm.class
org\realtor\rets\validation\operators\CloseParen.class
org\realtor\rets\validation\operators\OrOperator.class
org\realtor\rets\validation\terms\AbstractTerm.class
org\realtor\rets\validation\operators\MultiplicationOperator.class
org\realtor\rets\validation\operators\GreaterThanOperator.class
org\realtor\rets\validation\operators\LessThanOperator.class