Update of 
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-qtags/src/test/java/org/xdoclet/plugin/qtags/impl
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30066/plugin-qtags/src/test/java/org/xdoclet/plugin/qtags/impl

Added Files:
        QTagOldOnceImplTestCase.java 
Log Message:
fix for XDP-77



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

import java.net.URL;

import org.xdoclet.QDoxMetadataProvider;
import org.xdoclet.plugin.qtags.impl.test.FooBarOnceTagImpl;
import org.xdoclet.plugin.qtags.impl.test.FooBarOnceTagNewImpl;

import junit.framework.TestCase;

/**
 * @author Diogo Quintela
 */
public class QTagOldOnceImplTestCase extends TestCase {
    protected URL getResourceRelativeToThisPackage(String resourceName) {
        String className = getClass().getName();
        String packageName = className.substring(0, className.lastIndexOf('.'));
        String resourcePath = "/" + packageName.replace('.', '/' ) + "/" + 
resourceName;
        URL resource = getClass().getResource(resourcePath);
        assertNotNull("Resource not found at path: " + resourcePath, resource);
        return resource;
    }

    public void testOldQTagOnceFailingImpl() {
        URL testSource = 
getResourceRelativeToThisPackage("test/BeanUsingOnceQTags.java");
        QDoxMetadataProvider metadataProvider = new 
QDoxMetadataProvider(testSource, Boolean.TRUE);
        
metadataProvider.getDocletTagFactory().registerTag(FooBarOnceTagImpl.NAME, 
FooBarOnceTagImpl.class);

        metadataProvider.start();
        metadataProvider.getMetadata();
        // This should have failed because BeanUsingOnceQTags.java
        // declares @foo.bar-once more than one
        metadataProvider.stop();
    }

    public void testNewQTagOnceFailingImpl() {
        URL testSource = 
getResourceRelativeToThisPackage("test/BeanUsingOnceQTags.java");
        QDoxMetadataProvider metadataProvider = new 
QDoxMetadataProvider(testSource, Boolean.TRUE);
        
metadataProvider.getDocletTagFactory().registerTag(FooBarOnceTagNewImpl.NAME, 
FooBarOnceTagNewImpl.class);

        try {
            metadataProvider.start();
            metadataProvider.getMetadata();
            fail("This should have failed because BeanUsingOnceQTags.java 
declares @foo.bar-once more than one");
        } catch (RuntimeException rex) {
            // OK. It's failing
            assertTrue(rex.getMessage().indexOf("is allowed only once") > -1);
            System.out.println("As expected, parsing of BeanUsingOnceQTags is 
failing");
        } finally {
            metadataProvider.stop();
        }
    }
}



-------------------------------------------------------
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