Revision: 5943
http://pcgen.svn.sourceforge.net/pcgen/?rev=5943&view=rev
Author: thpr
Date: 2008-04-13 17:32:05 -0700 (Sun, 13 Apr 2008)
Log Message:
-----------
CDOM: Cleanup
Removed Paths:
-------------
branches/cdom/code/src/itest/pcgen/tokenruntimeload/AbstractIntegrationTestCase.java
branches/cdom/code/src/itest/pcgen/tokenruntimeload/WeaponProfTest.java
branches/cdom/code/src/itest/plugin/lsttokens/loader/LangAutoLoaderTest.java
branches/cdom/code/src/itest/plugin/lsttokens/loader/SaLstLoaderTest.java
branches/cdom/code/src/itest/plugin/lsttokens/loader/TokenGlobalLoaderTestSuite.java
branches/cdom/code/src/itest/plugin/lsttokens/loader/VisionLstLoaderTest.java
branches/cdom/code/src/itest/plugin/lsttokens/loader/testsupport/AbstractTokenLoaderTestCase.java
Deleted: branches/cdom/code/src/itest/pcgen/tokenruntimeload/AbstractIntegrationTestCase.java
===================================================================
--- branches/cdom/code/src/itest/pcgen/tokenruntimeload/AbstractIntegrationTestCase.java 2008-04-14 00:26:23 UTC (rev 5942)
+++ branches/cdom/code/src/itest/pcgen/tokenruntimeload/AbstractIntegrationTestCase.java 2008-04-14 00:32:05 UTC (rev 5943)
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2007 Tom Parker <thpr@...>
- *
- * 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 pcgen.tokenruntimeload;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import junit.framework.TestCase;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-
-import pcgen.cdom.base.CDOMObject;
-import pcgen.cdom.graph.PCGenGraph;
-import pcgen.core.Campaign;
-import pcgen.persistence.PersistenceLayerException;
-import pcgen.persistence.lst.CampaignSourceEntry;
-import pcgen.persistence.lst.LstToken;
-import pcgen.persistence.lst.TokenStore;
-import pcgen.rules.context.EditorLoadContext;
-import pcgen.rules.context.LoadContext;
-import pcgen.rules.persistence.CDOMLoader;
-
-public abstract class AbstractIntegrationTestCase<T extends CDOMObject> extends
- TestCase
-{
- protected PCGenGraph primaryGraph;
- protected PCGenGraph secondaryGraph;
- protected LoadContext primaryContext;
- protected LoadContext secondaryContext;
- protected T primaryProf;
- protected T secondaryProf;
- protected String prefix = "";
- protected int expectedPrimaryMessageCount = 0;
-
- private static boolean classSetUpFired = false;
- protected static CampaignSourceEntry testCampaign;
- protected static CampaignSourceEntry modCampaign;
-
- public abstract CDOMLoader<T> getLoader();
-
- @BeforeClass
- public static final void classSetUp() throws URISyntaxException
- {
- testCampaign =
- new CampaignSourceEntry(new Campaign(), new URI(
- "file:/Test%20Case"));
- modCampaign =
- new CampaignSourceEntry(new Campaign(), new URI(
- "file:/Test%20Case%20Modifier"));
- classSetUpFired = true;
- }
-
- @Override
- @Before
- public void setUp() throws PersistenceLayerException, URISyntaxException
- {
- if (!classSetUpFired)
- {
- classSetUp();
- }
- primaryGraph = new PCGenGraph();
- secondaryGraph = new PCGenGraph();
- primaryContext = new EditorLoadContext();
- secondaryContext = new EditorLoadContext();
- primaryProf =
- primaryContext.ref.constructCDOMObject(getCDOMClass(),
- "TestObj");
- secondaryProf =
- secondaryContext.ref.constructCDOMObject(getCDOMClass(),
- "TestObj");
- }
-
- public abstract Class<? extends T> getCDOMClass();
-
- public static void addToken(LstToken tok)
- {
- TokenStore.inst().addToTokenMap(tok);
- }
-
- protected void verifyClean()
- {
- // Ensure the graphs are the same at the start
- assertEquals(primaryGraph, secondaryGraph);
- // Ensure the graphs are the same at the start
- assertTrue(primaryProf.isCDOMEqual(secondaryProf));
- }
-}
Deleted: branches/cdom/code/src/itest/pcgen/tokenruntimeload/WeaponProfTest.java
===================================================================
--- branches/cdom/code/src/itest/pcgen/tokenruntimeload/WeaponProfTest.java 2008-04-14 00:26:23 UTC (rev 5942)
+++ branches/cdom/code/src/itest/pcgen/tokenruntimeload/WeaponProfTest.java 2008-04-14 00:32:05 UTC (rev 5943)
@@ -1,56 +0,0 @@
-package pcgen.tokenruntimeload;
-
-import java.net.URISyntaxException;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import pcgen.cdom.enumeration.IntegerKey;
-import pcgen.cdom.enumeration.ObjectKey;
-import pcgen.cdom.inst.CDOMWeaponProf;
-import pcgen.persistence.PersistenceLayerException;
-import pcgen.rules.persistence.CDOMLoader;
-import pcgen.rules.persistence.CDOMTokenLoader;
-import plugin.lsttokens.testsupport.TokenRegistration;
-import plugin.lsttokens.weaponprof.HandsToken;
-
-public class WeaponProfTest extends AbstractIntegrationTestCase<CDOMWeaponProf>
-{
-
- static HandsToken token = new HandsToken();
- static CDOMTokenLoader<CDOMWeaponProf> loader = new CDOMTokenLoader<CDOMWeaponProf>(
- CDOMWeaponProf.class);
-
- @Override
- @Before
- public final void setUp() throws PersistenceLayerException,
- URISyntaxException
- {
- super.setUp();
- TokenRegistration.register(token);
- }
-
- @Override
- public Class<CDOMWeaponProf> getCDOMClass()
- {
- return CDOMWeaponProf.class;
- }
-
- @Override
- public CDOMLoader<CDOMWeaponProf> getLoader()
- {
- return loader;
- }
-
- @Test
- public void testImportBasicWeaponProf() throws PersistenceLayerException
- {
- verifyClean();
- primaryProf = new CDOMWeaponProf();
- primaryProf.setName("TestWP1");
- loader.parseLine(primaryContext, primaryProf, "HANDS:2", testCampaign.getURI());
- secondaryProf.put(IntegerKey.HANDS, Integer.valueOf(2));
- secondaryProf.put(ObjectKey.SOURCE_URI, testCampaign.getURI());
- verifyClean();
- }
-}
Deleted: branches/cdom/code/src/itest/plugin/lsttokens/loader/LangAutoLoaderTest.java
===================================================================
--- branches/cdom/code/src/itest/plugin/lsttokens/loader/LangAutoLoaderTest.java 2008-04-14 00:26:23 UTC (rev 5942)
+++ branches/cdom/code/src/itest/plugin/lsttokens/loader/LangAutoLoaderTest.java 2008-04-14 00:32:05 UTC (rev 5943)
@@ -1,78 +0,0 @@
-/*
- * SaLstLoaderTest.java
- * Copyright 2007 (C) Koen Van Daele
- *
- * This library 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 library 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Created on 17-aug-07
- *
- * $Id: $
- */
-package plugin.lsttokens.loader;
-
-import pcgen.cdom.inst.CDOMTemplate;
-import pcgen.core.PCTemplate;
-import pcgen.persistence.lst.GlobalLstToken;
-import pcgen.rules.persistence.CDOMLoader;
-import pcgen.rules.persistence.CDOMTokenLoader;
-import plugin.lsttokens.LangautoLst;
-import plugin.lsttokens.loader.testsupport.AbstractTokenLoaderTestCase;
-
-/**
- * <code>LangAutoLstLoaderTest</code> tests LANGAUTO tags in both Runtime and
- * Editor contexts.
- *
- * @author Koen Van Daele <vandaelek@...>
- * @version $Revision$
- */
-public class LangAutoLoaderTest extends AbstractTokenLoaderTestCase
-{
- static LangautoLst token = new LangautoLst();
- static CDOMTokenLoader<CDOMTemplate> loader = new CDOMTokenLoader<CDOMTemplate>(
- CDOMTemplate.class);
-
- @Override
- public CDOMLoader<CDOMTemplate> getLoader()
- {
- return loader;
- }
-
- @Override
- public Class<PCTemplate> getCDOMClass()
- {
- return PCTemplate.class;
- }
-
- @Override
- public LangautoLst getToken()
- {
- return token;
- }
-
- public String[] getTestArray()
- {
- return new String[] { "Gnome", "Aspalanisch", "Common" };
- }
-
- protected boolean isClearable()
- {
- return true;
- }
-
- protected boolean isDotClearable()
- {
- return false;
- }
-}
Deleted: branches/cdom/code/src/itest/plugin/lsttokens/loader/SaLstLoaderTest.java
===================================================================
--- branches/cdom/code/src/itest/plugin/lsttokens/loader/SaLstLoaderTest.java 2008-04-14 00:26:23 UTC (rev 5942)
+++ branches/cdom/code/src/itest/plugin/lsttokens/loader/SaLstLoaderTest.java 2008-04-14 00:32:05 UTC (rev 5943)
@@ -1,76 +0,0 @@
-/*
- * SaLstLoaderTest.java
- * Copyright 2007 (C) Koen Van Daele
- *
- * This library 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 library 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Created on 17-aug-07
- *
- * $Id: $
- */
-package plugin.lsttokens.loader;
-
-import pcgen.cdom.inst.CDOMTemplate;
-import pcgen.core.PCTemplate;
-import pcgen.persistence.lst.GlobalLstToken;
-import pcgen.rules.persistence.CDOMLoader;
-import pcgen.rules.persistence.CDOMTokenLoader;
-import plugin.lsttokens.SabLst;
-import plugin.lsttokens.loader.testsupport.AbstractTokenLoaderTestCase;
-
-/**
- * <code>SaLstLoaderTest</code> tests SA tags in both Runtime and Editor contexts.
- *
- * @author Koen Van Daele <vandaelek@...>
- * @version $Revision$
- */
-public class SaLstLoaderTest extends AbstractTokenLoaderTestCase{
- static SabLst token = new SabLst();
- static CDOMTokenLoader<CDOMTemplate> loader = new CDOMTokenLoader<CDOMTemplate>(
- CDOMTemplate.class);
-
- @Override
- public CDOMLoader<CDOMTemplate> getLoader()
- {
- return loader;
- }
-
- @Override
- public Class<PCTemplate> getCDOMClass()
- {
- return PCTemplate.class;
- }
-
- @Override
- public SabLst getToken()
- {
- return token;
- }
-
- public String[] getTestArray()
- {
- return new String[] {"Fire in the hole" , "Banana Toss", "Ni Ni Ni"};
- }
-
- protected boolean isClearable()
- {
- return true;
- }
-
- protected boolean isDotClearable()
- {
- return true;
- }
-}
Deleted: branches/cdom/code/src/itest/plugin/lsttokens/loader/TokenGlobalLoaderTestSuite.java
===================================================================
--- branches/cdom/code/src/itest/plugin/lsttokens/loader/TokenGlobalLoaderTestSuite.java 2008-04-14 00:26:23 UTC (rev 5942)
+++ branches/cdom/code/src/itest/plugin/lsttokens/loader/TokenGlobalLoaderTestSuite.java 2008-04-14 00:32:05 UTC (rev 5943)
@@ -1,43 +0,0 @@
-/*
- * TokenGlobalLoaderTestSuite.java
- * Copyright 2007 (C) Koen Van Daele
- *
- * This library 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 library 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Created on 1-aug-07
- *
- * $Id: $
- */
-package plugin.lsttokens.loader;
-
-import junit.framework.TestSuite;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-import plugin.lsttokens.loader.VisionLstLoaderTest;
-
-/**
- * <code>TokenGlobalLoaderTestSuite</code> is a test suite to test the integration of
- * Global Tokens and Context.
- *
- * @author Koen Van Daele <vandaelek@...>
- * @version $Revision$
- */
-@...)
-@...})
-public class TokenGlobalLoaderTestSuite extends TestSuite{
- // No contents, see annotations
-}
Deleted: branches/cdom/code/src/itest/plugin/lsttokens/loader/VisionLstLoaderTest.java
===================================================================
--- branches/cdom/code/src/itest/plugin/lsttokens/loader/VisionLstLoaderTest.java 2008-04-14 00:26:23 UTC (rev 5942)
+++ branches/cdom/code/src/itest/plugin/lsttokens/loader/VisionLstLoaderTest.java 2008-04-14 00:32:05 UTC (rev 5943)
@@ -1,99 +0,0 @@
-/*
- * VisionLstLoaderTest.java
- * Copyright 2007 (C) Koen Van Daele
- *
- * This library 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 library 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Created on 31-jul-07
- *
- * $Id: $
- */
-package plugin.lsttokens.loader;
-
-import java.net.URI;
-
-import pcgen.cdom.inst.CDOMTemplate;
-import pcgen.core.PCTemplate;
-import pcgen.persistence.PersistenceLayerException;
-import pcgen.persistence.lst.GlobalLstToken;
-import pcgen.rules.context.EditorLoadContext;
-import pcgen.rules.persistence.CDOMLoader;
-import pcgen.rules.persistence.CDOMTokenLoader;
-import plugin.lsttokens.VisionLst;
-import plugin.lsttokens.loader.testsupport.AbstractTokenLoaderTestCase;
-
-/**
- * <code>VisionLstLoaderTest</code> is ...
- *
- * @author Koen Van Daele <vandaelek@...>
- * @version $Revision$
- */
-public class VisionLstLoaderTest extends AbstractTokenLoaderTestCase{
- static VisionLst token = new VisionLst();
- static CDOMTokenLoader<CDOMTemplate> loader = new CDOMTokenLoader<CDOMTemplate>(
- CDOMTemplate.class);
-
- @Override
- public CDOMLoader<CDOMTemplate> getLoader()
- {
- return loader;
- }
-
- @Override
- public Class<PCTemplate> getCDOMClass()
- {
- return PCTemplate.class;
- }
-
- @Override
- public VisionLst getToken()
- {
- return token;
- }
-
- public String[] getTestArray()
- {
- return new String[] {"Darkvision (25')" , "Normal (30')"};
- }
-
- protected boolean isClearable()
- {
- return true;
- }
-
- protected boolean isDotClearable()
- {
- return true;
- }
-
-
- public void testEditorContextMultipleSources() throws PersistenceLayerException
- {
- context = new EditorLoadContext();
- URI sourceURI = sourceCampaign.getURI();
- URI modURI = modCampaign.getURI();
- context.setSourceURI(sourceURI);
- testParse(context, "Normal (30')");
- context.setSourceURI(modURI);
- testParse(context, "Darkvision (20')");
- testParse(context, ".CLEAR.Normal (30')");
- context.setExtractURI(sourceURI);
- testUnparse(context, "Normal (30')");
- context.setExtractURI(modURI);
- testUnparse(context, ".CLEAR.Normal (30')|Darkvision (20')");
- }
-
-
-}
Deleted: branches/cdom/code/src/itest/plugin/lsttokens/loader/testsupport/AbstractTokenLoaderTestCase.java
===================================================================
--- branches/cdom/code/src/itest/plugin/lsttokens/loader/testsupport/AbstractTokenLoaderTestCase.java 2008-04-14 00:26:23 UTC (rev 5942)
+++ branches/cdom/code/src/itest/plugin/lsttokens/loader/testsupport/AbstractTokenLoaderTestCase.java 2008-04-14 00:32:05 UTC (rev 5943)
@@ -1,281 +0,0 @@
-/*
- * AbstractTokenLoaderTestCase.java
- * Copyright 2007 (C) Koen Van Daele
- *
- * This library 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 library 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Created on 31-jul-07
- *
- * $Id$
- */
-package plugin.lsttokens.loader.testsupport;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-
-import pcgen.base.lang.StringUtil;
-import pcgen.cdom.base.CDOMObject;
-import pcgen.core.Campaign;
-import pcgen.persistence.PersistenceLayerException;
-import pcgen.persistence.lst.CampaignSourceEntry;
-import pcgen.rules.context.EditorLoadContext;
-import pcgen.rules.context.LoadContext;
-import pcgen.rules.context.RuntimeLoadContext;
-import pcgen.rules.persistence.CDOMLoader;
-import pcgen.rules.persistence.token.CDOMPrimaryToken;
-
-/**
- * <code>AbstractTokenLoaderTestCase</code> is an abstract test case for
- * testing that tokens get cleared correctly in LoadContext
- *
- * @author Koen Van Daele <vandaelek@...>
- * @version $Revision$
- */
-public abstract class AbstractTokenLoaderTestCase<T extends CDOMObject> extends TestCase
-{
- protected LoadContext context;
- protected T prof;
-
- private static boolean classSetUpFired = false;
-
- protected static CampaignSourceEntry sourceCampaign;
- protected static CampaignSourceEntry modCampaign;
-
- @BeforeClass
- public static final void classSetUp() throws URISyntaxException
- {
- sourceCampaign =
- new CampaignSourceEntry(new Campaign(), new URI(
- "file:/Test%20Case%20Source"));
- modCampaign =
- new CampaignSourceEntry(new Campaign(), new URI(
- "file:/Test%20Case%20Mod"));
- classSetUpFired = true;
- }
-
- @Override
- @Before
- public void setUp() throws PersistenceLayerException, URISyntaxException
- {
- if (!classSetUpFired)
- {
- classSetUp();
- }
- context = new RuntimeLoadContext();
- prof = context.ref.constructCDOMObject(getCDOMClass(), "TestObj");
-
- URI sourceURI = sourceCampaign.getURI();
- context.getObjectContext().setSourceURI(sourceURI);
- context.getObjectContext().setExtractURI(sourceURI);
- }
-
- public char getJoinCharacter()
- {
- return '|';
- }
-
- /*
- * Provide an array of testdata.
- */
- public abstract String[] getTestArray();
-
- /*
- * Test Clearing the provided testArray in Runtime Context
- */
- public void testTestArrayInRuntimeContext()
- throws PersistenceLayerException
- {
- runClearAllTest(getTestArray());
- }
-
- /*
- * Test clearing the context before adding the testData to ensure that it doesn't
- * get cleared.
- */
- public void testPreClearTestArrayInRuntimeContext()
- throws PersistenceLayerException
- {
- runPreClearAllTest(getTestArray());
- }
- /*
- * Try to clear every element in the testarray.
- */
- public void testDotClearTestArrayInRuntimeContext()
- throws PersistenceLayerException, URISyntaxException
- {
- runClearAllIndexesTest(getTestArray());
- }
-
- /*
- * Test the provided testArray in Editor Context
- */
- public void testClearTestArrayInEditorContext()
- throws PersistenceLayerException
- {
- context = new EditorLoadContext();
- runClearAllTest(getTestArray());
- }
-
- public void testPreClearTestArrayInEditorContext()
- throws PersistenceLayerException
- {
- context = new EditorLoadContext();
- runPreClearAllTest(getTestArray());
- }
-
- public void testDotClearTestArrayInEditorContext()
- throws PersistenceLayerException, URISyntaxException
- {
- context = new EditorLoadContext();
- runClearAllIndexesTest(getTestArray());
- }
-
- protected abstract boolean isClearable();
-
- protected abstract boolean isDotClearable();
-
- public abstract CDOMPrimaryToken<T> getToken();
-
- public abstract CDOMLoader<T> getLoader();
-
- public abstract Class<T> getCDOMClass();
-
- protected void testParse(LoadContext context, String tok)
- throws PersistenceLayerException
- {
- assertTrue("Couldn't parse" + getToken().getTokenName() + " in "
- + context.getContextType() + " Context.", getToken().parse(context,
- prof, tok));
- context.commit();
- }
-
- protected void testUnparse(LoadContext context, String... str)
- throws PersistenceLayerException
- {
- String[] unparsed = getToken().unparse(context, prof);
- assertEquals(str.length, unparsed.length);
-
- for (int i = 0; i < str.length; i++)
- {
- assertEquals("Expected " + i + " item to be equal in "
- + context.getContextType() + " Context.", str[i], unparsed[i]);
- }
- }
-
- /**
- * Test is the token was successfully cleared.
- *
- * @param context
- * @throws PersistenceLayerException
- */
- protected void testCleared(LoadContext context)
- throws PersistenceLayerException
- {
- // TODO Rewrite this using inner classes as a Strategy.
- if (context.getContextType() == "Runtime")
- {
- assertNull(getToken().unparse(context, prof));
- }
- if (context.getContextType() == "Editor")
- {
- String[] unparsed = getToken().unparse(context, prof);
- for (int i = 0; i < unparsed.length; i++)
- {
- assertEquals("Expected " + i
- + " item to be .CLEAR in Editor Context.", ".CLEAR",
- unparsed[i]);
- }
- }
-
- }
-
- public void runClearAllTest(String... str) throws PersistenceLayerException
- {
- if (!isClearable()) {
- return;
- }
- for (String s : str)
- {
- testParse(context, s);
- }
- testParse(context, ".CLEAR");
- // Get back the appropriate token:
- testCleared(context);
- }
-
- public void runPreClearAllTest(String... str) throws PersistenceLayerException
- {
- if (!isClearable()) {
- return;
- }
- testParse(context,".CLEAR");
- for (String s : str) {
- testParse(context,s);
- }
- assertNotNull(getToken().unparse(context, prof));
- }
-
- /*
- * Clear each element of the array and test the results
- */
- public void runClearAllIndexesTest(String... str)
- throws PersistenceLayerException, URISyntaxException
- {
- if (!isDotClearable()) {
- return;
- }
- for (int i = 0; i < str.length; i++) {
- setUp();
- runClearIndexTest(i,str);
- }
- }
-
- /*
- * Clear the element at the specified index and assert that the result is
- * correct
- */
- protected void runClearIndexTest(int index, String... str)
- throws PersistenceLayerException
- {
- // parse everything
- for (String s : str)
- {
- testParse(context, s);
- }
- // clear the requested index
- testParse(context, ".CLEAR." + str[index]);
- String[] unparsed = getToken().unparse(context, prof);
- // assert that the return array contains only 1 element in LoadContext
- // Not sure if this should always be so...
- assertEquals(unparsed.length, 1);
-
- // assert that the correct index was removed
- ArrayList<String> strL = new ArrayList<String>(Arrays.asList(str));
- assertEquals(str[index], strL.remove(index));
-
- // make a string containing everything but the removed element
- // and compare it to the unparsed token
- String indexCleared =
- StringUtil.join(strL, String.valueOf(getJoinCharacter()));
- assertEquals(indexCleared, unparsed[0]);
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|