brett 2004/01/05 00:52:53
Modified: maven-model/src/java/org/apache/maven/model Resource.java
UnitTest.java
Added: maven-model/src/java/org/apache/maven/model PatternSet.java
maven-model/src/test/org/apache/maven/model
PatternSetTest.java
Log:
share code, but no reason for unit test to extend resource
Revision Changes Path
1.8 +1 -46
maven-components/maven-model/src/java/org/apache/maven/model/Resource.java
Index: Resource.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-model/src/java/org/apache/maven/model/Resource.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Resource.java 27 Dec 2003 04:30:07 -0000 1.7
+++ Resource.java 5 Jan 2004 08:52:53 -0000 1.8
@@ -67,6 +67,7 @@
* @author <a href="[EMAIL PROTECTED]">Michal Maczka</a>
*/
public class Resource
+ extends PatternSet
implements Serializable
{
/** Resource Directory */
@@ -75,53 +76,7 @@
/** Target directory. */
private String targetPath = "";
- /** Include patterns. */
- private List includes = new ArrayList();
-
- /** Exclude patterns. */
- private List excludes = new ArrayList();
-
private boolean filtering;
-
- /**
- * Add an include pattern.
- *
- * @param pattern Add an include pattern.
- */
- public void addInclude( String pattern )
- {
- this.includes.add( pattern );
- }
-
- /**
- * Add an exclude pattern.
- *
- * @param pattern Add an exlude pattern.
- */
- public void addExclude( String pattern )
- {
- this.excludes.add( pattern );
- }
-
- /**
- * Retrieve a list of include patterns.
- *
- * @return List of include patterns.
- */
- public List getIncludes()
- {
- return this.includes;
- }
-
- /**
- * Retrieve a list of exclude patterns.
- *
- * @return List of exclude patterns.
- */
- public List getExcludes()
- {
- return this.excludes;
- }
/**
* Set the directory where resources are located.
1.4 +3 -1
maven-components/maven-model/src/java/org/apache/maven/model/UnitTest.java
Index: UnitTest.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-model/src/java/org/apache/maven/model/UnitTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- UnitTest.java 13 Sep 2003 14:58:16 -0000 1.3
+++ UnitTest.java 5 Jan 2004 08:52:53 -0000 1.4
@@ -58,6 +58,7 @@
import org.apache.maven.model.Resource;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -69,7 +70,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">James Taylor</a>
*/
public class UnitTest
- extends Resource
+ extends PatternSet
+ implements Serializable
{
/** List of test resources. */
private List resources = new ArrayList();
1.1
maven-components/maven-model/src/java/org/apache/maven/model/PatternSet.java
Index: PatternSet.java
===================================================================
package org.apache.maven.model;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, 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 "Apache" and "Apache Software Foundation" and
* "Apache MavenSession" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache MavenSession", 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 (INCLUDING, 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/>.
*
* ====================================================================
*/
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* Represents a set of files.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a>
*/
public class PatternSet
implements Serializable
{
/** Include patterns. */
private List includes = new ArrayList();
/** Exclude patterns. */
private List excludes = new ArrayList();
protected PatternSet()
{
}
/**
* Add an include pattern.
*
* @param pattern Add an include pattern.
*/
public void addInclude( String pattern )
{
this.includes.add( pattern );
}
/**
* Add an exclude pattern.
*
* @param pattern Add an exlude pattern.
*/
public void addExclude( String pattern )
{
this.excludes.add( pattern );
}
/**
* Retrieve a list of include patterns.
*
* @return List of include patterns.
*/
public List getIncludes()
{
return this.includes;
}
/**
* Retrieve a list of exclude patterns.
*
* @return List of exclude patterns.
*/
public List getExcludes()
{
return this.excludes;
}
}
1.1
maven-components/maven-model/src/test/org/apache/maven/model/PatternSetTest.java
Index: PatternSetTest.java
===================================================================
package org.apache.maven.model;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, 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 "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", 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 (INCLUDING, 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/>.
*
* ====================================================================
*/
import junit.framework.TestCase;
/**
* Test the pattern set element.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a>
*
* @version $Id: PatternSetTest.java,v 1.1 2004/01/05 08:52:53 brett Exp $
*/
public class PatternSetTest
extends TestCase
{
private PatternSet patternSet;
public PatternSetTest( String name )
{
super( name );
}
public void setUp()
{
patternSet = new PatternSet()
{
};
}
public void testIncludesEmpty()
{
assertEquals( "check empty", 0, patternSet.getIncludes().size() );
}
public void testExcludesEmpty()
{
assertEquals( "check empty", 0, patternSet.getExcludes().size() );
}
public void testAddInclude()
{
patternSet.addInclude( "include" );
assertEquals( "check size", 1, patternSet.getIncludes().size() );
assertEquals( "check element", "include", patternSet.getIncludes().get( 0 )
);
}
public void testAddExclude()
{
patternSet.addExclude( "exclude" );
assertEquals( "check size", 1, patternSet.getExcludes().size() );
assertEquals( "check element", "exclude", patternSet.getExcludes().get( 0 )
);
}
public void testAddIncludeTwice()
{
patternSet.addInclude( "include" );
patternSet.addInclude( "include" );
assertEquals( "check size", 2, patternSet.getIncludes().size() );
assertEquals( "check element", "include", patternSet.getIncludes().get( 0 )
);
assertEquals( "check element", "include", patternSet.getIncludes().get( 1 )
);
}
public void testAddExcludeTwice()
{
patternSet.addExclude( "exclude" );
patternSet.addExclude( "exclude" );
assertEquals( "check size", 2, patternSet.getExcludes().size() );
assertEquals( "check element", "exclude", patternSet.getExcludes().get( 0 )
);
assertEquals( "check element", "exclude", patternSet.getExcludes().get( 1 )
);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]