You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by we...@apache.org on 2004/05/11 20:30:11 UTC

cvs commit: jakarta-jetspeed-2/components/locator/src/test/org/apache/jetspeed/locator TestTemplateLocator.java

weaver      2004/05/11 11:30:11

  Modified:    components/locator/src/test/org/apache/jetspeed/locator Tag:
                        NANOCONTAINER_DEPLOYER TestTemplateLocator.java
  Added:       components/locator/src/test Tag: NANOCONTAINER_DEPLOYER
                        log4j.properties
  Removed:     components/locator/src/test Tag: NANOCONTAINER_DEPLOYER
                        Log4j.properties
  Log:
  - lowercased log4j so it is automatically loaded
  - uses new test suite
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.1   +43 -0     jakarta-jetspeed-2/components/locator/src/test/Attic/log4j.properties
  
  
  
  
  No                   revision
  No                   revision
  1.1.2.2   +130 -126  jakarta-jetspeed-2/components/locator/src/test/org/apache/jetspeed/locator/Attic/TestTemplateLocator.java
  
  Index: TestTemplateLocator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/locator/src/test/org/apache/jetspeed/locator/Attic/TestTemplateLocator.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- TestTemplateLocator.java	20 Apr 2004 16:25:10 -0000	1.1.2.1
  +++ TestTemplateLocator.java	11 May 2004 18:30:11 -0000	1.1.2.2
  @@ -1,126 +1,130 @@
  -/*
  - * Copyright 2000-2004 The Apache Software Foundation.
  - * 
  - * Licensed under the Apache License, Version 2.0 (the "License");
  - * you may not use this file except in compliance with the License.
  - * You may obtain a copy of the License at
  - * 
  - *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  - * Unless required by applicable law or agreed to in writing, software
  - * distributed under the License is distributed on an "AS IS" BASIS,
  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - * See the License for the specific language governing permissions and
  - * limitations under the License.
  - */
  -package org.apache.jetspeed.locator;
  -
  -import java.io.File;
  -
  -import junit.framework.Test;
  -
  -import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
  -import org.apache.jetspeed.components.NanoDeployerBasedTestSuite;
  -
  -/**
  - * TestTemplateLocator
  - *
  - * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  - * @version $Id$
  - */
  -public class TestTemplateLocator extends AbstractComponentAwareTestCase
  -{
  -    public TestTemplateLocator(String name) 
  -    {
  -        super( name );
  -    }
  -    
  -    
  -    /**
  -     * Start the tests.
  -     *
  -     * @param args the arguments. Not used
  -     */
  -    public static void main(String args[]) 
  -    {
  -        junit.awtui.TestRunner.main( new String[] { TestTemplateLocator.class.getName() } );
  -    }
  -
  -    public static Test suite()
  -    {
  -        // All methods starting with "test" will be executed in the test suite.
  -        NanoDeployerBasedTestSuite suite = new NanoDeployerBasedTestSuite(TestTemplateLocator.class);
  -        
  -        return suite;
  -    }
  -            
  -    public void testLocateTemplate()
  -          throws Exception
  -    {
  -        File appRoot = new File(System.getProperty("org.apache.jetspeed.application_root"));
  -        
  -        assertTrue("The application root, "+appRoot+", could not be located.", appRoot.exists());
  -        
  -        TemplateLocator component = (TemplateLocator)getContainer().getComponentInstance("TemplateLocator");
  -        assertNotNull("template service is null", component);            
  -        LocatorDescriptor locator = component.createLocatorDescriptor("email");
  -        locator.setName("test.vm");
  -        TemplateDescriptor template = component.locateTemplate(locator);
  -        assertNotNull("template is null", template);
  -        System.out.println("template1 = " + template);
  -        assertTrue("template1 result", "type/email/name/test.vm".endsWith(template.toString()));
  -        
  -        LocatorDescriptor locator2 = component.createLocatorDescriptor("email");
  -        locator2.setName("htmltest.vm");
  -        locator2.setMediaType("html");        
  -        template = component.locateTemplate(locator2);
  -        assertNotNull("template is null", template);                
  -        System.out.println("template2 = " + template);            
  -        assertTrue("template2 result", "type/email/media-type/html/name/htmltest.vm".endsWith(template.toString()));
  -
  -        LocatorDescriptor locator3 = component.createLocatorDescriptor("email");
  -        locator3.setName("entest.vm");
  -        locator3.setMediaType("html");
  -        locator3.setLanguage("en");                
  -        template = component.locateTemplate(locator3);
  -        assertNotNull("template is null", template);        
  -        System.out.println("template3 = " + template);            
  -        assertTrue("template3 result", "type/email/media-type/html/language/en/name/entest.vm".endsWith(template.toString()));
  -
  -        LocatorDescriptor locator4 = component.createLocatorDescriptor("email");
  -        locator4.setName("ustest.vm");
  -        locator4.setMediaType("html");
  -        locator4.setLanguage("en");
  -        locator4.setCountry("US");                
  -        template = component.locateTemplate(locator4);
  -        assertNotNull("template is null", template);        
  -        System.out.println("template4 = " + template);            
  -        assertTrue("template4 result", 
  -            "type/email/media-type/html/language/en/country/US/name/ustest.vm".endsWith(template.toString()));
  -
  -        // test fallback
  -        LocatorDescriptor locator5 = component.createLocatorDescriptor("email");
  -        locator5.setName("entest.vm");
  -        locator5.setMediaType("html");
  -        locator5.setLanguage("en");
  -        locator5.setCountry("UZ");                
  -        template = component.locateTemplate(locator5);
  -        assertNotNull("template is null", template);        
  -        System.out.println("template5 = " + template);            
  -        assertTrue("template5 result", 
  -            "type/email/media-type/html/language/en/name/entest.vm".endsWith(template.toString()));
  -
  -        // test fallback all the way to email
  -        LocatorDescriptor locator6 = component.createLocatorDescriptor("email");
  -        locator6.setName("test.vm");
  -        locator6.setMediaType("html");
  -        locator6.setLanguage("en");
  -        locator6.setCountry("UZ");                
  -        template = component.locateTemplate(locator6);
  -        System.out.println("template6 = " + template);            
  -        assertTrue("template6 result", 
  -            "type/email/name/test.vm".endsWith(template.toString()));
  -                    
  -    }
  -    
  -}
  +/*
  + * Copyright 2000-2004 The Apache Software Foundation.
  + * 
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + * 
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + * 
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +package org.apache.jetspeed.locator;
  +
  +import java.io.File;
  +
  +import junit.framework.Test;
  +
  +import org.apache.jetspeed.components.AbstractComponentAwareTestCase;
  +import org.apache.jetspeed.components.ContainerDeployerTestSuite;
  +import org.apache.jetspeed.locator.LocatorDescriptor;
  +import org.apache.jetspeed.locator.TemplateDescriptor;
  +import org.apache.jetspeed.locator.TemplateLocator;
  +
  +/**
  + * TestTemplateLocator
  + *
  + * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  + * @version $Id$
  + */
  +public class TestTemplateLocator extends AbstractComponentAwareTestCase
  +{
  +    public TestTemplateLocator(String name) 
  +    {
  +        super( name );
  +    }
  +    
  +    
  +    /**
  +     * Start the tests.
  +     *
  +     * @param args the arguments. Not used
  +     */
  +    public static void main(String args[]) 
  +    {
  +        junit.awtui.TestRunner.main( new String[] { TestTemplateLocator.class.getName() } );
  +    }
  +
  +    public static Test suite()
  +    {
  +        // All methods starting with "test" will be executed in the test suite.
  +        //NanoDeployerBasedTestSuite suite = new NanoDeployerBasedTestSuite(TestTemplateLocator.class)
  +        return new ContainerDeployerTestSuite(TestTemplateLocator.class, new String[]{"Locator"});
  +    }
  +            
  +    public void testLocateTemplate()
  +          throws Exception
  +    {
  +        
  +        File appRoot = new File(System.getProperty("org.apache.jetspeed.application_root"));
  +        
  +        assertTrue("The application root, "+appRoot+", could not be located.", appRoot.exists());
  +        Object obj =  getContainer().getComponentInstance("TemplateLocator");
  +        ClassLoader testCl = TemplateLocator.class.getClassLoader();
  +        TemplateLocator component = (TemplateLocator)obj;
  +        assertNotNull("template service is null", component);            
  +        LocatorDescriptor locator = component.createLocatorDescriptor("email");
  +        locator.setName("test.vm");
  +        TemplateDescriptor template = component.locateTemplate(locator);
  +        assertNotNull("template is null", template);
  +        System.out.println("template1 = " + template);
  +        assertTrue("template1 result", "type/email/name/test.vm".endsWith(template.toString()));
  +        
  +        LocatorDescriptor locator2 = component.createLocatorDescriptor("email");
  +        locator2.setName("htmltest.vm");
  +        locator2.setMediaType("html");        
  +        template = component.locateTemplate(locator2);
  +        assertNotNull("template is null", template);                
  +        System.out.println("template2 = " + template);            
  +        assertTrue("template2 result", "type/email/media-type/html/name/htmltest.vm".endsWith(template.toString()));
  +
  +        LocatorDescriptor locator3 = component.createLocatorDescriptor("email");
  +        locator3.setName("entest.vm");
  +        locator3.setMediaType("html");
  +        locator3.setLanguage("en");                
  +        template = component.locateTemplate(locator3);
  +        assertNotNull("template is null", template);        
  +        System.out.println("template3 = " + template);            
  +        assertTrue("template3 result", "type/email/media-type/html/language/en/name/entest.vm".endsWith(template.toString()));
  +
  +        LocatorDescriptor locator4 = component.createLocatorDescriptor("email");
  +        locator4.setName("ustest.vm");
  +        locator4.setMediaType("html");
  +        locator4.setLanguage("en");
  +        locator4.setCountry("US");                
  +        template = component.locateTemplate(locator4);
  +        assertNotNull("template is null", template);        
  +        System.out.println("template4 = " + template);            
  +        assertTrue("template4 result", 
  +            "type/email/media-type/html/language/en/country/US/name/ustest.vm".endsWith(template.toString()));
  +
  +        // test fallback
  +        LocatorDescriptor locator5 = component.createLocatorDescriptor("email");
  +        locator5.setName("entest.vm");
  +        locator5.setMediaType("html");
  +        locator5.setLanguage("en");
  +        locator5.setCountry("UZ");                
  +        template = component.locateTemplate(locator5);
  +        assertNotNull("template is null", template);        
  +        System.out.println("template5 = " + template);            
  +        assertTrue("template5 result", 
  +            "type/email/media-type/html/language/en/name/entest.vm".endsWith(template.toString()));
  +
  +        // test fallback all the way to email
  +        LocatorDescriptor locator6 = component.createLocatorDescriptor("email");
  +        locator6.setName("test.vm");
  +        locator6.setMediaType("html");
  +        locator6.setLanguage("en");
  +        locator6.setCountry("UZ");                
  +        template = component.locateTemplate(locator6);
  +        System.out.println("template6 = " + template);            
  +        assertTrue("template6 result", 
  +            "type/email/name/test.vm".endsWith(template.toString()));
  +                    
  +    }
  +    
  +}
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org