Update of 
/cvsroot/xdoclet-plugins/xdoclet-plugins/taglib-qtags/src/test/java/org/xdoclet/plugin/qtags/qtags
In directory 
sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv28258/taglib-qtags/src/test/java/org/xdoclet/plugin/qtags/qtags

Added Files:
        QtagsTestCase.java 
Log Message:
started work on split qtags in plugin and taglib for m2 build


--- NEW FILE: QtagsTestCase.java ---
/*
 * Copyright (c) 2003
 * XDoclet Team
 * All rights reserved.
 */
package org.xdoclet.plugin.qtags.qtags;

import junit.framework.TestCase;

import java.util.Arrays;
import java.util.List;

import org.xdoclet.XDocletTag;

import com.thoughtworks.qdox.model.AbstractJavaEntity;
import com.thoughtworks.qdox.model.JavaClass;
import com.thoughtworks.qdox.model.JavaField;
import com.thoughtworks.qdox.model.JavaMethod;
import com.thoughtworks.qdox.model.JavaSource;

/**
 * test suite for qtags capabilities in metacircular way.
 *
 * @author Konstantin Pribluda
 */
public class QtagsTestCase extends TestCase {
    private JavaClass clazz;
    private JavaField field;
    private JavaMethod constructor;
    private JavaMethod method;

    /**
     * qtags.allowed-value can be used on class or method level
     */
    public void testQtagsAllowedValueTag() throws Exception {
        allowedValueTag(method);
        allowedValueTag(clazz);

        try {
            allowedValueTag(field);
            fail();
        } catch (RuntimeException expected) {
        }

        try {
            allowedValueTag(constructor);
            fail();
        } catch (RuntimeException ex) {
        }
    }

    public void testQtagsDefaultTagShouldOnlyBeAllowedOnMethodOnce() throws 
Exception {
        XDocletTag tagOne = defaultTag(method);
        XDocletTag tagTwo = defaultTag(method);
        List tags = Arrays.asList(new XDocletTag[] {tagOne, tagTwo});

        try {
            method.setTags(tags);
            //            fail("only one is allowed");
        } catch (RuntimeException expected) {
        }

        try {
            defaultTag(clazz);
            fail();
        } catch (RuntimeException expected) {
        }

        try {
            defaultTag(field);
            fail();
        } catch (RuntimeException expected) {
        }

        try {
            defaultTag(constructor);
            fail();
        } catch (RuntimeException expected) {
        }
    }

    public void testQtagsDeprecatedTagShouldOnlyBeAllowedOnClassOnce() throws 
Exception {
        XDocletTag tagOne = deprecatedTag(clazz);
        XDocletTag tagTwo = deprecatedTag(clazz);
        List tags = Arrays.asList(new XDocletTag[] {tagOne, tagTwo});

        try {
            clazz.setTags(tags);
            //            fail("only one is allowed");
        } catch (RuntimeException expected) {
        }

        try {
            deprecatedTag(method);
            fail();
        } catch (RuntimeException expected) {
        }

        try {
            deprecatedTag(field);
            fail();
        } catch (RuntimeException expected) {
        }

        try {
            deprecatedTag(constructor);
            fail();
        } catch (RuntimeException expected) {
        }
    }

    public void testQtagsIgnoreTagShouldOnlyBeAllowedOnClassOnce() throws 
Exception {
        XDocletTag tagOne = ignoreTag(clazz);
        XDocletTag tagTwo = ignoreTag(clazz);
        List tags = Arrays.asList(new XDocletTag[] {tagOne, tagTwo});

        try {
            clazz.setTags(tags);
            //            fail("only one is allowed");
        } catch (RuntimeException expected) {
        }

        try {
            ignoreTag(method);
            fail();
        } catch (RuntimeException expected) {
        }

        try {
            ignoreTag(field);
            fail();
        } catch (RuntimeException expected) {
        }

        try {
            ignoreTag(constructor);
            fail();
        } catch (RuntimeException expected) {
        }
    }

    public void 
testQtagsLocationTagShouldOnlyBeAllowedOnClassWithConstrainedValues()
        throws Exception {
        XDocletTag tagOne = locationTag(clazz, "class");
        XDocletTag tagTwo = locationTag(clazz, "method");
        XDocletTag tagThree = locationTag(clazz, "field");
        XDocletTag tagFour = locationTag(clazz, "constructor");

        try {
            locationTag(clazz, "blah");
            fail();
        } catch (RuntimeException expected) {
        }

        List tags = Arrays.asList(new XDocletTag[] {tagOne, tagTwo, tagThree, 
tagFour});

        try {
            clazz.setTags(tags);
            //            fail("only one is allowed");
        } catch (RuntimeException expected) {
        }

        try {
            locationTag(method, "method");
            fail();
        } catch (RuntimeException expected) {
        }

        try {
            locationTag(field, "field");
            fail();
        } catch (RuntimeException expected) {
        }

        try {
            locationTag(constructor, "constructor");
            fail();
        } catch (RuntimeException expected) {
        }
    }

    public void testQtagsOnceTagShouldOnlyBeAllowedOnClassOnce() throws 
Exception {
        XDocletTag tagOne = onceTag(clazz);
        XDocletTag tagTwo = onceTag(clazz);
        List tags = Arrays.asList(new XDocletTag[] {tagOne, tagTwo});

        try {
            clazz.setTags(tags);
            //            fail("only one is allowed");
        } catch (RuntimeException expected) {
        }

        try {
            onceTag(method);
            fail();
        } catch (RuntimeException expected) {
        }

        try {
            onceTag(field);
            fail();
        } catch (RuntimeException expected) {
        }

        try {
            onceTag(constructor);
            fail();
        } catch (RuntimeException expected) {
        }
    }

    public void testQtagsRequiredTagShouldOnlyBeAllowedOnMethodOnce() throws 
Exception {
        XDocletTag tagOne = requiredTag(method);
        XDocletTag tagTwo = requiredTag(method);
        List tags = Arrays.asList(new XDocletTag[] {tagOne, tagTwo});

        try {
            method.setTags(tags);
            //            fail("only one is allowed");
        } catch (RuntimeException expected) {
        }

        try {
            requiredTag(clazz);
            fail();
        } catch (RuntimeException expected) {
        }

        try {
            requiredTag(field);
            fail();
        } catch (RuntimeException expected) {
        }

        try {
            requiredTag(constructor);
            fail();
        } catch (RuntimeException expected) {
        }
    }

    public void testQtagsVerbatimTagShouldOnlyBeAllowedOnMethodOnce() throws 
Exception {
        XDocletTag tagOne = verbatimTag(method);
        XDocletTag tagTwo = verbatimTag(method);
        List tags = Arrays.asList(new XDocletTag[] {tagOne, tagTwo});

        try {
            method.setTags(tags);
            //            fail("only one is allowed");
        } catch (RuntimeException expected) {
        }

        try {
            verbatimTag(clazz);
            fail();
        } catch (RuntimeException expected) {
        }

        try {
            verbatimTag(field);
            fail();
        } catch (RuntimeException expected) {
        }

        try {
            verbatimTag(constructor);
            fail();
        } catch (RuntimeException expected) {
        }
    }

    protected void setUp() throws Exception {
        super.setUp();
        clazz = new JavaClass();
        clazz.setParent(new JavaSource());
        method = new JavaMethod();
        method.setParent(clazz);
        constructor = new JavaMethod();
        constructor.setParent(clazz);
        constructor.setConstructor(true);
        field = new JavaField();
        field.setParent(clazz);
    }

    private XDocletTag allowedValueTag(AbstractJavaEntity entity) {
        return new QtagsAllowedValueTagImpl(QtagsAllowedValueTagImpl.NAME, " 
blurge dsdh dsjk sdjk hdjkfh s", entity, 22);
    }

    private XDocletTag defaultTag(AbstractJavaEntity entity) {
        return new QtagsDefaultTagImpl(QtagsDefaultTagImpl.NAME, " blurge dsdh 
dsjk sdjk hdjkfh s", entity, 22);
    }

    private XDocletTag deprecatedTag(AbstractJavaEntity entity) {
        return new QtagsDeprecatedTagImpl(QtagsDeprecatedTagImpl.NAME, " blurge 
dsdh dsjk sdjk hdjkfh s", entity, 22);
    }

    private XDocletTag ignoreTag(AbstractJavaEntity entity) {
        return new QtagsIgnoreTagImpl(QtagsIgnoreTagImpl.NAME, " blurge dsdh 
dsjk sdjk hdjkfh s", entity, 22);
    }

    private XDocletTag locationTag(AbstractJavaEntity entity, String value) {
        return new QtagsLocationTagImpl(QtagsLocationTagImpl.NAME, value, 
entity, 22);
    }

    private XDocletTag onceTag(AbstractJavaEntity entity) {
        return new QtagsOnceTagImpl(QtagsOnceTagImpl.NAME, " blurge dsdh dsjk 
sdjk hdjkfh s", entity, 22);
    }

    private XDocletTag requiredTag(AbstractJavaEntity entity) {
        return new QtagsRequiredTagImpl(QtagsRequiredTagImpl.NAME, " blurge 
dsdh dsjk sdjk hdjkfh s", entity, 22);
    }

    private XDocletTag verbatimTag(AbstractJavaEntity entity) {
        return new QtagsVerbatimTagImpl(QtagsVerbatimTagImpl.NAME, " blurge 
dsdh dsjk sdjk hdjkfh s", entity, 22);
    }
}

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
xdoclet-plugins-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xdoclet-plugins-commits

Reply via email to