neeme 01/10/31 04:30:42 Added: src/scratchpad/org/apache/avalon/excalibur/i18n/test AbstractBundleTestCase.java Log: new tests for rewritten i18n classes Revision Changes Path 1.1 jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/i18n/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 file. */ package org.apache.avalon.excalibur.i18n.test; import java.util.Map; import java.util.HashMap; import junit.framework.TestCase; import org.apache.log.Hierarchy; import org.apache.log.Logger; import org.apache.avalon.excalibur.i18n.Bundle; import org.apache.avalon.excalibur.i18n.AbstractBundle; import java.io.FileWriter; /** * @author <a href="mailto:[EMAIL PROTECTED]">Neeme Praks</a> * @version $Id: AbstractBundleTestCase.java,v 1.1 2001/10/31 12:30:42 neeme Exp $ */ public class AbstractBundleTestCase extends TestCase { private TestBundle bundle = new TestBundle(); private HashMap 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.bundle.setLogger(Hierarchy.getDefaultHierarchy().getLoggerFor("Bundle")); 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 testSubstitute() { assertTrue(this.bundle.getString("nice", variables), this.bundle.getString("nice", variables).equals("This is a not so nice test!")); assertTrue(this.bundle.getString("nice.nice", variables), this.bundle.getString("nice.nice", variables).equals("This is a not so nice, not so nice test!")); assertTrue(this.bundle.getString("nice.bad", variables), this.bundle.getString("nice.bad", variables).equals("This is a not so nice but not too bad test!")); assertTrue(this.bundle.getString("test.plain", variables), this.bundle.getString("test.plain", variables).equals("This is a test!")); assertTrue(this.bundle.getString("test.empty", variables), this.bundle.getString("test.empty", variables).equals("")); } private class TestBundle extends AbstractBundle { private Map store = new HashMap(); public void init(String fileName, boolean cacheAtStartup) throws Exception { } void put(String key, String value) { this.store.put(key, value); } public String getString(String key) { return (String) store.get(key); } } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>