01: /******************************************************************************
02: * Copyright (C) Lars Ivar Almli. All rights reserved. *
03: * ---------------------------------------------------------------------------*
04: * This file is part of MActor. *
05: * *
06: * MActor is free software; you can redistribute it and/or modify *
07: * it under the terms of the GNU General Public License as published by *
08: * the Free Software Foundation; either version 2 of the License, or *
09: * (at your option) any later version. *
10: * *
11: * MActor is distributed in the hope that it will be useful, *
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14: * GNU General Public License for more details. *
15: * *
16: * You should have received a copy of the GNU General Public License *
17: * along with MActor; if not, write to the Free Software *
18: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
19: ******************************************************************************/package org.mactor.extensions;
20:
21: import java.util.List;
22: import org.mactor.framework.ConfigException;
23: import org.mactor.framework.MactorException;
24: import org.mactor.framework.TestContext;
25: import org.mactor.framework.extensioninterface.ActionCommand;
26:
27: /**
28: * Asserts that the two provider parameters are equal
29: *
30: * @author Lars Ivar Almli
31: */
32: public class AssertEqualsValidator implements ActionCommand {
33: public void perform(TestContext context, List<String> params)
34: throws MactorException {
35: if (params.size() != 2)
36: throw new ConfigException(
37: "Invalid testspec. Two parameter srequiered: [<the value 1>,<the value 2>]>");
38: if (!isEqual(params.get(0), params.get(1)))
39: throw new MactorException("Assertions failed. '"
40: + params.get(1) + "' not equal to '"
41: + params.get(0) + "'");
42: }
43:
44: public static boolean isEqual(String s1, String s2) {
45: if (s1 == null && s2 == null)
46: return true;
47: if (s1 == null)
48: return false;
49: return s1.equals(s2);
50: }
51: }
|