|
From: <th...@us...> - 2008-08-06 21:35:21
|
Revision: 7395
http://pcgen.svn.sourceforge.net/pcgen/?rev=7395&view=rev
Author: thpr
Date: 2008-08-06 21:35:27 +0000 (Wed, 06 Aug 2008)
Log Message:
-----------
test
Modified Paths:
--------------
Trunk/pcgen/code/src/java/plugin/lsttokens/template/FavoredclassToken.java
Added Paths:
-----------
Trunk/pcgen/code/src/utest/plugin/lsttokens/template/FavoredClassTokenTest.java
Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/template/FavoredclassToken.java
===================================================================
--- Trunk/pcgen/code/src/java/plugin/lsttokens/template/FavoredclassToken.java 2008-08-06 21:28:32 UTC (rev 7394)
+++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/FavoredclassToken.java 2008-08-06 21:35:27 UTC (rev 7395)
@@ -78,6 +78,10 @@
}
else
{
+ if (hasIllegalSeparator('.', token))
+ {
+ return false;
+ }
// SubClass
String parent = token.substring(0, dotLoc);
String subclass = token.substring(dotLoc + 1);
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/template/FavoredClassTokenTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/template/FavoredClassTokenTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/template/FavoredClassTokenTest.java 2008-08-06 21:35:27 UTC (rev 7395)
@@ -0,0 +1,158 @@
+/*
+ * 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.template;
+
+import org.junit.Test;
+
+import pcgen.cdom.enumeration.SubClassCategory;
+import pcgen.core.PCClass;
+import pcgen.core.PCTemplate;
+import pcgen.core.SubClass;
+import pcgen.persistence.PersistenceLayerException;
+import pcgen.rules.persistence.CDOMLoader;
+import pcgen.rules.persistence.token.CDOMPrimaryToken;
+import plugin.lsttokens.testsupport.AbstractListTokenTestCase;
+import plugin.lsttokens.testsupport.CDOMTokenLoader;
+
+public class FavoredClassTokenTest extends
+ AbstractListTokenTestCase<PCTemplate, PCClass>
+{
+
+ static FavoredclassToken token = new FavoredclassToken();
+ static CDOMTokenLoader<PCTemplate> loader = new CDOMTokenLoader<PCTemplate>(
+ PCTemplate.class);
+
+ @Override
+ public Class<PCTemplate> getCDOMClass()
+ {
+ return PCTemplate.class;
+ }
+
+ @Override
+ public CDOMLoader<PCTemplate> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public CDOMPrimaryToken<PCTemplate> getToken()
+ {
+ return token;
+ }
+
+ @Override
+ public Class<PCClass> getTargetClass()
+ {
+ return PCClass.class;
+ }
+
+ @Override
+ public boolean isTypeLegal()
+ {
+ return false;
+ }
+
+ @Override
+ public boolean isAllLegal()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isClearDotLegal()
+ {
+ return false;
+ }
+
+ @Override
+ public boolean isClearLegal()
+ {
+ return false;
+ }
+
+ @Override
+ public char getJoinCharacter()
+ {
+ return '|';
+ }
+
+ @Test
+ public void testInvalidInputSubClassNoSub()
+ throws PersistenceLayerException
+ {
+ construct(primaryContext, "TestWP1");
+ assertFalse(parse("TestWP1."));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidInputSubClassNoClass()
+ throws PersistenceLayerException
+ {
+ assertFalse(parse(".TestWP1"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testInvalidInputSubDoubleSeparator()
+ throws PersistenceLayerException
+ {
+ construct(primaryContext, "TestWP1");
+ assertFalse(parse("TestWP1..Two"));
+ assertNoSideEffects();
+ }
+
+ @Test
+ public void testCategorization() throws PersistenceLayerException
+ {
+ construct(primaryContext, "TestWP1");
+ assertTrue(parse("TestWP1.Two"));
+ SubClass obj = primaryContext.ref.constructCDOMObject(
+ SubClass.class, "Two");
+ SubClassCategory cat = SubClassCategory.getConstant("TestWP2");
+ primaryContext.ref.reassociateCategory(cat, obj);
+ assertFalse(primaryContext.ref.validate());
+ obj = primaryContext.ref.constructCDOMObject(SubClass.class, "Two");
+ cat = SubClassCategory.getConstant("TestWP1");
+ primaryContext.ref.reassociateCategory(cat, obj);
+ assertTrue(primaryContext.ref.validate());
+ }
+
+ @Test
+ public void testRoundRobinThreeSub() throws PersistenceLayerException
+ {
+ construct(primaryContext, "TestWP1");
+ construct(primaryContext, "TestWP2");
+ construct(primaryContext, "TestWP3");
+ construct(secondaryContext, "TestWP1");
+ construct(secondaryContext, "TestWP2");
+ construct(secondaryContext, "TestWP3");
+ SubClass obj = primaryContext.ref.constructCDOMObject(
+ SubClass.class, "Sub");
+ SubClassCategory cat = SubClassCategory.getConstant("TestWP2");
+ primaryContext.ref.reassociateCategory(cat, obj);
+ obj = secondaryContext.ref.constructCDOMObject(SubClass.class,
+ "Sub");
+ secondaryContext.ref.reassociateCategory(cat, obj);
+ System.err.println("!");
+ runRoundRobin("TestWP1" + getJoinCharacter() + "TestWP2.Sub"
+ + getJoinCharacter() + "TestWP3");
+ System.err.println("!!");
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|