You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by le...@apache.org on 2002/08/08 09:17:30 UTC
cvs commit: jakarta-avalon-excalibur/xmlbundle/src/test/org/apache/excalibur/xmlbundle/test AbstractBundleTestCase.java DefaultBundleLoaderTestCase.java DefaultBundleLoaderTestCase.xtest DefaultBundleMatcherTestCase.java DefaultBundleMatcherTestCase.xtest XmlBundle.xml XmlBundleTestCase.java XmlBundleTestCase.xtest
leif 2002/08/08 00:17:29
Modified: xmlbundle build.xml default.properties
Added: xmlbundle/src/test/org/apache/excalibur/xmlbundle/test
AbstractBundleTestCase.java
DefaultBundleLoaderTestCase.java
DefaultBundleLoaderTestCase.xtest
DefaultBundleMatcherTestCase.java
DefaultBundleMatcherTestCase.xtest XmlBundle.xml
XmlBundleTestCase.java XmlBundleTestCase.xtest
Removed: xmlbundle/src/java/org/apache/excalibur/xmlbundle/test
AbstractBundleTestCase.java
DefaultBundleLoaderTestCase.java
DefaultBundleLoaderTestCase.xtest
DefaultBundleMatcherTestCase.java
DefaultBundleMatcherTestCase.xtest XmlBundle.xml
XmlBundleTestCase.java XmlBundleTestCase.xtest
Log:
Get the dist build working.
Anakia docs are being skipped.
Moved and setup the tests.
Revision Changes Path
1.31 +22 -15 jakarta-avalon-excalibur/xmlbundle/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/xmlbundle/build.xml,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- build.xml 6 Aug 2002 16:27:51 -0000 1.30
+++ build.xml 8 Aug 2002 07:17:29 -0000 1.31
@@ -36,6 +36,10 @@
<path id="test.class.path">
<pathelement location="${build.testclasses}"/>
<pathelement location="${junit.jar}"/>
+ <pathelement location="${excalibur-testcase.jar}"/>
+ <pathelement location="${excalibur-collections.jar}"/>
+ <pathelement location="${excalibur-i18n.jar}"/>
+ <pathelement location="${excalibur-pool.jar}"/>
<path refid="project.class.path"/>
</path>
<property name="cp" refid="test.class.path"/>
@@ -84,6 +88,9 @@
<!-- Need the jar to prevent recursive deps. -->
<ant antfile="${depchecker.prefix}/depchecker.xml" target="checkJUnit"/>
+ <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkTestcase"/>
+ <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkI18n"/>
+ <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkCollections"/>
</target>
@@ -316,9 +323,6 @@
<zip zipfile="${dist.base}/${dist.name}.zip" compress="true">
<zipfileset dir="${dist.dir}" prefix="${dist.name}"/>
</zip>
-
- <delete dir="${dist.dir}" />
-
</target>
<!-- Creates a mini jar-only distribution -->
@@ -359,6 +363,8 @@
</target>
<target name="docs" depends="anakia-check" description="Generate documentation and website">
+ <echo message="Anakia docs being skipped because docs.vsl does not exist and build was breaking."/>
+ <!-- Skip Anakia docs until they work
<taskdef name="anakia"
classname="org.apache.velocity.anakia.AnakiaTask">
<classpath refid="tools.class.path"/>
@@ -372,18 +378,19 @@
excludes="menu.xml"
velocitypropertiesfile="../site/src/stylesheets/velocity.properties"
/>
-
- <copy todir="${docs.dir}" filtering="off">
- <fileset dir="../site/src" includes="css/*.css" />
- <fileset dir="${xdocs.dir}">
- <include name="**/images/**"/>
- <include name="**/*.gif"/>
- <include name="**/*.jpg"/>
- <include name="**/*.png"/>
- <include name="**/*.css"/>
- <include name="**/*.js"/>
- </fileset>
- </copy>
+ -->
+
+ <copy todir="${docs.dir}" filtering="off">
+ <fileset dir="../site/src" includes="css/*.css" />
+ <fileset dir="${xdocs.dir}">
+ <include name="**/images/**"/>
+ <include name="**/*.gif"/>
+ <include name="**/*.jpg"/>
+ <include name="**/*.png"/>
+ <include name="**/*.css"/>
+ <include name="**/*.js"/>
+ </fileset>
+ </copy>
</target>
<target name="site" depends="javadocs, docs" description=" Places Docs ready for hosting on website">
1.18 +20 -0 jakarta-avalon-excalibur/xmlbundle/default.properties
Index: default.properties
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/xmlbundle/default.properties,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- default.properties 7 Aug 2002 19:33:47 -0000 1.17
+++ default.properties 8 Aug 2002 07:17:29 -0000 1.18
@@ -60,6 +60,26 @@
excalibur-xmlutil.lib=${excalibur-xmlutil.home}
excalibur-xmlutil.jar=${excalibur-xmlutil.lib}/excalibur-xmlutil-1.0.jar
+# ----- Excalibur testcase, version 1.0 or later -----
+excalibur-testcase.home=${basedir}/../testcase/dist
+excalibur-testcase.lib=${excalibur-testcase.home}
+excalibur-testcase.jar=${excalibur-testcase.lib}/excalibur-testcase-1.0.jar
+
+# ----- Excalibur Collections, version 1.0 or later -----
+excalibur-collections.home=${basedir}/../collections/dist
+excalibur-collections.lib=${excalibur-collections.home}
+excalibur-collections.jar=${excalibur-collections.lib}/excalibur-collections-1.0.jar
+
+# ----- Excalibur I18n, version 1.0 or later -----
+excalibur-i18n.home=${basedir}/../i18n/dist
+excalibur-i18n.lib=${excalibur-i18n.home}
+excalibur-i18n.jar=${excalibur-i18n.lib}/excalibur-i18n-1.0.jar
+
+# ----- Excalibur pool, version 1.1 or later -----
+excalibur-pool.home=${basedir}/../pool/dist
+excalibur-pool.lib=${excalibur-pool.home}
+excalibur-pool.jar=${excalibur-pool.lib}/excalibur-pool-1.1.jar
+
# --------------------------------------------------
tools.dir=${basedir}/../../jakarta-avalon/tools
1.1 jakarta-avalon-excalibur/xmlbundle/src/test/org/apache/excalibur/xmlbundle/test/AbstractBundleTestCase.java
Index: AbstractBundleTestCase.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.excalibur.xmlbundle.test;
import java.util.HashMap;
import java.util.Map;
import org.apache.excalibur.xmlbundle.AbstractBundle;
import org.apache.avalon.excalibur.testcase.ExcaliburTestCase;
/**
* @author <a href="mailto:neeme@apache.org">Neeme Praks</a>
* @version $Id: AbstractBundleTestCase.java,v 1.1 2002/08/08 07:17:29 leif Exp $
*/
public class AbstractBundleTestCase extends ExcaliburTestCase
{
private TestBundle bundle = new TestBundle();
private Map variables = new HashMap( 5 );
public AbstractBundleTestCase( String name )
{
super( name );
}
public void setUp() throws Exception
{
this.variables.put( "nice", "not so nice" );
this.variables.put( "bad", "too bad" );
this.variables.put( "value", "a cat" );
this.bundle.enableLogging( getLogEnabledLogger() );
this.bundle.put( "cat", "Here is an example of {value}." );
this.bundle.put( "nice", "This is a {nice} test!" );
this.bundle.put( "nice.nice", "This is a {nice}, {nice} test!" );
this.bundle.put( "nice.bad", "This is a {nice} but not {bad} test!" );
this.bundle.put( "test.plain", "This is a test!" );
this.bundle.put( "test.empty", "" );
}
public void tearDown() throws Exception
{
this.variables.clear();
this.bundle.store.clear();
}
public void testSubstitute()
{
assertEquals( "This is a not so nice test!", this.bundle.getString( "nice", variables ) );
assertEquals( "This is a not so nice, not so nice test!", this.bundle.getString( "nice.nice", variables ) );
assertEquals( "This is a not so nice but not too bad test!", this.bundle.getString( "nice.bad", variables ) );
assertEquals( "This is a test!", this.bundle.getString( "test.plain", variables ) );
assertEquals( "", this.bundle.getString( "test.empty", variables ) );
assertEquals( "Here is an example of a cat.", this.bundle.getString( "cat", this.variables ) );
}
private static class TestBundle extends AbstractBundle
{
private Map store = new HashMap();
public void setLoadOnInit( boolean set )
{
}
public void init( String fileName ) throws Exception
{
// do nothing
}
void put( String key, String value )
{
this.store.put( key, value );
}
public String getString( String key )
{
return (String)store.get( key );
}
}
}
1.1 jakarta-avalon-excalibur/xmlbundle/src/test/org/apache/excalibur/xmlbundle/test/DefaultBundleLoaderTestCase.java
Index: DefaultBundleLoaderTestCase.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.excalibur.xmlbundle.test;
import org.apache.excalibur.xmlbundle.BundleSelector;
import org.apache.avalon.excalibur.testcase.ExcaliburTestCase;
/**
* @author <a href="mailto:neeme@apache.org">Neeme Praks</a>
* @version $Id: DefaultBundleLoaderTestCase.java,v 1.1 2002/08/08 07:17:29 leif Exp $
*/
public class DefaultBundleLoaderTestCase extends ExcaliburTestCase
{
private BundleSelector bundleSelector;
public DefaultBundleLoaderTestCase( String name )
{
super( name );
}
public void setUp() throws Exception
{
super.setUp();
this.bundleSelector = (BundleSelector)this.manager.lookup( BundleSelector.ROLE );
}
public void tearDown() throws Exception
{
manager.release( this.bundleSelector );
this.bundleSelector = null;
super.tearDown();
}
public void testLoading() throws Exception
{
this.bundleSelector.select( "ee", "uu" );
}
public static void main( String[] args )
{
ExcaliburTestCase test = new DefaultBundleLoaderTestCase( "test" );
test.run();
}
}
1.1 jakarta-avalon-excalibur/xmlbundle/src/test/org/apache/excalibur/xmlbundle/test/DefaultBundleLoaderTestCase.xtest
Index: DefaultBundleLoaderTestCase.xtest
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<testcase>
<annotation><![CDATA[
<title>DefaultBundleLoader tests</title>
<para>
Tests the DefaultBundleLoader implementation: loading bundles, mapping correctly, etc.
</para>
]]></annotation>
<roles>
<role name="org.apache.avalon.excalibur.xml.xpath.XPathProcessor" shorthand="xpath-processor" default-class="org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl"/>
<role name="org.apache.avalon.excalibur.xml.Parser" shorthand="parser" default-class="org.apache.avalon.excalibur.xml.XercesParser"/>
<role
shorthand="bundles"
name="org.apache.avalon.excalibur.i18n.BundleSelector"
default-class="org.apache.avalon.excalibur.i18n.BundleSelector"
/>
<role
shorthand="bundle-mappers"
name="org.apache.avalon.excalibur.i18n.BundleInfoMapperSelector"
default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector"
>
<hint shorthand="default" class="org.apache.avalon.excalibur.i18n.DefaultMapper"/>
<hint shorthand="dir" class="org.apache.avalon.excalibur.i18n.DirectoryMapper"/>
</role>
<role
shorthand="bundle-matchers"
name="org.apache.avalon.excalibur.i18n.BundleMatcherSelector"
default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector"
>
<hint shorthand="default" class="org.apache.avalon.excalibur.i18n.DefaultBundleMatcher"/>
</role>
<role
shorthand="bundle-loaders"
name="org.apache.avalon.excalibur.i18n.BundleLoaderSelector"
default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector"
>
<hint shorthand="default" class="org.apache.avalon.excalibur.i18n.DefaultBundleLoader"/>
</role>
<role
shorthand="bundle-factories"
name="org.apache.avalon.excalibur.i18n.BundleFactorySelector"
default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector"
>
<hint shorthand="default" class="org.apache.avalon.excalibur.i18n.DefaultBundleFactory"/>
</role>
</roles>
<context/>
<logkit/>
<components>
<xpath-processor/>
<parser/>
<bundle-mappers>
<default name="test">
<prefix>file:///root/path/to/xml/files/</prefix>
<suffix>.xml</suffix>
</default>
</bundle-mappers>
<bundle-matchers>
<default name="test1">
<bundle-info name="test" ext="test-ext">
<locale language="test-lang" country="test-country" variant="test-variant"/>
</bundle-info>
</default>
<default name="test2">
<bundle-info name="test"/>
</default>
<default name="test3">
<bundle-info>
<locale language="test-lang" country="test-country"/>
</bundle-info>
</default>
</bundle-matchers>
<bundle-loaders>
<default name="loader">
<scan-dir>dir/to/be/scanned</scan-dir>
<return-type>xml</return-type>
</default>
</bundle-loaders>
<bundle-factories>
<default name="xml" mapper="test" bundle="org.apache.avalon.excalibur.i18n.XmlBundle">
<bundle-conf
load-on-init="true"
use-root-element="false"
/>
</default>
</bundle-factories>
<bundles default="xml">
<test1 matcher="test1"/>
<test2 matcher="test2"/>
<test3 matcher="test3"/>
<xml matcher="test4"/>
</bundles>
</components>
</testcase>
1.1 jakarta-avalon-excalibur/xmlbundle/src/test/org/apache/excalibur/xmlbundle/test/DefaultBundleMatcherTestCase.java
Index: DefaultBundleMatcherTestCase.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.excalibur.xmlbundle.test;
import java.net.URL;
import java.util.Locale;
import junit.framework.TestCase;
import org.apache.excalibur.xmlbundle.BundleInfo;
import org.apache.excalibur.xmlbundle.BundleMatcher;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
/**
* @author <a href="mailto:neeme@apache.org">Neeme Praks</a>
* @version $Id: DefaultBundleMatcherTestCase.java,v 1.1 2002/08/08 07:17:29 leif Exp $
*/
public class DefaultBundleMatcherTestCase extends TestCase
{
private BundleMatcher[] matchers;
public DefaultBundleMatcherTestCase( String name )
{
super( name );
}
public void configure( Configuration configuration ) throws Exception
{
Configuration[] confs = configuration.getChildren( "matcher" );
this.matchers = new BundleMatcher[ confs.length ];
for( int i = 0; i < confs.length; i++ )
{
this.matchers[ i ] = (BundleMatcher)Class.forName( confs[ i ].getAttribute( "class" ) ).newInstance();
if( this.matchers[ i ] instanceof Configurable ) ( (Configurable)this.matchers[ i ] ).configure( confs[ i ] );
}
}
public void setUp() throws Exception
{
super.setUp();
final String resourceName = this.getClass().getName().replace( '.', '/' ) + ".xtest";
URL resource = this.getClass().getClassLoader().getResource( resourceName );
final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
final Configuration conf = builder.build( resource.openStream() );
configure( conf );
}
public void tearDown() throws Exception
{
super.tearDown();
this.matchers = null;
}
public void testMatching() throws Exception
{
assertEquals( "test1", matchers[ 0 ].getType( new BundleInfo( "test", new Locale( "test-lang", "test-country", "test-variant" ), "test-ext" ) ) );
assertTrue( null == matchers[ 0 ].getType( new BundleInfo( "test", new Locale( "test-lang", "test-country", "test-variant" ), "test" ) ) );
assertEquals( "test2", matchers[ 1 ].getType( new BundleInfo( "test", new Locale( "test-lang", "test-country", "test-variant" ) ) ) );
assertTrue( null == matchers[ 1 ].getType( new BundleInfo( "testing", new Locale( "test-lang", "test-country", "test-variant" ) ) ) );
assertEquals( "test3", matchers[ 2 ].getType( new BundleInfo( "test", new Locale( "test-lang", "test-country" ) ) ) );
assertTrue( null == matchers[ 2 ].getType( new BundleInfo( "testing", new Locale( "test-language", "test-country" ) ) ) );
assertTrue( null == matchers[ 2 ].getType( new BundleInfo( "testing", new Locale( "test-lang", "test-count" ) ) ) );
}
}
1.1 jakarta-avalon-excalibur/xmlbundle/src/test/org/apache/excalibur/xmlbundle/test/DefaultBundleMatcherTestCase.xtest
Index: DefaultBundleMatcherTestCase.xtest
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<conf>
<matcher class="org.apache.avalon.excalibur.i18n.DefaultBundleMatcher" type="test1">
<bundle-info name="test" ext="test-ext">
<locale language="test-lang" country="test-country" variant="test-variant"/>
</bundle-info>
</matcher>
<matcher class="org.apache.avalon.excalibur.i18n.DefaultBundleMatcher" type="test2">
<bundle-info name="test"/>
</matcher>
<matcher class="org.apache.avalon.excalibur.i18n.DefaultBundleMatcher" type="test3">
<bundle-info class="org.apache.avalon.excalibur.i18n.ConfigurableBundleInfo">
<locale language="test-lang" country="test-country"/>
</bundle-info>
</matcher>
</conf>
1.1 jakarta-avalon-excalibur/xmlbundle/src/test/org/apache/excalibur/xmlbundle/test/XmlBundle.xml
Index: XmlBundle.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<level1>
<level2>
<level3>Text on level3</level3>
</level2>
</level1>
<levels>
<level number="1">Flat level 1</level>
<level number="2">Flat level 2</level>
<level number="3">Flat level 3</level>
</levels>
<key-with-variable>Here is an example of {value}.</key-with-variable>
</resources>
1.1 jakarta-avalon-excalibur/xmlbundle/src/test/org/apache/excalibur/xmlbundle/test/XmlBundleTestCase.java
Index: XmlBundleTestCase.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.excalibur.xmlbundle.test;
import java.util.HashMap;
import java.util.Map;
import org.apache.excalibur.xmlbundle.BundleInfo;
import org.apache.excalibur.xmlbundle.BundleInfoMapper;
import org.apache.excalibur.xmlbundle.XmlBundle;
import org.apache.avalon.excalibur.testcase.ExcaliburTestCase;
import org.apache.avalon.framework.configuration.DefaultConfiguration;
import org.xml.sax.InputSource;
/**
* @author <a href="mailto:neeme@apache.org">Neeme Praks</a>
* @version $Id: XmlBundleTestCase.java,v 1.1 2002/08/08 07:17:29 leif Exp $
*/
public class XmlBundleTestCase extends ExcaliburTestCase
{
private Map variables = new HashMap( 5 );
private XmlBundle bundle = new XmlBundle();
private XmlBundle bundleWithRoot = new XmlBundle();
public XmlBundleTestCase( String name )
{
super( name );
}
public void setUp() throws Exception
{
this.variables.put( "value", "a cat" );
final String bundleFileName = this.getClass().getPackage().getName().replace( '.', '/' ) + "/XmlBundle.xml";
getLogger().debug( "Test-bundle file = " + bundleFileName );
this.bundle.setBundleInfo( new BundleInfo( "test", null ) );
this.bundle.setMapper( (BundleInfoMapper)this.manager.lookup( BundleInfoMapper.ROLE ) );
this.bundle.enableLogging( getLogEnabledLogger() );
this.bundle.compose( this.manager );
DefaultConfiguration conf = new DefaultConfiguration( "bundle-conf", "conf" );
conf.setAttribute( XmlBundle.ConfigurationKeys.LOAD_ON_INIT, "true" );
conf.setAttribute( XmlBundle.ConfigurationKeys.USE_ROOT, "false" );
this.bundle.configure( conf );
this.bundle.initialize( new InputSource( this.getClass().getClassLoader().getResource( bundleFileName ).openStream() ) );
this.bundleWithRoot.setBundleInfo( new BundleInfo( "test-with-root", null ) );
this.bundleWithRoot.setMapper( (BundleInfoMapper)this.manager.lookup( BundleInfoMapper.ROLE ) );
this.bundleWithRoot.enableLogging( getLogEnabledLogger() );
this.bundleWithRoot.compose( super.manager );
conf = new DefaultConfiguration( "bundle-conf", "conf" );
conf.setAttribute( XmlBundle.ConfigurationKeys.LOAD_ON_INIT, "true" );
conf.setAttribute( XmlBundle.ConfigurationKeys.USE_ROOT, "true" );
this.bundleWithRoot.configure( conf );
this.bundleWithRoot.initialize( new InputSource( this.getClass().getClassLoader().getResource( bundleFileName ).openStream() ) );
}
public void testGetString()
{
assertEquals( "Text on level3", this.bundle.getString( "level1.level2.level3" ) );
assertEquals( "Flat level 2", this.bundle.getString( "levels/level[@number='2']" ) );
assertEquals( "Text on level3", this.bundleWithRoot.getString( "resources.level1.level2.level3" ) );
assertEquals( "Flat level 2", this.bundleWithRoot.getString( "resources.levels/level[@number='2']" ) );
}
public void testGetStringWithVariable()
{
assertEquals( "Here is an example of a cat.", this.bundle.getString( "key-with-variable", this.variables ) );
assertEquals( "Here is an example of a cat.", this.bundleWithRoot.getString( "resources.key-with-variable", this.variables ) );
}
}
1.1 jakarta-avalon-excalibur/xmlbundle/src/test/org/apache/excalibur/xmlbundle/test/XmlBundleTestCase.xtest
Index: XmlBundleTestCase.xtest
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<testcase>
<annotation><![CDATA[
<title>XmlResourceBundle tests</title>
<para>
Tests the XmlResourceBundle implementation: loading from file, returning correct values, substituting correctly, etc.
</para>
]]></annotation>
<roles>
<role name="org.apache.avalon.excalibur.xml.xpath.XPathProcessor" shorthand="xpath-processor" default-class="org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl"/>
<role name="org.apache.avalon.excalibur.xml.Parser" shorthand="parser" default-class="org.apache.avalon.excalibur.xml.XercesParser"/>
<role
shorthand="bundle-mapper"
name="org.apache.avalon.excalibur.i18n.BundleInfoMapper"
default-class="org.apache.avalon.excalibur.i18n.DefaultMapper"
/>
</roles>
<context/>
<logkit/>
<components>
<xpath-processor/>
<parser/>
<bundle-mapper>
<prefix>file:///root/path/to/xml/files/</prefix>
<suffix>.xml</suffix>
</bundle-mapper>
</components>
</testcase>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>