[jboss-cvs] JBoss Messaging SVN: r4549 - in trunk: tests/src/org/jboss/messaging/tests/unit/core/deployers/impl and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jun 23 07:02:48 EDT 2008
Author: timfox
Date: 2008-06-23 07:02:48 -0400 (Mon, 23 Jun 2008)
New Revision: 4549
Added:
trunk/tests/src/org/jboss/messaging/tests/unit/core/deployers/impl/XMLDeployerTest.java
Removed:
trunk/tests/src/org/jboss/messaging/tests/unit/core/deployers/impl/DeployerTest.java
Modified:
trunk/src/main/org/jboss/messaging/core/deployers/impl/XmlDeployer.java
Log:
More test stuff
Modified: trunk/src/main/org/jboss/messaging/core/deployers/impl/XmlDeployer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/deployers/impl/XmlDeployer.java 2008-06-23 10:41:32 UTC (rev 4548)
+++ trunk/src/main/org/jboss/messaging/core/deployers/impl/XmlDeployer.java 2008-06-23 11:02:48 UTC (rev 4549)
@@ -22,6 +22,16 @@
package org.jboss.messaging.core.deployers.impl;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.jboss.messaging.core.deployers.Deployer;
import org.jboss.messaging.core.deployers.DeploymentManager;
import org.jboss.messaging.core.logging.Logger;
@@ -31,45 +41,41 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Set;
-
/**
* @author <a href="ataylor at redhat.com">Andy Taylor</a>
*/
public abstract class XmlDeployer implements Deployer, MessagingComponent
{
private static Logger log = Logger.getLogger(XmlDeployer.class);
+
protected static final String NAME_ATTR = "name";
- private final HashMap<URL, HashMap<String, Node>> configuration = new HashMap<URL, HashMap<String, Node>>();
+ private final Map<URL, Map<String, Node>> configuration = new HashMap<URL, Map<String, Node>>();
private final DeploymentManager deploymentManager;
- private volatile boolean started;
+ private boolean started;
public XmlDeployer(final DeploymentManager deploymentManager)
{
this.deploymentManager = deploymentManager;
}
+
/**
* adds a URL to the already configured set of url's this deployer is handling
* @param url The URL to add
* @param name the name of the element
* @param e .
*/
- public void addToConfiguration(URL url, String name, Node e)
+ public synchronized void addToConfiguration(final URL url, final String name, final Node e)
{
- if (configuration.get(url) == null)
+ Map<String, Node> map = configuration.get(url);
+ if (map == null)
{
- configuration.put(url, new HashMap<String, Node>());
- }
- configuration.get(url).put(name, e);
+ map = new HashMap<String, Node>();
+ configuration.put(url, map);
+ }
+ map.put(name, e);
}
/**
@@ -78,10 +84,10 @@
* @param url The resource to redeploy
* @throws Exception .
*/
- public void redeploy(URL url) throws Exception
+ public synchronized void redeploy(final URL url) throws Exception
{
Element e = getRootElement(url);
- ArrayList<String> added = new ArrayList<String>();
+ List<String> added = new ArrayList<String>();
//pull out the elements that need deploying
String elements[] = getElementTagName();
for (String element : elements)
@@ -93,7 +99,8 @@
String name = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
added.add(name);
//if this has never been deployed deploy
- if (configuration.get(url) == null || (configuration.get(url) != null && configuration.get(url).get(name) == null))
+ Map<String, Node> map = configuration.get(url);
+ if (map == null || (map != null && map.get(name) == null))
{
log.info(new StringBuilder(name).append(" doesn't exist deploying"));
deploy(node);
@@ -106,18 +113,17 @@
deploy(node);
addToConfiguration(url, name, node);
}
-
}
}
//now check for anything that has been removed and undeploy
if (configuration.get(url) != null)
{
Set<String> keys = configuration.get(url).keySet();
- ArrayList<String> removed = new ArrayList<String>();
+ List<String> removed = new ArrayList<String>();
for (String key : keys)
{
- if(!added.contains(key))
+ if (!added.contains(key))
{
undeploy(configuration.get(url).get(key));
removed.add(key);
@@ -135,7 +141,7 @@
* @param url The Resource that was deleted
* @throws Exception .
*/
- public void undeploy(URL url) throws Exception
+ public synchronized void undeploy(final URL url) throws Exception
{
Set<String> keys = configuration.get(url).keySet();
for (String key : keys)
@@ -151,7 +157,7 @@
* @param url The resource todeploy
* @throws Exception .
*/
- public void deploy(URL url) throws Exception
+ public synchronized void deploy(final URL url) throws Exception
{
Element e = getRootElement(url);
//find all thenodes to deploy
@@ -165,7 +171,7 @@
Node keyNode = node.getAttributes().getNamedItem(getKeyAttribute());
if(keyNode == null)
{
- log.error("key attribuet missing for configuration " + node);
+ log.error("key attribute missing for configuration " + node);
continue;
}
String name = keyNode.getNodeValue();
@@ -194,19 +200,29 @@
}
//register with the deploymenmt manager
- public void start() throws Exception
+ public synchronized void start() throws Exception
{
+ if (started)
+ {
+ return;
+ }
+
deploymentManager.registerDeployer(this);
started = true;
}
//undeploy everything
- public void stop() throws Exception
+ public synchronized void stop() throws Exception
{
- Collection<HashMap<String, Node>> urls = configuration.values();
- for (HashMap<String, Node> hashMap : urls)
+ if (!started)
{
+ return;
+ }
+
+ Collection<Map<String, Node>> urls = configuration.values();
+ for (Map<String, Node> hashMap : urls)
+ {
for (Node node : hashMap.values())
{
try
@@ -224,7 +240,7 @@
started = false;
}
- public boolean isStarted()
+ public synchronized boolean isStarted()
{
return started;
}
@@ -241,18 +257,17 @@
* @param node the element to deploy
* @throws Exception .
*/
- public abstract void deploy(Node node)
- throws Exception;
+ public abstract void deploy(final Node node) throws Exception;
/**
* undeploys an element
* @param node the element to undeploy
* @throws Exception .
*/
- public abstract void undeploy(Node node)
+ public abstract void undeploy(final Node node)
throws Exception;
- protected Element getRootElement(URL url)
+ protected Element getRootElement(final URL url)
throws Exception
{
Reader reader = new InputStreamReader(url.openStream());
@@ -261,7 +276,7 @@
return XMLUtil.stringToElement(xml);
}
- private boolean hasNodeChanged(URL url, Node child, String name)
+ private boolean hasNodeChanged(final URL url, final Node child, final String name)
{
String newTextContent = child.getTextContent();
String origTextContent = configuration.get(url).get(name).getTextContent();
Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/core/deployers/impl/DeployerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/deployers/impl/DeployerTest.java 2008-06-23 10:41:32 UTC (rev 4548)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/deployers/impl/DeployerTest.java 2008-06-23 11:02:48 UTC (rev 4549)
@@ -1,248 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This 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 software 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.messaging.tests.unit.core.deployers.impl;
-
-
-import junit.framework.TestCase;
-import org.jboss.messaging.core.deployers.impl.XmlDeployer;
-import org.jboss.messaging.util.XMLUtil;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-/**
- * tests the abstract deployer class
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
- */
-public class DeployerTest extends TestCase
-{
- private String conf1 = "<deployment>\n" +
- " <test name=\"test1\">content1</test>\n" +
- " <test name=\"test2\">content2</test>\n" +
- " <test name=\"test3\">content3</test>\n" +
- " <test name=\"test4\">content4</test>\n" +
- "</deployment>";
-
- private String conf2 = "<deployment>\n" +
- " <test name=\"test1\">content1</test>\n" +
- " <test name=\"test2\">contenthaschanged2</test>\n" +
- " <test name=\"test3\">contenthaschanged3</test>\n" +
- " <test name=\"test4\">content4</test>\n" +
- "</deployment>";
-
- private String conf3 = "<deployment>\n" +
- " <test name=\"test1\">content1</test>\n" +
- " <test name=\"test2\">contenthaschanged2</test>\n" +
- "</deployment>";
-
- private String conf4 = "<deployment>\n" +
- " <test name=\"test1\">content1</test>\n" +
- " <test name=\"test2\">content2</test>\n" +
- " <test name=\"test3\">content3</test>\n" +
- " <test name=\"test4\">content4</test>\n" +
- " <test name=\"test5\">content5</test>\n" +
- " <test name=\"test6\">content6</test>\n" +
- "</deployment>";
-
- private URL url;
-
-
- protected void setUp() throws Exception
- {
- super.setUp();
- url = new URL("http://thisdoesntmatter");
- }
-
- public void testDeploy() throws Exception
- {
- Element e = XMLUtil.stringToElement(conf1);
- TestDeployer testDeployer = new TestDeployer();
- testDeployer.setElement(e);
- testDeployer.deploy(url);
- assertEquals(testDeployer.getDeployments(), 4);
- assertNotNull(testDeployer.getNodes().get("test1"));
- assertNotNull(testDeployer.getNodes().get("test2"));
- assertNotNull(testDeployer.getNodes().get("test3"));
- assertNotNull(testDeployer.getNodes().get("test4"));
- assertEquals(testDeployer.getNodes().get("test1").getTextContent(), "content1");
- assertEquals(testDeployer.getNodes().get("test2").getTextContent(), "content2");
- assertEquals(testDeployer.getNodes().get("test3").getTextContent(), "content3");
- assertEquals(testDeployer.getNodes().get("test4").getTextContent(), "content4");
- }
-
- public void testRedeploy() throws Exception
- {
- Element e = XMLUtil.stringToElement(conf1);
- TestDeployer testDeployer = new TestDeployer();
- testDeployer.setElement(e);
- testDeployer.deploy(url);
- e = XMLUtil.stringToElement(conf2);
- testDeployer.setElement(e);
- testDeployer.redeploy(url);
- assertEquals(testDeployer.getDeployments(), 4);
- assertNotNull(testDeployer.getNodes().get("test1"));
- assertNotNull(testDeployer.getNodes().get("test2"));
- assertNotNull(testDeployer.getNodes().get("test3"));
- assertNotNull(testDeployer.getNodes().get("test4"));
- assertEquals(testDeployer.getNodes().get("test1").getTextContent(), "content1");
- assertEquals(testDeployer.getNodes().get("test2").getTextContent(), "contenthaschanged2");
- assertEquals(testDeployer.getNodes().get("test3").getTextContent(), "contenthaschanged3");
- assertEquals(testDeployer.getNodes().get("test4").getTextContent(), "content4");
- }
-
- public void testRedeployRemovingNodes() throws Exception
- {
- Element e = XMLUtil.stringToElement(conf1);
- TestDeployer testDeployer = new TestDeployer();
- testDeployer.setElement(e);
- testDeployer.deploy(url);
- e = XMLUtil.stringToElement(conf3);
- testDeployer.setElement(e);
- testDeployer.redeploy(url);
- assertEquals(testDeployer.getDeployments(), 2);
- assertNotNull(testDeployer.getNodes().get("test1"));
- assertNotNull(testDeployer.getNodes().get("test2"));
- assertNull(testDeployer.getNodes().get("test3"));
- assertNull(testDeployer.getNodes().get("test4"));
- assertEquals(testDeployer.getNodes().get("test1").getTextContent(), "content1");
- assertEquals(testDeployer.getNodes().get("test2").getTextContent(), "contenthaschanged2");
- }
-
- public void testRedeployAddingNodes() throws Exception
- {
- Element e = XMLUtil.stringToElement(conf1);
- TestDeployer testDeployer = new TestDeployer();
- testDeployer.setElement(e);
- testDeployer.deploy(url);
- e = XMLUtil.stringToElement(conf4);
- testDeployer.setElement(e);
- testDeployer.redeploy(url);
- assertEquals(testDeployer.getDeployments(), 6);
- assertNotNull(testDeployer.getNodes().get("test1"));
- assertNotNull(testDeployer.getNodes().get("test2"));
- assertNotNull(testDeployer.getNodes().get("test3"));
- assertNotNull(testDeployer.getNodes().get("test4"));
- assertNotNull(testDeployer.getNodes().get("test5"));
- assertNotNull(testDeployer.getNodes().get("test6"));
- assertEquals(testDeployer.getNodes().get("test1").getTextContent(), "content1");
- assertEquals(testDeployer.getNodes().get("test2").getTextContent(), "content2");
- assertEquals(testDeployer.getNodes().get("test3").getTextContent(), "content3");
- assertEquals(testDeployer.getNodes().get("test4").getTextContent(), "content4");
- assertEquals(testDeployer.getNodes().get("test5").getTextContent(), "content5");
- assertEquals(testDeployer.getNodes().get("test6").getTextContent(), "content6");
- }
-
- public void testUndeploy() throws Exception
- {
- Element e = XMLUtil.stringToElement(conf1);
- TestDeployer testDeployer = new TestDeployer();
- testDeployer.setElement(e);
- testDeployer.deploy(url);
- testDeployer.undeploy(url);
- assertEquals(testDeployer.getDeployments(), 0);
- assertNull(testDeployer.getNodes().get("test1"));
- assertNull(testDeployer.getNodes().get("test2"));
- assertNull(testDeployer.getNodes().get("test3"));
- assertNull(testDeployer.getNodes().get("test4"));
- }
- class TestDeployer extends XmlDeployer
- {
- private String elementname = "test";
- Element element = null;
- private int deployments = 0;
- ArrayList<String> contents = new ArrayList<String>();
- HashMap<String, Node> nodes = new HashMap<String, Node>();
-
- public TestDeployer()
- {
- super(null);
- }
-
- public HashMap<String, Node> getNodes()
- {
- return nodes;
- }
-
- public ArrayList<String> getContents()
- {
- return contents;
- }
-
- public int getDeployments()
- {
- return deployments;
- }
-
- public String getElementname()
- {
- return elementname;
- }
-
- public void setElementname(String elementname)
- {
- this.elementname = elementname;
- }
-
- public Element getElement()
- {
- return element;
- }
-
- public void setElement(Element element)
- {
- this.element = element;
- }
-
- public String[] getElementTagName()
- {
- return new String[]{elementname};
- }
-
-
- public String getConfigFileName()
- {
- return "test";
- }
-
- public void deploy(Node node) throws Exception
- {
- deployments++;
- contents.add(node.getTextContent());
- nodes.put(node.getAttributes().getNamedItem(NAME_ATTR).getNodeValue(), node);
- }
-
- public void undeploy(Node node) throws Exception
- {
- deployments--;
- nodes.remove(node.getAttributes().getNamedItem(NAME_ATTR).getNodeValue());
- }
-
- protected Element getRootElement(URL url)
- {
- return element;
- }
- }
-}
Copied: trunk/tests/src/org/jboss/messaging/tests/unit/core/deployers/impl/XMLDeployerTest.java (from rev 4547, trunk/tests/src/org/jboss/messaging/tests/unit/core/deployers/impl/DeployerTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/deployers/impl/XMLDeployerTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/deployers/impl/XMLDeployerTest.java 2008-06-23 11:02:48 UTC (rev 4549)
@@ -0,0 +1,248 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.unit.core.deployers.impl;
+
+
+import junit.framework.TestCase;
+import org.jboss.messaging.core.deployers.impl.XmlDeployer;
+import org.jboss.messaging.util.XMLUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+/**
+ * tests the abstract xml deployer class
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class XMLDeployerTest extends TestCase
+{
+ private static final String conf1 = "<deployment>\n" +
+ " <test name=\"test1\">content1</test>\n" +
+ " <test name=\"test2\">content2</test>\n" +
+ " <test name=\"test3\">content3</test>\n" +
+ " <test name=\"test4\">content4</test>\n" +
+ "</deployment>";
+
+ private static final String conf2 = "<deployment>\n" +
+ " <test name=\"test1\">content1</test>\n" +
+ " <test name=\"test2\">contenthaschanged2</test>\n" +
+ " <test name=\"test3\">contenthaschanged3</test>\n" +
+ " <test name=\"test4\">content4</test>\n" +
+ "</deployment>";
+
+ private static final String conf3 = "<deployment>\n" +
+ " <test name=\"test1\">content1</test>\n" +
+ " <test name=\"test2\">contenthaschanged2</test>\n" +
+ "</deployment>";
+
+ private static final String conf4 = "<deployment>\n" +
+ " <test name=\"test1\">content1</test>\n" +
+ " <test name=\"test2\">content2</test>\n" +
+ " <test name=\"test3\">content3</test>\n" +
+ " <test name=\"test4\">content4</test>\n" +
+ " <test name=\"test5\">content5</test>\n" +
+ " <test name=\"test6\">content6</test>\n" +
+ "</deployment>";
+
+ private URL url;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ url = new URL("http://thisdoesntmatter");
+ }
+
+ public void testDeploy() throws Exception
+ {
+ Element e = XMLUtil.stringToElement(conf1);
+ TestDeployer testDeployer = new TestDeployer();
+ testDeployer.setElement(e);
+ testDeployer.deploy(url);
+ assertEquals(testDeployer.getDeployments(), 4);
+ assertNotNull(testDeployer.getNodes().get("test1"));
+ assertNotNull(testDeployer.getNodes().get("test2"));
+ assertNotNull(testDeployer.getNodes().get("test3"));
+ assertNotNull(testDeployer.getNodes().get("test4"));
+ assertEquals(testDeployer.getNodes().get("test1").getTextContent(), "content1");
+ assertEquals(testDeployer.getNodes().get("test2").getTextContent(), "content2");
+ assertEquals(testDeployer.getNodes().get("test3").getTextContent(), "content3");
+ assertEquals(testDeployer.getNodes().get("test4").getTextContent(), "content4");
+ }
+
+ public void testRedeploy() throws Exception
+ {
+ Element e = XMLUtil.stringToElement(conf1);
+ TestDeployer testDeployer = new TestDeployer();
+ testDeployer.setElement(e);
+ testDeployer.deploy(url);
+ e = XMLUtil.stringToElement(conf2);
+ testDeployer.setElement(e);
+ testDeployer.redeploy(url);
+ assertEquals(testDeployer.getDeployments(), 4);
+ assertNotNull(testDeployer.getNodes().get("test1"));
+ assertNotNull(testDeployer.getNodes().get("test2"));
+ assertNotNull(testDeployer.getNodes().get("test3"));
+ assertNotNull(testDeployer.getNodes().get("test4"));
+ assertEquals(testDeployer.getNodes().get("test1").getTextContent(), "content1");
+ assertEquals(testDeployer.getNodes().get("test2").getTextContent(), "contenthaschanged2");
+ assertEquals(testDeployer.getNodes().get("test3").getTextContent(), "contenthaschanged3");
+ assertEquals(testDeployer.getNodes().get("test4").getTextContent(), "content4");
+ }
+
+ public void testRedeployRemovingNodes() throws Exception
+ {
+ Element e = XMLUtil.stringToElement(conf1);
+ TestDeployer testDeployer = new TestDeployer();
+ testDeployer.setElement(e);
+ testDeployer.deploy(url);
+ e = XMLUtil.stringToElement(conf3);
+ testDeployer.setElement(e);
+ testDeployer.redeploy(url);
+ assertEquals(testDeployer.getDeployments(), 2);
+ assertNotNull(testDeployer.getNodes().get("test1"));
+ assertNotNull(testDeployer.getNodes().get("test2"));
+ assertNull(testDeployer.getNodes().get("test3"));
+ assertNull(testDeployer.getNodes().get("test4"));
+ assertEquals(testDeployer.getNodes().get("test1").getTextContent(), "content1");
+ assertEquals(testDeployer.getNodes().get("test2").getTextContent(), "contenthaschanged2");
+ }
+
+ public void testRedeployAddingNodes() throws Exception
+ {
+ Element e = XMLUtil.stringToElement(conf1);
+ TestDeployer testDeployer = new TestDeployer();
+ testDeployer.setElement(e);
+ testDeployer.deploy(url);
+ e = XMLUtil.stringToElement(conf4);
+ testDeployer.setElement(e);
+ testDeployer.redeploy(url);
+ assertEquals(testDeployer.getDeployments(), 6);
+ assertNotNull(testDeployer.getNodes().get("test1"));
+ assertNotNull(testDeployer.getNodes().get("test2"));
+ assertNotNull(testDeployer.getNodes().get("test3"));
+ assertNotNull(testDeployer.getNodes().get("test4"));
+ assertNotNull(testDeployer.getNodes().get("test5"));
+ assertNotNull(testDeployer.getNodes().get("test6"));
+ assertEquals(testDeployer.getNodes().get("test1").getTextContent(), "content1");
+ assertEquals(testDeployer.getNodes().get("test2").getTextContent(), "content2");
+ assertEquals(testDeployer.getNodes().get("test3").getTextContent(), "content3");
+ assertEquals(testDeployer.getNodes().get("test4").getTextContent(), "content4");
+ assertEquals(testDeployer.getNodes().get("test5").getTextContent(), "content5");
+ assertEquals(testDeployer.getNodes().get("test6").getTextContent(), "content6");
+ }
+
+ public void testUndeploy() throws Exception
+ {
+ Element e = XMLUtil.stringToElement(conf1);
+ TestDeployer testDeployer = new TestDeployer();
+ testDeployer.setElement(e);
+ testDeployer.deploy(url);
+ testDeployer.undeploy(url);
+ assertEquals(testDeployer.getDeployments(), 0);
+ assertNull(testDeployer.getNodes().get("test1"));
+ assertNull(testDeployer.getNodes().get("test2"));
+ assertNull(testDeployer.getNodes().get("test3"));
+ assertNull(testDeployer.getNodes().get("test4"));
+ }
+
+ class TestDeployer extends XmlDeployer
+ {
+ private String elementname = "test";
+ Element element = null;
+ private int deployments = 0;
+ ArrayList<String> contents = new ArrayList<String>();
+ HashMap<String, Node> nodes = new HashMap<String, Node>();
+
+ public TestDeployer()
+ {
+ super(null);
+ }
+
+ public HashMap<String, Node> getNodes()
+ {
+ return nodes;
+ }
+
+ public ArrayList<String> getContents()
+ {
+ return contents;
+ }
+
+ public int getDeployments()
+ {
+ return deployments;
+ }
+
+ public String getElementname()
+ {
+ return elementname;
+ }
+
+ public void setElementname(String elementname)
+ {
+ this.elementname = elementname;
+ }
+
+ public Element getElement()
+ {
+ return element;
+ }
+
+ public void setElement(Element element)
+ {
+ this.element = element;
+ }
+
+ public String[] getElementTagName()
+ {
+ return new String[]{elementname};
+ }
+
+
+ public String getConfigFileName()
+ {
+ return "test";
+ }
+
+ public void deploy(Node node) throws Exception
+ {
+ deployments++;
+ contents.add(node.getTextContent());
+ nodes.put(node.getAttributes().getNamedItem(NAME_ATTR).getNodeValue(), node);
+ }
+
+ public void undeploy(Node node) throws Exception
+ {
+ deployments--;
+ nodes.remove(node.getAttributes().getNamedItem(NAME_ATTR).getNodeValue());
+ }
+
+ protected Element getRootElement(URL url)
+ {
+ return element;
+ }
+ }
+}
More information about the jboss-cvs-commits
mailing list