Return-Path: Delivered-To: apmail-avalon-cvs-archive@avalon.apache.org Received: (qmail 68149 invoked by uid 500); 10 Apr 2003 04:38:10 -0000 Mailing-List: contact cvs-help@avalon.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list cvs@avalon.apache.org Received: (qmail 68131 invoked by uid 500); 10 Apr 2003 04:38:10 -0000 Received: (qmail 68119 invoked from network); 10 Apr 2003 04:38:10 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 10 Apr 2003 04:38:10 -0000 Received: (qmail 79092 invoked by uid 1438); 10 Apr 2003 04:38:08 -0000 Date: 10 Apr 2003 04:38:08 -0000 Message-ID: <20030410043808.79090.qmail@icarus.apache.org> From: mcconnell@apache.org To: avalon-sandbox-cvs@apache.org Subject: cvs commit: avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/src/test/org/apache AbstractTestCase.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N mcconnell 2003/04/09 21:38:08 Added: merlin/merlin-smp/src/examples/afs/simple project.properties merlin/merlin-smp/src/examples/afs/simple/src/java/org/apache/bank/impl ActionSimulator.java ActionSimulator.xinfo merlin/merlin-smp/src/examples/afs/simple/src/test/org/apache AbstractTestCase.java Removed: merlin/merlin-smp/src/examples/afs/simple build.xml Log: Updates to the simple bank examples. Revision Changes Path 1.1 avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/project.properties Index: project.properties =================================================================== maven.junit.fork = true 1.1 avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/src/java/org/apache/bank/impl/ActionSimulator.java Index: ActionSimulator.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation. For more information on the Apache Software Foundation, please see . */ package org.apache.bank.impl; import java.io.File; import java.io.InputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.net.URL; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.framework.service.Serviceable; import org.apache.avalon.framework.service.ServiceManager; import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.activity.Disposable; import org.apache.bank.Bank; import org.apache.bank.Account; import org.apache.bank.PolicyException; import org.apache.bank.NoSuchAccountException; public class ActionSimulator extends AbstractLogEnabled implements Serviceable, Initializable, Disposable { private ServiceManager m_manager; private Bank m_bank; public void service( ServiceManager manager ) throws ServiceException { m_manager = manager; m_bank = (Bank) manager.lookup( "bank" ); } /** * Initialization of the component by the container. * @exception if an initialization error occurs */ public void initialize() throws Exception { getLogger().info( "initialize" ); try { // // create an account // Account account = m_bank.createAccount( "simulation" ); getLogger().info( "balance: " + account.getBalance() ); // // deposit some funds // float deposit = new Float( 60000 ).floatValue(); account.deposit( deposit ); getLogger().info( "balance: " + account.getBalance() ); // // make a partial withdrawl // float withdrawl = new Float( 40000 ).floatValue(); account.withdraw( withdrawl ); getLogger().info( "balance: " + account.getBalance() ); // // withdrawl the balance and close the account // account.withdraw( account.getBalance() ); getLogger().info( "balance: " + account.getBalance() ); m_bank.closeAccount( account.getID() ); } catch( Throwable e ) { final String msg = "Bank runtime failure."; getLogger().error( msg, e ); } } /** * Disposal of the bank by the container. */ public void dispose() { getLogger().info( "disposal" ); m_manager.release( m_bank ); m_bank = null; m_manager = null; } } 1.1 avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/src/java/org/apache/bank/impl/ActionSimulator.xinfo Index: ActionSimulator.xinfo =================================================================== simulator 1.0 1.1 avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple/src/test/org/apache/AbstractTestCase.java Index: AbstractTestCase.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation. For more information on the Apache Software Foundation, please see . */ package org.apache; import java.io.File; import junit.framework.TestCase; import org.apache.avalon.assembly.locator.DefaultLocator; import org.apache.avalon.assembly.logging.LoggingManager; import org.apache.avalon.assembly.logging.TargetDescriptor; import org.apache.avalon.assembly.logging.LoggingDescriptor; import org.apache.avalon.assembly.logging.DefaultLoggingManager; import org.apache.avalon.assembly.locator.DefaultLocator; import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.context.ContextException; import org.apache.avalon.framework.context.DefaultContext; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.meta.model.Category; import org.apache.avalon.merlin.block.Block; import org.apache.avalon.merlin.kernel.impl.DefaultKernel; import org.apache.avalon.merlin.kernel.KernelException; import org.apache.avalon.merlin.kernel.Kernel; /** * A testcase for the @link{StandardTypeManager}. * * @author Avalon Development Team */ public abstract class AbstractTestCase extends TestCase implements Kernel { private DefaultKernel m_kernel; public AbstractTestCase( String name ) { super( name ); } protected void setUp() throws Exception { ClassLoader loader = Thread.currentThread().getContextClassLoader(); File base = new File( System.getProperty( "user.dir" ) ); File classes = new File( base, "target/classes" ); DefaultLocator context = new DefaultLocator(); context.put( "urn:merlin:home", base ); context.put( "urn:merlin:system", base ); context.put( "urn:merlin:classloader.common", loader ); context.put( "urn:merlin:classloader.system", loader ); context.put( "urn:merlin:debug", "WARN" ); context.put( "urn:merlin:logging.priority", "INFO" ); context.put( "urn:merlin:block.url", classes.toURL() ); context.makeReadOnly(); m_kernel = new DefaultKernel(); m_kernel.contextualize( context ); m_kernel.initialize(); } public void tearDown() throws Exception { if( m_kernel != null ) { m_kernel.shutdown(); } } //-------------------------------------------------- // Kernel //-------------------------------------------------- /** * Return the root block. * @return the root block */ public Block getRootBlock() { if( m_kernel == null ) { final String message = "Kernel has not been initialized."; throw new IllegalStateException( message ); } return m_kernel.getRootBlock(); } /** * Initiate an orderly shutdown of the kernel. */ public void shutdown() { if( m_kernel == null ) { final String message = "Kernel has not been initialized."; throw new IllegalStateException( message ); } m_kernel.shutdown(); } } --------------------------------------------------------------------- To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org For additional commands, e-mail: cvs-help@avalon.apache.org