/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * 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 com.xpn.xwiki.it.selenium;

import junit.framework.Test;

import com.xpn.xwiki.it.selenium.framework.AbstractXWikiTestCase;
import com.xpn.xwiki.it.selenium.framework.ColibriSkinExecutor;
import com.xpn.xwiki.it.selenium.framework.XWikiTestSuite;

/**
 * Verify the data validation feature of XWiki.
 * 
 * @version $Id$
 */
public class ValidationTest extends AbstractXWikiTestCase
{
    private static final String SYNTAX = "xwiki/1.0";
    
    public static Test suite()
    {
        XWikiTestSuite suite = new XWikiTestSuite("Verify the data validation feature of XWiki");
        suite.addTestSuite(ValidationTest.class, ColibriSkinExecutor.class);
        return suite;
    }

    @Override
    protected void setUp() throws Exception
    {
        super.setUp();
        loginAsAdmin();
    }

    public void testSaveActionValidatesWhenXValidateIsPresent()
    {
        deletePage("Main", "ValidatedClass");
        open("Main", "ValidatedClass", "edit", "editor=class");
        setFieldValue("propname", "prop");
        setFieldValue("proptype", "com.xpn.xwiki.objects.classes.StringClass");
        submit("//input[@value='Add Property']");
        setFieldValue("prop_validationRegExp", "/^[0-4][0-2]$/");
        setFieldValue("prop_validationMessage", "invalid value for prop");
        clickEditSaveAndView();
        createPage("Main", "ValidatedObject",
            "value: $doc.display('prop')\n\n#foreach($e in $context.validationStatus.errors)$e #end", SYNTAX);
        open("Main", "ValidatedObject", "edit", "editor=object");
        setFieldValue("classname", "Main.ValidatedClass");
        submit("//input[@value='Add Object from this Class']");
        setFieldValue("Main.ValidatedClass_0_prop", "22");
        clickEditSaveAndView();
        open("Main", "ValidatedObject", "save", "xvalidate=1");
        assertTextPresent("value: 22");
        open("Main", "ValidatedObject", "edit", "editor=object");
        setFieldValue("Main.ValidatedClass_0_prop", "44");
        clickEditSaveAndView();
        open("Main", "ValidatedObject", "save", "xvalidate=1");
        assertTextNotPresent("value: 44");
        assertTextPresent("invalid value for prop");
        open("Main", "ValidatedObject", "save", "xvalidate=1&Main.ValidatedClass_0_prop=11");
        assertTextPresent("value: 11");
    }
}

@@ -2013,44 +2013,61 @@
     
-submit(%22//input%5B@value='Add Property
+clickButtonAndContinue(%22//input%5B@name='action_propadd
 '%5D%22)
@@ -2535,58 +2535,63 @@
     
-submit(%22//input%5B@value='Add Object from this Class
+clickButtonAndContinue(%22//input%5B@name='action_objectadd
 '%5D%22)

Improve the class and object editors Fix selenium tests