cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hu...@apache.org
Subject cvs commit: cocoon-2.1/src/test/org/apache/cocoon SitemapComponentTestCase.java
Date Sun, 04 Jul 2004 17:52:29 GMT
huber       2004/07/04 10:52:29

  Modified:    src/test/org/apache/cocoon SitemapComponentTestCase.java
  Log:
  added method for testing selector
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.9       +55 -8     cocoon-2.1/src/test/org/apache/cocoon/SitemapComponentTestCase.java
  
  Index: SitemapComponentTestCase.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/test/org/apache/cocoon/SitemapComponentTestCase.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SitemapComponentTestCase.java	28 Jun 2004 08:28:38 -0000	1.8
  +++ SitemapComponentTestCase.java	4 Jul 2004 17:52:29 -0000	1.9
  @@ -77,7 +77,7 @@
       private MockResponse response = new MockResponse();
       private MockContext context = new MockContext();
       private MockRedirector redirector = new MockRedirector();
  -    private HashMap objectmodel = new HashMap();
  +    private Map objectmodel = new HashMap();
   
       /**
        * Create a new composite test case.
  @@ -169,7 +169,49 @@
           }
           return result;
       }
  -    
  +
  +    /**
  +     * Select with a pattern.
  +     *
  +     * @param type Hint of the matcher. 
  +     * @param expression Expression for the selector.
  +     * @param parameters Matcher parameters.
  +     */
  +    public final boolean select(String type, String expression, Parameters parameters)
{
  +
  +        ComponentSelector selector = null;
  +        org.apache.cocoon.selection.Selector sel = null;
  +        SourceResolver resolver = null;
  +
  +        boolean result = false;
  +        try {
  +            selector = (ComponentSelector) this.manager.lookup(org.apache.cocoon.selection.Selector.ROLE
+
  +                "Selector");
  +            assertNotNull("Test lookup of selector selector", selector);
  +
  +            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
  +            assertNotNull("Test lookup of source resolver", resolver);
  +
  +            assertNotNull("Test if selector name is not null", type);
  +            sel = (org.apache.cocoon.selection.Selector) selector.select(type);
  +            assertNotNull("Test lookup of selector", sel);
  +            
  +
  +            result = sel.select(expression, objectmodel, parameters);
  +
  +        } catch (ComponentException ce) {
  +            getLogger().error("Could not retrieve selector", ce);
  +            fail("Could not retrieve selector: " + ce.toString());
  +        } finally {
  +            if (sel != null) {
  +                selector.release(sel);
  +            }
  +            this.manager.release(selector);
  +            this.manager.release(resolver);
  +        }
  +        return result;
  +    }
  +
       /**
        * Perform the action component.
        *
  @@ -327,20 +369,25 @@
               ce.printStackTrace();
               fail("Could not retrieve transformer:"+ce.toString());
           } finally {
  -            if (transformer!=null)
  +            if (transformer!=null) {
                   selector.release(transformer);
  +            }
   
  -            if (selector!=null)
  +            if (selector!=null) {
                   this.manager.release(selector);
  +            }
   
  -            if (inputsource!=null)
  +            if (inputsource!=null) {
                   resolver.release(inputsource);
  +            }
   
  -            if (resolver!=null)
  +            if (resolver!=null) {
                   this.manager.release(resolver);
  +            }
   
  -            if (parser!=null)
  +            if (parser!=null) {
                   this.manager.release((Component) parser);
  +            }
           }
   
           return document; 
  
  
  

Mime
View raw message