|
From: <th...@us...> - 2008-12-31 23:46:39
|
Revision: 8766
http://pcgen.svn.sourceforge.net/pcgen/?rev=8766&view=rev
Author: thpr
Date: 2008-12-31 23:46:35 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
Kit Token Tests, part 1
Added Paths:
-----------
Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/
Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/
Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/ClassTokenTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/CountTokenTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/FreeTokenTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/RankTokenTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/SelectionTokenTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/SkillTokenTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/spells/
Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/spells/CountTokenTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/spells/SpellsTokenTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/startpack/
Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/startpack/ApplyTokenTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/startpack/EquipBuyTokenTest.java
Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/startpack/VisibleTokenTest.java
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/ClassTokenTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/ClassTokenTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/ClassTokenTest.java 2008-12-31 23:46:35 UTC (rev 8766)
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens.kit.skill;
+
+import org.junit.Test;
+
+import pcgen.core.PCClass;
+import pcgen.core.kit.KitSkill;
+import pcgen.persistence.PersistenceLayerException;
+import pcgen.rules.persistence.CDOMSubLineLoader;
+import pcgen.rules.persistence.token.CDOMSecondaryToken;
+import plugin.lsttokens.testsupport.AbstractSubTokenTestCase;
+
+public class ClassTokenTest extends AbstractSubTokenTestCase<KitSkill>
+{
+
+ static ClassToken token = new ClassToken();
+ static CDOMSubLineLoader<KitSkill> loader = new CDOMSubLineLoader<KitSkill>(
+ "*KITTOKEN", "SKILL", KitSkill.class);
+
+ @Override
+ public Class<KitSkill> getCDOMClass()
+ {
+ return KitSkill.class;
+ }
+
+ @Override
+ public CDOMSubLineLoader<KitSkill> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMSecondaryToken<KitSkill> getToken()
+ {
+ return token;
+ }
+
+ @Test
+ public void testInvalidInputEmptyCount() throws PersistenceLayerException
+ {
+ assertTrue(parse("Fireball"));
+ assertFalse(primaryContext.ref.validate());
+ }
+
+ @Test
+ public void testInvalidInputOnlyOne() throws PersistenceLayerException
+ {
+ primaryContext.ref.constructCDOMObject(PCClass.class, "Fireball");
+ secondaryContext.ref.constructCDOMObject(PCClass.class, "Fireball");
+ primaryContext.ref.constructCDOMObject(PCClass.class, "English");
+ secondaryContext.ref.constructCDOMObject(PCClass.class, "English");
+ assertTrue(parse("Fireball,English"));
+ assertFalse(primaryContext.ref.validate());
+ }
+
+ @Test
+ public void testRoundRobinSimple() throws PersistenceLayerException
+ {
+ primaryContext.ref.constructCDOMObject(PCClass.class, "Fireball");
+ secondaryContext.ref.constructCDOMObject(PCClass.class, "Fireball");
+ runRoundRobin("Fireball");
+ }
+}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/CountTokenTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/CountTokenTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/CountTokenTest.java 2008-12-31 23:46:35 UTC (rev 8766)
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens.kit.skill;
+
+import org.junit.Test;
+
+import pcgen.core.kit.KitSkill;
+import pcgen.persistence.PersistenceLayerException;
+import pcgen.rules.persistence.CDOMSubLineLoader;
+import pcgen.rules.persistence.token.CDOMSecondaryToken;
+import plugin.lsttokens.testsupport.AbstractSubTokenTestCase;
+
+public class CountTokenTest extends AbstractSubTokenTestCase<KitSkill>
+{
+
+ static CountToken token = new CountToken();
+ static CDOMSubLineLoader<KitSkill> loader = new CDOMSubLineLoader<KitSkill>(
+ "*KITTOKEN", "SPELLS", KitSkill.class);
+
+ @Override
+ public Class<KitSkill> getCDOMClass()
+ {
+ return KitSkill.class;
+ }
+
+ @Override
+ public CDOMSubLineLoader<KitSkill> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMSecondaryToken<KitSkill> getToken()
+ {
+ return token;
+ }
+
+ @Test
+ public void testRoundRobinNumber() throws PersistenceLayerException
+ {
+ runRoundRobin("3");
+ }
+
+ @Test
+ public void testInvalidInputFormula() throws PersistenceLayerException
+ {
+ assertFalse(parse("FormulaProhibited"));
+ }
+
+ @Test
+ public void testInvalidInputZero() throws PersistenceLayerException
+ {
+ assertFalse(parse("0"));
+ }
+
+ @Test
+ public void testInvalidInputNegative() throws PersistenceLayerException
+ {
+ assertFalse(parse("-1"));
+ }
+
+ @Test
+ public void testInvalidInputDecimal() throws PersistenceLayerException
+ {
+ assertFalse(parse("1.5"));
+ }
+
+}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/FreeTokenTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/FreeTokenTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/FreeTokenTest.java 2008-12-31 23:46:35 UTC (rev 8766)
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens.kit.skill;
+
+import org.junit.Test;
+
+import pcgen.core.kit.KitSkill;
+import pcgen.persistence.PersistenceLayerException;
+import pcgen.rules.persistence.CDOMSubLineLoader;
+import pcgen.rules.persistence.token.CDOMSecondaryToken;
+import plugin.lsttokens.testsupport.AbstractSubTokenTestCase;
+
+public class FreeTokenTest extends AbstractSubTokenTestCase<KitSkill>
+{
+
+ static FreeToken token = new FreeToken();
+ static CDOMSubLineLoader<KitSkill> loader = new CDOMSubLineLoader<KitSkill>(
+ "*KITTOKEN", "SKILL", KitSkill.class);
+
+ @Override
+ public Class<KitSkill> getCDOMClass()
+ {
+ return KitSkill.class;
+ }
+
+ @Override
+ public CDOMSubLineLoader<KitSkill> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMSecondaryToken<KitSkill> getToken()
+ {
+ return token;
+ }
+
+ @Test
+ public void testInvalidInputString() throws PersistenceLayerException
+ {
+ internalTestInvalidInputString(null);
+ }
+
+ @Test
+ public void testInvalidInputStringSet() throws PersistenceLayerException
+ {
+ assertTrue(parse("YES"));
+ assertTrue(parseSecondary("YES"));
+ assertEquals(Boolean.TRUE, getValue());
+ internalTestInvalidInputString(Boolean.TRUE);
+ }
+
+ public void internalTestInvalidInputString(Object val)
+ throws PersistenceLayerException
+ {
+ assertEquals(val, getValue());
+ assertFalse(parse("String"));
+ assertEquals(val, getValue());
+ assertFalse(parse("TYPE=TestType"));
+ assertEquals(val, getValue());
+ assertFalse(parse("TYPE.TestType"));
+ assertEquals(val, getValue());
+ assertFalse(parse("ALL"));
+ assertEquals(val, getValue());
+ assertFalse(parse("Yo!"));
+ assertEquals(val, getValue());
+ assertFalse(parse("Now"));
+ assertEquals(val, getValue());
+ }
+
+ @Test
+ public void testValidInputs() throws PersistenceLayerException
+ {
+ assertTrue(parse("YES"));
+ assertEquals(Boolean.TRUE, getValue());
+ assertTrue(parse("NO"));
+ assertEquals(Boolean.FALSE, getValue());
+ // We're nice enough to be case insensitive here...
+ assertTrue(parse("YeS"));
+ assertEquals(Boolean.TRUE, getValue());
+ assertTrue(parse("Yes"));
+ assertEquals(Boolean.TRUE, getValue());
+ assertTrue(parse("No"));
+ assertEquals(Boolean.FALSE, getValue());
+ // Allow abbreviations
+ assertTrue(parse("Y"));
+ assertEquals(Boolean.TRUE, getValue());
+ assertTrue(parse("N"));
+ assertEquals(Boolean.FALSE, getValue());
+ }
+
+ private Boolean getValue()
+ {
+ return primaryProf.getFree();
+ }
+
+ @Test
+ public void testRoundRobinYes() throws PersistenceLayerException
+ {
+ runRoundRobin("YES");
+ }
+
+ @Test
+ public void testRoundRobinNo() throws PersistenceLayerException
+ {
+ runRoundRobin("NO");
+ }
+}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/RankTokenTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/RankTokenTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/RankTokenTest.java 2008-12-31 23:46:35 UTC (rev 8766)
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens.kit.skill;
+
+import org.junit.Test;
+
+import pcgen.core.kit.KitSkill;
+import pcgen.persistence.PersistenceLayerException;
+import pcgen.rules.persistence.CDOMSubLineLoader;
+import pcgen.rules.persistence.token.CDOMSecondaryToken;
+import plugin.lsttokens.testsupport.AbstractSubTokenTestCase;
+
+public class RankTokenTest extends AbstractSubTokenTestCase<KitSkill>
+{
+
+ static RankToken token = new RankToken();
+ static CDOMSubLineLoader<KitSkill> loader = new CDOMSubLineLoader<KitSkill>(
+ "*KITTOKEN", "SPELLS", KitSkill.class);
+
+ @Override
+ public Class<KitSkill> getCDOMClass()
+ {
+ return KitSkill.class;
+ }
+
+ @Override
+ public CDOMSubLineLoader<KitSkill> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMSecondaryToken<KitSkill> getToken()
+ {
+ return token;
+ }
+
+ @Test
+ public void testRoundRobinNumber() throws PersistenceLayerException
+ {
+ runRoundRobin("3");
+ }
+
+ @Test
+ public void testRoundRobinDecimal() throws PersistenceLayerException
+ {
+ runRoundRobin("3.5");
+ }
+
+ @Test
+ public void testInvalidInputFormula() throws PersistenceLayerException
+ {
+ assertFalse(parse("FormulaProhibited"));
+ }
+
+// @Test
+// public void testInvalidInputZero() throws PersistenceLayerException
+// {
+// assertFalse(parse("0"));
+// }
+
+ @Test
+ public void testInvalidInputNegative() throws PersistenceLayerException
+ {
+ assertFalse(parse("-1"));
+ }
+
+}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/SelectionTokenTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/SelectionTokenTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/SelectionTokenTest.java 2008-12-31 23:46:35 UTC (rev 8766)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens.kit.skill;
+
+import org.junit.Test;
+
+import pcgen.core.Language;
+import pcgen.core.kit.KitSkill;
+import pcgen.persistence.PersistenceLayerException;
+import pcgen.rules.persistence.CDOMSubLineLoader;
+import pcgen.rules.persistence.token.CDOMSecondaryToken;
+import plugin.lsttokens.testsupport.AbstractSubTokenTestCase;
+
+public class SelectionTokenTest extends AbstractSubTokenTestCase<KitSkill>
+{
+
+ static SelectionToken token = new SelectionToken();
+ static CDOMSubLineLoader<KitSkill> loader = new CDOMSubLineLoader<KitSkill>(
+ "*KITTOKEN", "SKILL", KitSkill.class);
+
+ @Override
+ public Class<KitSkill> getCDOMClass()
+ {
+ return KitSkill.class;
+ }
+
+ @Override
+ public CDOMSubLineLoader<KitSkill> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMSecondaryToken<KitSkill> getToken()
+ {
+ return token;
+ }
+
+ @Test
+ public void testInvalidInputEmptyCount() throws PersistenceLayerException
+ {
+ assertTrue(parse("Fireball"));
+ assertFalse(primaryContext.ref.validate());
+ }
+
+ @Test
+ public void testRoundRobinSimple() throws PersistenceLayerException
+ {
+ primaryContext.ref.constructCDOMObject(Language.class, "Fireball");
+ secondaryContext.ref.constructCDOMObject(Language.class, "Fireball");
+ runRoundRobin("Fireball");
+ }
+
+ @Test
+ public void testRoundRobinTwo() throws PersistenceLayerException
+ {
+ primaryContext.ref.constructCDOMObject(Language.class, "Fireball");
+ secondaryContext.ref.constructCDOMObject(Language.class, "Fireball");
+ primaryContext.ref.constructCDOMObject(Language.class, "English");
+ secondaryContext.ref.constructCDOMObject(Language.class, "English");
+ runRoundRobin("Fireball" + getJoinCharacter() + "English");
+ }
+
+ @Test
+ public void testInvalidListEnd() throws PersistenceLayerException
+ {
+ assertFalse(parse("TestWP1" + getJoinCharacter()));
+ }
+
+ private char getJoinCharacter()
+ {
+ return ',';
+ }
+
+ @Test
+ public void testInvalidListStart() throws PersistenceLayerException
+ {
+ assertFalse(parse(getJoinCharacter() + "TestWP1"));
+ }
+
+ @Test
+ public void testInvalidListDoubleJoin() throws PersistenceLayerException
+ {
+ assertFalse(parse("TestWP2" + getJoinCharacter() + getJoinCharacter()
+ + "TestWP1"));
+ }
+
+}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/SkillTokenTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/SkillTokenTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/skill/SkillTokenTest.java 2008-12-31 23:46:35 UTC (rev 8766)
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens.kit.skill;
+
+import org.junit.Test;
+
+import pcgen.core.Skill;
+import pcgen.core.kit.KitSkill;
+import pcgen.persistence.PersistenceLayerException;
+import pcgen.rules.persistence.CDOMSubLineLoader;
+import pcgen.rules.persistence.token.CDOMSecondaryToken;
+import plugin.lsttokens.testsupport.AbstractSubTokenTestCase;
+
+public class SkillTokenTest extends AbstractSubTokenTestCase<KitSkill>
+{
+
+ static SkillToken token = new SkillToken();
+ static CDOMSubLineLoader<KitSkill> loader = new CDOMSubLineLoader<KitSkill>(
+ "*KITTOKEN", "SKILL", KitSkill.class);
+
+ @Override
+ public Class<KitSkill> getCDOMClass()
+ {
+ return KitSkill.class;
+ }
+
+ @Override
+ public CDOMSubLineLoader<KitSkill> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMSecondaryToken<KitSkill> getToken()
+ {
+ return token;
+ }
+
+ @Test
+ public void testInvalidInputEmptyCount() throws PersistenceLayerException
+ {
+ assertTrue(parse("Fireball"));
+ assertFalse(primaryContext.ref.validate());
+ }
+
+ @Test
+ public void testRoundRobinSimple() throws PersistenceLayerException
+ {
+ primaryContext.ref.constructCDOMObject(Skill.class, "Fireball");
+ secondaryContext.ref.constructCDOMObject(Skill.class, "Fireball");
+ runRoundRobin("Fireball");
+ }
+
+ @Test
+ public void testInvalidInputEmptyType() throws PersistenceLayerException
+ {
+ assertFalse(parse("TYPE="));
+ }
+
+ @Test
+ public void testInvalidInputTrailingType() throws PersistenceLayerException
+ {
+ assertFalse(parse("TYPE=One."));
+ }
+
+ @Test
+ public void testInvalidInputDoubleType() throws PersistenceLayerException
+ {
+ assertFalse(parse("TYPE=One..Two"));
+ }
+
+ @Test
+ public void testRoundRobinType() throws PersistenceLayerException
+ {
+ runRoundRobin("TYPE=Foo");
+ }
+}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/spells/CountTokenTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/spells/CountTokenTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/spells/CountTokenTest.java 2008-12-31 23:46:35 UTC (rev 8766)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens.kit.spells;
+
+import org.junit.Test;
+
+import pcgen.core.kit.KitSpells;
+import pcgen.persistence.PersistenceLayerException;
+import pcgen.rules.persistence.CDOMSubLineLoader;
+import pcgen.rules.persistence.token.CDOMSecondaryToken;
+import plugin.lsttokens.testsupport.AbstractSubTokenTestCase;
+
+public class CountTokenTest extends AbstractSubTokenTestCase<KitSpells>
+{
+
+ static CountToken token = new CountToken();
+ static CDOMSubLineLoader<KitSpells> loader = new CDOMSubLineLoader<KitSpells>(
+ "*KITTOKEN", "SPELLS", KitSpells.class);
+
+ @Override
+ public Class<KitSpells> getCDOMClass()
+ {
+ return KitSpells.class;
+ }
+
+ @Override
+ public CDOMSubLineLoader<KitSpells> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMSecondaryToken<KitSpells> getToken()
+ {
+ return token;
+ }
+
+ @Test
+ public void testRoundRobinNumber() throws PersistenceLayerException
+ {
+ runRoundRobin("3");
+ }
+
+ @Test
+ public void testRoundRobinFormula() throws PersistenceLayerException
+ {
+ runRoundRobin("Formula");
+ }
+}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/spells/SpellsTokenTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/spells/SpellsTokenTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/spells/SpellsTokenTest.java 2008-12-31 23:46:35 UTC (rev 8766)
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens.kit.spells;
+
+import org.junit.Test;
+
+import pcgen.core.Ability;
+import pcgen.core.AbilityCategory;
+import pcgen.core.PCClass;
+import pcgen.core.kit.KitSpells;
+import pcgen.core.spell.Spell;
+import pcgen.persistence.PersistenceLayerException;
+import pcgen.rules.persistence.CDOMSubLineLoader;
+import pcgen.rules.persistence.token.CDOMSecondaryToken;
+import plugin.lsttokens.testsupport.AbstractSubTokenTestCase;
+
+public class SpellsTokenTest extends AbstractSubTokenTestCase<KitSpells>
+{
+
+ static SpellsToken token = new SpellsToken();
+ static CDOMSubLineLoader<KitSpells> loader = new CDOMSubLineLoader<KitSpells>(
+ "*KITTOKEN", "SPELLS", KitSpells.class);
+
+ @Override
+ public Class<KitSpells> getCDOMClass()
+ {
+ return KitSpells.class;
+ }
+
+ @Override
+ public CDOMSubLineLoader<KitSpells> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMSecondaryToken<KitSpells> getToken()
+ {
+ return token;
+ }
+
+ @Test
+ public void testInvalidInputEmptySpellbook()
+ throws PersistenceLayerException
+ {
+ assertFalse(parse("SPELLBOOK=|CLASS=Wizard|Fireball=2"));
+ }
+
+ @Test
+ public void testInvalidInputEmptyClass() throws PersistenceLayerException
+ {
+ assertFalse(parse("SPELLBOOK=Personal|CLASS=|Fireball=2"));
+ }
+
+ @Test
+ public void testInvalidInputTwoClass() throws PersistenceLayerException
+ {
+ assertFalse(parse("SPELLBOOK=Personal|CLASS=Wizard|CLASS=Cleric|Fireball=2"));
+ }
+
+ @Test
+ public void testInvalidInputTwoSpellbook() throws PersistenceLayerException
+ {
+ assertFalse(parse("SPELLBOOK=Personal|SPELLBOOK=Other|CLASS=Wizard|Fireball=2"));
+ }
+
+ @Test
+ public void testInvalidInputEmptySpell() throws PersistenceLayerException
+ {
+ assertFalse(parse("SPELLBOOK=Personal|CLASS=Wizard|=2"));
+ }
+
+ @Test
+ public void testInvalidInputEmptyCount() throws PersistenceLayerException
+ {
+ assertFalse(parse("SPELLBOOK=Personal|CLASS=Wizard|Fireball="));
+ }
+
+ @Test
+ public void testRoundRobinSimple() throws PersistenceLayerException
+ {
+ primaryContext.ref.constructCDOMObject(Spell.class, "Fireball");
+ secondaryContext.ref.constructCDOMObject(Spell.class, "Fireball");
+ runRoundRobin("Fireball=2");
+ }
+
+ @Test
+ public void testInvalidInputEmptyType() throws PersistenceLayerException
+ {
+ assertFalse(parse("SPELLBOOK=Personal|CLASS=Wizard|TYPE."));
+ }
+
+ @Test
+ public void testInvalidInputTrailingType() throws PersistenceLayerException
+ {
+ assertFalse(parse("SPELLBOOK=Personal|CLASS=Wizard|TYPE.One."));
+ }
+
+ @Test
+ public void testInvalidInputDoubleType() throws PersistenceLayerException
+ {
+ assertFalse(parse("SPELLBOOK=Personal|CLASS=Wizard|TYPE.One..Two"));
+ }
+
+ @Test
+ public void testRoundRobinType() throws PersistenceLayerException
+ {
+ runRoundRobin("TYPE.Foo=2");
+ }
+
+ @Test
+ public void testRoundRobinFeat() throws PersistenceLayerException
+ {
+ primaryContext.ref.constructCDOMObject(Spell.class, "Fireball");
+ secondaryContext.ref.constructCDOMObject(Spell.class, "Fireball");
+ primaryContext.ref.constructCDOMObject(PCClass.class, "Wizard");
+ secondaryContext.ref.constructCDOMObject(PCClass.class, "Wizard");
+ Ability ab = primaryContext.ref.constructCDOMObject(Ability.class, "EnhancedFeat");
+ primaryContext.ref.reassociateCategory(AbilityCategory.FEAT, ab);
+ ab = secondaryContext.ref.constructCDOMObject(Ability.class, "EnhancedFeat");
+ secondaryContext.ref.reassociateCategory(AbilityCategory.FEAT, ab);
+ runRoundRobin("SPELLBOOK=Personal|CLASS=Wizard|Fireball[EnhancedFeat]=2");
+ }
+
+ @Test
+ public void testRoundRobinCount() throws PersistenceLayerException
+ {
+ primaryContext.ref.constructCDOMObject(Spell.class, "Fireball");
+ secondaryContext.ref.constructCDOMObject(Spell.class, "Fireball");
+ primaryContext.ref.constructCDOMObject(PCClass.class, "Wizard");
+ secondaryContext.ref.constructCDOMObject(PCClass.class, "Wizard");
+ runRoundRobin("SPELLBOOK=Personal|CLASS=Wizard|Fireball=2");
+ }
+
+ @Test
+ public void testRoundRobinSpellBookClass() throws PersistenceLayerException
+ {
+ primaryContext.ref.constructCDOMObject(Spell.class, "Fireball");
+ secondaryContext.ref.constructCDOMObject(Spell.class, "Fireball");
+ primaryContext.ref.constructCDOMObject(PCClass.class, "Wizard");
+ secondaryContext.ref.constructCDOMObject(PCClass.class, "Wizard");
+ runRoundRobin("SPELLBOOK=Personal|CLASS=Wizard|Fireball");
+ }
+}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/startpack/ApplyTokenTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/startpack/ApplyTokenTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/startpack/ApplyTokenTest.java 2008-12-31 23:46:35 UTC (rev 8766)
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens.kit.startpack;
+
+import org.junit.Test;
+
+import pcgen.cdom.enumeration.KitApply;
+import pcgen.cdom.enumeration.ObjectKey;
+import pcgen.core.Kit;
+import pcgen.persistence.PersistenceLayerException;
+import pcgen.rules.persistence.CDOMLoader;
+import pcgen.rules.persistence.token.CDOMPrimaryToken;
+import plugin.lsttokens.testsupport.AbstractTokenTestCase;
+import plugin.lsttokens.testsupport.CDOMTokenLoader;
+
+public class ApplyTokenTest extends AbstractTokenTestCase<Kit>
+{
+
+ static ApplyToken token = new ApplyToken();
+
+ static CDOMTokenLoader<Kit> loader = new CDOMTokenLoader<Kit>(
+ Kit.class);
+
+ @Override
+ public Class<Kit> getCDOMClass()
+ {
+ return Kit.class;
+ }
+
+ @Override
+ public CDOMLoader<Kit> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMPrimaryToken<Kit> getToken()
+ {
+ return token;
+ }
+
+ @Test
+ public void testInvalidInputString() throws PersistenceLayerException
+ {
+ internalTestInvalidInputString(null);
+ }
+
+ @Test
+ public void testInvalidInputStringSet() throws PersistenceLayerException
+ {
+ assertTrue(parse("INSTANT"));
+ assertTrue(parseSecondary("INSTANT"));
+ assertEquals(KitApply.INSTANT, primaryProf.get(ObjectKey.APPLY_MODE));
+ internalTestInvalidInputString(KitApply.INSTANT);
+ }
+
+ public void internalTestInvalidInputString(Object val)
+ throws PersistenceLayerException
+ {
+ assertEquals(val, primaryProf.get(ObjectKey.APPLY_MODE));
+ assertFalse(parse("Always"));
+ assertEquals(val, primaryProf.get(ObjectKey.APPLY_MODE));
+ assertFalse(parse("String"));
+ assertEquals(val, primaryProf.get(ObjectKey.APPLY_MODE));
+ assertFalse(parse("TYPE=TestType"));
+ assertEquals(val, primaryProf.get(ObjectKey.APPLY_MODE));
+ assertFalse(parse("TYPE.TestType"));
+ assertEquals(val, primaryProf.get(ObjectKey.APPLY_MODE));
+ assertFalse(parse("ALL"));
+ assertEquals(val, primaryProf.get(ObjectKey.APPLY_MODE));
+ // Note case sensitivity
+ assertFalse(parse("Permanent"));
+ }
+
+ @Test
+ public void testValidInputs() throws PersistenceLayerException
+ {
+ assertTrue(parse("INSTANT"));
+ assertEquals(KitApply.INSTANT, primaryProf.get(ObjectKey.APPLY_MODE));
+ assertTrue(parse("PERMANENT"));
+ assertEquals(KitApply.PERMANENT, primaryProf.get(ObjectKey.APPLY_MODE));
+ }
+
+ @Test
+ public void testRoundRobinPermanent() throws PersistenceLayerException
+ {
+ runRoundRobin("PERMANENT");
+ }
+
+ @Test
+ public void testRoundRobinInstant() throws PersistenceLayerException
+ {
+ runRoundRobin("INSTANT");
+ }
+
+}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/startpack/EquipBuyTokenTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/startpack/EquipBuyTokenTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/startpack/EquipBuyTokenTest.java 2008-12-31 23:46:35 UTC (rev 8766)
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens.kit.startpack;
+
+import java.net.URISyntaxException;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import pcgen.base.formula.Formula;
+import pcgen.cdom.enumeration.FormulaKey;
+import pcgen.cdom.enumeration.ObjectKey;
+import pcgen.core.Kit;
+import pcgen.core.QualifiedObject;
+import pcgen.persistence.PersistenceLayerException;
+import pcgen.rules.persistence.CDOMLoader;
+import pcgen.rules.persistence.token.CDOMPrimaryToken;
+import plugin.lsttokens.testsupport.AbstractFormulaTokenTestCase;
+import plugin.lsttokens.testsupport.CDOMTokenLoader;
+import plugin.lsttokens.testsupport.TokenRegistration;
+import plugin.pretokens.parser.PreClassParser;
+import plugin.pretokens.parser.PreRaceParser;
+import plugin.pretokens.writer.PreClassWriter;
+import plugin.pretokens.writer.PreRaceWriter;
+
+public class EquipBuyTokenTest extends AbstractFormulaTokenTestCase<Kit>
+{
+
+ PreClassParser preclass = new PreClassParser();
+ PreClassWriter preclasswriter = new PreClassWriter();
+ PreRaceParser prerace = new PreRaceParser();
+ PreRaceWriter preracewriter = new PreRaceWriter();
+
+ @Override
+ @Before
+ public void setUp() throws PersistenceLayerException, URISyntaxException
+ {
+ super.setUp();
+ TokenRegistration.register(preclass);
+ TokenRegistration.register(preclasswriter);
+ TokenRegistration.register(prerace);
+ TokenRegistration.register(preracewriter);
+ }
+
+ static EquipBuyToken token = new EquipBuyToken();
+ static CDOMTokenLoader<Kit> loader = new CDOMTokenLoader<Kit>(Kit.class);
+
+ @Override
+ public Class<Kit> getCDOMClass()
+ {
+ return Kit.class;
+ }
+
+ @Override
+ public CDOMLoader<Kit> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMPrimaryToken<Kit> getToken()
+ {
+ return token;
+ }
+
+ @Override
+ public FormulaKey getFormulaKey()
+ {
+ return null;
+ }
+
+ @Override
+ protected Formula getFormula()
+ {
+ QualifiedObject<Formula> qo = primaryProf.get(ObjectKey.EQUIP_BUY);
+ if (qo != null)
+ {
+ return qo.getObject(null);
+ }
+ return null;
+ }
+
+ @Test
+ public void testInvalidInputOnlyPre() throws PersistenceLayerException
+ {
+ try
+ {
+ assertFalse(parse("PRECLASS:1,Fighter=1"));
+ }
+ catch (IllegalArgumentException e)
+ {
+ // this is okay too :)
+ }
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidInputEmbeddedPre() throws PersistenceLayerException
+ {
+ assertFalse(parse("TestWP1|PRECLASS:1,Fighter=1|TestWP2"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidInputDoublePipePre()
+ throws PersistenceLayerException
+ {
+ assertFalse(parse("TestWP1||PRECLASS:1,Fighter=1"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidInputPostPrePipe() throws PersistenceLayerException
+ {
+ assertFalse(parse("TestWP1|PRECLASS:1,Fighter=1|"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testRoundRobinPre() throws PersistenceLayerException
+ {
+ runRoundRobin("TestWP1|PRECLASS:1,Fighter=1");
+ }
+
+ @Test
+ public void testRoundRobinTwoPre() throws PersistenceLayerException
+ {
+ runRoundRobin("TestWP1|!PRERACE:1,Human|PRECLASS:1,Fighter=1");
+ }
+
+ @Test
+ public void testRoundRobinNotPre() throws PersistenceLayerException
+ {
+ runRoundRobin("TestWP1|!PRECLASS:1,Fighter=1");
+ }
+}
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/startpack/VisibleTokenTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/startpack/VisibleTokenTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/kit/startpack/VisibleTokenTest.java 2008-12-31 23:46:35 UTC (rev 8766)
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens.kit.startpack;
+
+import org.junit.Test;
+
+import pcgen.cdom.enumeration.ObjectKey;
+import pcgen.core.Kit;
+import pcgen.persistence.PersistenceLayerException;
+import pcgen.rules.persistence.CDOMLoader;
+import pcgen.rules.persistence.token.CDOMPrimaryToken;
+import pcgen.util.enumeration.Visibility;
+import plugin.lsttokens.testsupport.AbstractTokenTestCase;
+import plugin.lsttokens.testsupport.CDOMTokenLoader;
+
+public class VisibleTokenTest extends AbstractTokenTestCase<Kit>
+{
+
+ static VisibleToken token = new VisibleToken();
+
+ static CDOMTokenLoader<Kit> loader = new CDOMTokenLoader<Kit>(
+ Kit.class);
+
+ @Override
+ public Class<Kit> getCDOMClass()
+ {
+ return Kit.class;
+ }
+
+ @Override
+ public CDOMLoader<Kit> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMPrimaryToken<Kit> getToken()
+ {
+ return token;
+ }
+
+ @Test
+ public void testInvalidOutput()
+ {
+ assertTrue(primaryContext.getWriteMessageCount() == 0);
+ primaryProf.put(ObjectKey.VISIBILITY, Visibility.OUTPUT_ONLY);
+ assertNull(token.unparse(primaryContext, primaryProf));
+ assertFalse(primaryContext.getWriteMessageCount() == 0);
+ }
+
+ @Test
+ public void testInvalidInputString() throws PersistenceLayerException
+ {
+ internalTestInvalidInputString(null);
+ }
+
+ @Test
+ public void testInvalidInputStringSet() throws PersistenceLayerException
+ {
+ assertTrue(parse("QUALIFY"));
+ assertTrue(parseSecondary("QUALIFY"));
+ assertEquals(Visibility.QUALIFY, primaryProf.get(ObjectKey.VISIBILITY));
+ internalTestInvalidInputString(Visibility.QUALIFY);
+ }
+
+ public void internalTestInvalidInputString(Object val)
+ throws PersistenceLayerException
+ {
+ assertEquals(val, primaryProf.get(ObjectKey.VISIBILITY));
+ assertFalse(parse("Always"));
+ assertEquals(val, primaryProf.get(ObjectKey.VISIBILITY));
+ assertFalse(parse("String"));
+ assertEquals(val, primaryProf.get(ObjectKey.VISIBILITY));
+ assertFalse(parse("TYPE=TestType"));
+ assertEquals(val, primaryProf.get(ObjectKey.VISIBILITY));
+ assertFalse(parse("TYPE.TestType"));
+ assertEquals(val, primaryProf.get(ObjectKey.VISIBILITY));
+ assertFalse(parse("ALL"));
+ assertEquals(val, primaryProf.get(ObjectKey.VISIBILITY));
+ // Note case sensitivity
+ assertFalse(parse("Display"));
+ }
+
+ @Test
+ public void testValidInputs() throws PersistenceLayerException
+ {
+ assertTrue(parse("QUALIFY"));
+ assertEquals(Visibility.QUALIFY, primaryProf.get(ObjectKey.VISIBILITY));
+ assertTrue(parse("YES"));
+ assertEquals(Visibility.DEFAULT, primaryProf.get(ObjectKey.VISIBILITY));
+ assertTrue(parse("NO"));
+ assertEquals(Visibility.HIDDEN, primaryProf.get(ObjectKey.VISIBILITY));
+ }
+
+ @Test
+ public void testRoundRobinQualify() throws PersistenceLayerException
+ {
+ runRoundRobin("QUALIFY");
+ }
+
+ @Test
+ public void testRoundRobinYes() throws PersistenceLayerException
+ {
+ runRoundRobin("YES");
+ }
+
+ @Test
+ public void testRoundRobinNo() throws PersistenceLayerException
+ {
+ runRoundRobin("NO");
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|