You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by bl...@apache.org on 2003/07/10 14:50:45 UTC
cvs commit: avalon-sandbox/merlin/meta-spi/src/test/org/apache/avalon/meta/model/test ProfileTestCase.java
bloritsch 2003/07/10 05:50:45
Modified: merlin/meta-spi/src/java/org/apache/avalon/meta/model
Profile.java
Added: merlin/meta-spi/src/test/org/apache/avalon/meta/model/test
ProfileTestCase.java
Log:
Add Profile TestCase
Revision Changes Path
1.11 +1 -28 avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/model/Profile.java
Index: Profile.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/meta-spi/src/java/org/apache/avalon/meta/model/Profile.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Profile.java 9 Jul 2003 17:36:49 -0000 1.10
+++ Profile.java 10 Jul 2003 12:50:44 -0000 1.11
@@ -318,33 +318,6 @@
return "[" + getName() + "]";
}
- /**
- * Provide a textual report on the profile.
- * @return the formatted profile report
- */
- /*
- public String list()
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append( "PROFILE REPORT\n" );
- buffer.append( "\n name: " + getName() );
- buffer.append( "\n base: " + getType().getInfo().getName() );
- buffer.append( "\n key: " + getType().getInfo().getClassname() );
- buffer.append( "\n context: " + getContext() );
- buffer.append( "\n configuration:" );
- if( getConfiguration() != null )
- {
- buffer.append( ConfigurationUtil.list( getConfiguration() ) );
- }
- else
- {
- buffer.append( " null" );
- }
- buffer.append( "\n parameters: " + getParameters() );
- buffer.append( "\n\n" );
- return buffer.toString();
- }
- */
private void setActivationPolicy( Context context )
{
1.1 avalon-sandbox/merlin/meta-spi/src/test/org/apache/avalon/meta/model/test/ProfileTestCase.java
Index: ProfileTestCase.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 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", "Avalon", "Excalibur" 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 <http://www.apache.org/>.
*/
package org.apache.avalon.meta.model.test;
import junit.framework.TestCase;
import org.apache.avalon.meta.info.*;
import org.apache.avalon.meta.model.*;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfiguration;
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.Version;
import java.util.Properties;
/**
* ProfileTestCase does XYZ
*
* @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
* @version CVS $ Revision: 1.1 $
*/
public class ProfileTestCase extends TestCase
{
private Type m_type;
private LoggingDirective m_log;
private Mode m_mode;
private boolean m_activation;
private Parameters m_parameters;
private Configuration m_configuration;
private ContextDirective m_context;
private String m_name;
private ReferenceDescriptor m_serviceRef;
private ServiceDescriptor[] m_services;
private DependencyDescriptor[] m_dependencies;
public ProfileTestCase( String name )
{
super( name );
}
public void setUp()
{
m_name = "Test";
m_context = new ContextDirective( getClass().getName(), new Import[0], new Entry[0] );
m_configuration = new DefaultConfiguration("test");
m_parameters = Parameters.fromProperties(System.getProperties());
m_activation = true;
m_mode = Mode.IMPLICIT;
m_serviceRef = new ReferenceDescriptor( ProfileTestCase.class.getName(), new Version( 1, 0, 0 ) );
m_services = new ServiceDescriptor[]{
new ServiceDescriptor( m_serviceRef )
};
m_dependencies= new DependencyDescriptor[0];
m_type = new Type(
new InfoDescriptor("name", ProfileTestCase.class.getName(),new Version(1,0,0),"pooled", new Properties()),
new LoggerDescriptor[] {new LoggerDescriptor("name", new Properties())},
new ContextDescriptor(new ReferenceDescriptor(ProfileTestCase.class.getName(), new Version(1,0,0)), new EntryDescriptor[]{}),
m_services,
m_dependencies,
new StageDescriptor[0],
new ExtensionDescriptor[0]
);
m_log = new LoggingDirective(m_type);
}
private Context getContext()
{
DefaultContext context = new DefaultContext();
context.put( Profile.TYPE_KEY, m_type );
context.put( Profile.CATEGORIES_KEY, m_log );
context.put( Profile.MODE_KEY, m_mode );
context.put( Profile.ACTIVATION_KEY, new Boolean( m_activation ) );
context.put( Profile.CONFIGURATION_KEY, m_configuration );
context.put( Profile.CONTEXT_KEY, m_context );
context.put( Profile.NAME_KEY, m_name );
context.put( Profile.PARAMETERS_KEY, m_parameters );
context.makeReadOnly();
return context;
}
public void testProfile() throws ContextException
{
Profile profile = new Profile();
profile.contextualize( getContext() );
assertEquals(m_type, profile.getType());
assertEquals(m_log, profile.getCategories());
assertEquals(m_mode, profile.getMode());
assertEquals(m_activation, profile.getActivationPolicy());
assertEquals(m_parameters, profile.getParameters());
assertEquals(m_configuration, profile.getConfiguration());
assertEquals(m_context, profile.getContext());
assertEquals(m_name, profile.getName());
assertEquals(m_services, profile.getServices());
assertEquals(m_services.length, profile.getServices().length);
assertEquals(m_services[0], profile.getService(m_serviceRef));
assertEquals(m_dependencies, profile.getDependencies());
assertEquals(m_dependencies.length, profile.getDependencies().length);
profile.setActivationPolicy( !m_activation );
assertEquals( !m_activation, profile.getActivationPolicy() );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org