/*
 * ################################################################
 *
 * ProActive Parallel Suite(TM): The Java(TM) library for
 *    Parallel, Distributed, Multi-Core Computing for
 *    Enterprise Grids & Clouds
 *
 * Copyright (C) 1997-2011 INRIA/University of
 *                 Nice-Sophia Antipolis/ActiveEon
 * Contact: proactive@ow2.org or contact@activeeon.com
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Affero General Public License
 * as published by the Free Software Foundation; version 3 of
 * the License.
 *
 * 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
 * Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero 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
 *
 * If needed, contact us to obtain a release under GPL Version 2 or 3
 * or a different license than the AGPL.
 *
 *  Initial developer(s):               The ActiveEon Team
 *                        http://www.activeeon.com/
 *  Contributor(s):
 *
 * ################################################################
 * $$ACTIVEEON_INITIAL_DEV$$
 */
package functionaltests.nodestate;

import org.objectweb.proactive.core.node.Node;
import org.ow2.proactive.resourcemanager.common.event.RMEventType;
import org.ow2.proactive.resourcemanager.core.RMCore;
import org.ow2.proactive.resourcemanager.frontend.ResourceManager;
import org.ow2.proactive.resourcemanager.nodesource.infrastructure.DefaultInfrastructureManager;
import org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy;

import functionaltests.RMConsecutive;
import functionaltests.RMTHelper;


/**
 * This class tests a particular case of node add/removal where a race condition
 * exists and that lead to dead lock in the past.
 * Running this test ensure that at least the dead lock doesn't occur.
 */
public class TestAddRemoveAll extends RMConsecutive {

    private String nodeName = "nodeDeadLock";
    private String nsName = "TestAddRemoveAll";

    @org.junit.Test
    public void action() throws Exception {
        RMTHelper helper = RMTHelper.getDefaultInstance();

        ResourceManager resourceManager = helper.getResourceManager();
        RMTHelper.log("Add/RemoveAll");
        resourceManager.createNodeSource(nsName, DefaultInfrastructureManager.class.getName(), null,
                StaticPolicy.class.getName(), null);
        helper.waitForNodeSourceEvent(RMEventType.NODESOURCE_CREATED, nsName);
        Node nodeToAdd = helper.createNode(nodeName).getNode();
        resourceManager.addNode(nodeToAdd.getNodeInformation().getURL(), nsName).getBooleanValue();
        //at this time, nodes maybe fully added in the nodesource but not in the core
        //the next removal may fail for some nodes that are not known by the core...
        RMCore resourceManagerIMPL = (RMCore) resourceManager;
        resourceManagerIMPL.removeAllNodes(nsName, true);
        if (resourceManager.getState().getTotalNodesNumber() != 0) {
            RMTHelper.log("The removeAll method in RMCore didn't removed all nodes");
        } else {
            RMTHelper.log("The removeAll method in RMCore did its job well");
        }
    }
}

@@ -1566,62 +1566,8 @@
 pe;%0A
-import org.ow2.proactive.resourcemanager.core.RMCore;%0A
 impo
@@ -1799,17 +1799,16 @@
 Policy;%0A
-%0A
 import f
@@ -3044,23 +3044,16 @@
         
-RMCore 
 resource
@@ -3063,83 +3063,25 @@
 ager
-IMPL = (RMCore) resourceManager;%0A        resourceManagerIMPL
 .remove
-All
 Node
-s
+Source
 (nsN

remove the cast for RM interface to RMCore