You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2016/09/03 20:23:33 UTC
[10/51] [partial] maven-aether git commit: [MNG-6007] rename Aether
to Maven Artifact Resolver
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-util/src/main/java/org/eclipse/aether/util/version/GenericVersion.java
----------------------------------------------------------------------
diff --git a/aether-util/src/main/java/org/eclipse/aether/util/version/GenericVersion.java b/aether-util/src/main/java/org/eclipse/aether/util/version/GenericVersion.java
deleted file mode 100644
index 3596a29..0000000
--- a/aether-util/src/main/java/org/eclipse/aether/util/version/GenericVersion.java
+++ /dev/null
@@ -1,464 +0,0 @@
-package org.eclipse.aether.util.version;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.eclipse.aether.version.Version;
-
-/**
- * A generic version, that is a version that accepts any input string and tries to apply common sense sorting. See
- * {@link GenericVersionScheme} for details.
- */
-final class GenericVersion
- implements Version
-{
-
- private final String version;
-
- private final Item[] items;
-
- private final int hash;
-
- /**
- * Creates a generic version from the specified string.
- *
- * @param version The version string, must not be {@code null}.
- */
- public GenericVersion( String version )
- {
- this.version = version;
- items = parse( version );
- hash = Arrays.hashCode( items );
- }
-
- private static Item[] parse( String version )
- {
- List<Item> items = new ArrayList<Item>();
-
- for ( Tokenizer tokenizer = new Tokenizer( version ); tokenizer.next(); )
- {
- Item item = tokenizer.toItem();
- items.add( item );
- }
-
- trimPadding( items );
-
- return items.toArray( new Item[items.size()] );
- }
-
- private static void trimPadding( List<Item> items )
- {
- Boolean number = null;
- int end = items.size() - 1;
- for ( int i = end; i > 0; i-- )
- {
- Item item = items.get( i );
- if ( !Boolean.valueOf( item.isNumber() ).equals( number ) )
- {
- end = i;
- number = item.isNumber();
- }
- if ( end == i && ( i == items.size() - 1 || items.get( i - 1 ).isNumber() == item.isNumber() )
- && item.compareTo( null ) == 0 )
- {
- items.remove( i );
- end--;
- }
- }
- }
-
- public int compareTo( Version obj )
- {
- final Item[] these = items;
- final Item[] those = ( (GenericVersion) obj ).items;
-
- boolean number = true;
-
- for ( int index = 0;; index++ )
- {
- if ( index >= these.length && index >= those.length )
- {
- return 0;
- }
- else if ( index >= these.length )
- {
- return -comparePadding( those, index, null );
- }
- else if ( index >= those.length )
- {
- return comparePadding( these, index, null );
- }
-
- Item thisItem = these[index];
- Item thatItem = those[index];
-
- if ( thisItem.isNumber() != thatItem.isNumber() )
- {
- if ( number == thisItem.isNumber() )
- {
- return comparePadding( these, index, number );
- }
- else
- {
- return -comparePadding( those, index, number );
- }
- }
- else
- {
- int rel = thisItem.compareTo( thatItem );
- if ( rel != 0 )
- {
- return rel;
- }
- number = thisItem.isNumber();
- }
- }
- }
-
- private static int comparePadding( Item[] items, int index, Boolean number )
- {
- int rel = 0;
- for ( int i = index; i < items.length; i++ )
- {
- Item item = items[i];
- if ( number != null && number != item.isNumber() )
- {
- break;
- }
- rel = item.compareTo( null );
- if ( rel != 0 )
- {
- break;
- }
- }
- return rel;
- }
-
- @Override
- public boolean equals( Object obj )
- {
- return ( obj instanceof GenericVersion ) && compareTo( (GenericVersion) obj ) == 0;
- }
-
- @Override
- public int hashCode()
- {
- return hash;
- }
-
- @Override
- public String toString()
- {
- return version;
- }
-
- static final class Tokenizer
- {
-
- private static final Integer QUALIFIER_ALPHA = -5;
-
- private static final Integer QUALIFIER_BETA = -4;
-
- private static final Integer QUALIFIER_MILESTONE = -3;
-
- private static final Map<String, Integer> QUALIFIERS;
-
- static
- {
- QUALIFIERS = new TreeMap<String, Integer>( String.CASE_INSENSITIVE_ORDER );
- QUALIFIERS.put( "alpha", QUALIFIER_ALPHA );
- QUALIFIERS.put( "beta", QUALIFIER_BETA );
- QUALIFIERS.put( "milestone", QUALIFIER_MILESTONE );
- QUALIFIERS.put( "cr", -2 );
- QUALIFIERS.put( "rc", -2 );
- QUALIFIERS.put( "snapshot", -1 );
- QUALIFIERS.put( "ga", 0 );
- QUALIFIERS.put( "final", 0 );
- QUALIFIERS.put( "", 0 );
- QUALIFIERS.put( "sp", 1 );
- }
-
- private final String version;
-
- private int index;
-
- private String token;
-
- private boolean number;
-
- private boolean terminatedByNumber;
-
- public Tokenizer( String version )
- {
- this.version = ( version.length() > 0 ) ? version : "0";
- }
-
- public boolean next()
- {
- final int n = version.length();
- if ( index >= n )
- {
- return false;
- }
-
- int state = -2;
-
- int start = index;
- int end = n;
- terminatedByNumber = false;
-
- for ( ; index < n; index++ )
- {
- char c = version.charAt( index );
-
- if ( c == '.' || c == '-' || c == '_' )
- {
- end = index;
- index++;
- break;
- }
- else
- {
- int digit = Character.digit( c, 10 );
- if ( digit >= 0 )
- {
- if ( state == -1 )
- {
- end = index;
- terminatedByNumber = true;
- break;
- }
- if ( state == 0 )
- {
- // normalize numbers and strip leading zeros (prereq for Integer/BigInteger handling)
- start++;
- }
- state = ( state > 0 || digit > 0 ) ? 1 : 0;
- }
- else
- {
- if ( state >= 0 )
- {
- end = index;
- break;
- }
- state = -1;
- }
- }
-
- }
-
- if ( end - start > 0 )
- {
- token = version.substring( start, end );
- number = state >= 0;
- }
- else
- {
- token = "0";
- number = true;
- }
-
- return true;
- }
-
- @Override
- public String toString()
- {
- return String.valueOf( token );
- }
-
- public Item toItem()
- {
- if ( number )
- {
- try
- {
- if ( token.length() < 10 )
- {
- return new Item( Item.KIND_INT, Integer.parseInt( token ) );
- }
- else
- {
- return new Item( Item.KIND_BIGINT, new BigInteger( token ) );
- }
- }
- catch ( NumberFormatException e )
- {
- throw new IllegalStateException( e );
- }
- }
- else
- {
- if ( index >= version.length() )
- {
- if ( "min".equalsIgnoreCase( token ) )
- {
- return Item.MIN;
- }
- else if ( "max".equalsIgnoreCase( token ) )
- {
- return Item.MAX;
- }
- }
- if ( terminatedByNumber && token.length() == 1 )
- {
- switch ( token.charAt( 0 ) )
- {
- case 'a':
- case 'A':
- return new Item( Item.KIND_QUALIFIER, QUALIFIER_ALPHA );
- case 'b':
- case 'B':
- return new Item( Item.KIND_QUALIFIER, QUALIFIER_BETA );
- case 'm':
- case 'M':
- return new Item( Item.KIND_QUALIFIER, QUALIFIER_MILESTONE );
- default:
- }
- }
- Integer qualifier = QUALIFIERS.get( token );
- if ( qualifier != null )
- {
- return new Item( Item.KIND_QUALIFIER, qualifier );
- }
- else
- {
- return new Item( Item.KIND_STRING, token.toLowerCase( Locale.ENGLISH ) );
- }
- }
- }
-
- }
-
- static final class Item
- {
-
- static final int KIND_MAX = 8;
-
- static final int KIND_BIGINT = 5;
-
- static final int KIND_INT = 4;
-
- static final int KIND_STRING = 3;
-
- static final int KIND_QUALIFIER = 2;
-
- static final int KIND_MIN = 0;
-
- static final Item MAX = new Item( KIND_MAX, "max" );
-
- static final Item MIN = new Item( KIND_MIN, "min" );
-
- private final int kind;
-
- private final Object value;
-
- public Item( int kind, Object value )
- {
- this.kind = kind;
- this.value = value;
- }
-
- public boolean isNumber()
- {
- return ( kind & KIND_QUALIFIER ) == 0; // i.e. kind != string/qualifier
- }
-
- public int compareTo( Item that )
- {
- int rel;
- if ( that == null )
- {
- // null in this context denotes the pad item (0 or "ga")
- switch ( kind )
- {
- case KIND_MIN:
- rel = -1;
- break;
- case KIND_MAX:
- case KIND_BIGINT:
- case KIND_STRING:
- rel = 1;
- break;
- case KIND_INT:
- case KIND_QUALIFIER:
- rel = (Integer) value;
- break;
- default:
- throw new IllegalStateException( "unknown version item kind " + kind );
- }
- }
- else
- {
- rel = kind - that.kind;
- if ( rel == 0 )
- {
- switch ( kind )
- {
- case KIND_MAX:
- case KIND_MIN:
- break;
- case KIND_BIGINT:
- rel = ( (BigInteger) value ).compareTo( (BigInteger) that.value );
- break;
- case KIND_INT:
- case KIND_QUALIFIER:
- rel = ( (Integer) value ).compareTo( (Integer) that.value );
- break;
- case KIND_STRING:
- rel = ( (String) value ).compareToIgnoreCase( (String) that.value );
- break;
- default:
- throw new IllegalStateException( "unknown version item kind " + kind );
- }
- }
- }
- return rel;
- }
-
- @Override
- public boolean equals( Object obj )
- {
- return ( obj instanceof Item ) && compareTo( (Item) obj ) == 0;
- }
-
- @Override
- public int hashCode()
- {
- return value.hashCode() + kind * 31;
- }
-
- @Override
- public String toString()
- {
- return String.valueOf( value );
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-util/src/main/java/org/eclipse/aether/util/version/GenericVersionConstraint.java
----------------------------------------------------------------------
diff --git a/aether-util/src/main/java/org/eclipse/aether/util/version/GenericVersionConstraint.java b/aether-util/src/main/java/org/eclipse/aether/util/version/GenericVersionConstraint.java
deleted file mode 100644
index bfcd455..0000000
--- a/aether-util/src/main/java/org/eclipse/aether/util/version/GenericVersionConstraint.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package org.eclipse.aether.util.version;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.eclipse.aether.version.Version;
-import org.eclipse.aether.version.VersionConstraint;
-import org.eclipse.aether.version.VersionRange;
-
-/**
- * A constraint on versions for a dependency.
- */
-final class GenericVersionConstraint
- implements VersionConstraint
-{
-
- private final VersionRange range;
-
- private final Version version;
-
- /**
- * Creates a version constraint from the specified version range.
- *
- * @param range The version range, must not be {@code null}.
- */
- public GenericVersionConstraint( VersionRange range )
- {
- if ( range == null )
- {
- throw new IllegalArgumentException( "version range missing" );
- }
- this.range = range;
- this.version = null;
- }
-
- /**
- * Creates a version constraint from the specified version.
- *
- * @param version The version, must not be {@code null}.
- */
- public GenericVersionConstraint( Version version )
- {
- if ( version == null )
- {
- throw new IllegalArgumentException( "version missing" );
- }
- this.version = version;
- this.range = null;
- }
-
- public VersionRange getRange()
- {
- return range;
- }
-
- public Version getVersion()
- {
- return version;
- }
-
- public boolean containsVersion( Version version )
- {
- if ( range == null )
- {
- return version.equals( this.version );
- }
- else
- {
- return range.containsVersion( version );
- }
- }
-
- @Override
- public String toString()
- {
- return String.valueOf( ( range == null ) ? version : range );
- }
-
- @Override
- public boolean equals( Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
- if ( obj == null || !getClass().equals( obj.getClass() ) )
- {
- return false;
- }
-
- GenericVersionConstraint that = (GenericVersionConstraint) obj;
-
- return eq( range, that.range ) && eq( version, that.getVersion() );
- }
-
- private static <T> boolean eq( T s1, T s2 )
- {
- return s1 != null ? s1.equals( s2 ) : s2 == null;
- }
-
- @Override
- public int hashCode()
- {
- int hash = 17;
- hash = hash * 31 + hash( getRange() );
- hash = hash * 31 + hash( getVersion() );
- return hash;
- }
-
- private static int hash( Object obj )
- {
- return obj != null ? obj.hashCode() : 0;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-util/src/main/java/org/eclipse/aether/util/version/GenericVersionRange.java
----------------------------------------------------------------------
diff --git a/aether-util/src/main/java/org/eclipse/aether/util/version/GenericVersionRange.java b/aether-util/src/main/java/org/eclipse/aether/util/version/GenericVersionRange.java
deleted file mode 100644
index 832dd94..0000000
--- a/aether-util/src/main/java/org/eclipse/aether/util/version/GenericVersionRange.java
+++ /dev/null
@@ -1,242 +0,0 @@
-package org.eclipse.aether.util.version;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.eclipse.aether.version.InvalidVersionSpecificationException;
-import org.eclipse.aether.version.Version;
-import org.eclipse.aether.version.VersionRange;
-
-/**
- * A version range inspired by mathematical range syntax. For example, "[1.0,2.0)", "[1.0,)" or "[1.0]".
- */
-final class GenericVersionRange
- implements VersionRange
-{
-
- private final Bound lowerBound;
-
- private final Bound upperBound;
-
- /**
- * Creates a version range from the specified range specification.
- *
- * @param range The range specification to parse, must not be {@code null}.
- * @throws InvalidVersionSpecificationException If the range could not be parsed.
- */
- public GenericVersionRange( String range )
- throws InvalidVersionSpecificationException
- {
- String process = range;
-
- boolean lowerBoundInclusive, upperBoundInclusive;
- Version lowerBound, upperBound;
-
- if ( range.startsWith( "[" ) )
- {
- lowerBoundInclusive = true;
- }
- else if ( range.startsWith( "(" ) )
- {
- lowerBoundInclusive = false;
- }
- else
- {
- throw new InvalidVersionSpecificationException( range, "Invalid version range " + range
- + ", a range must start with either [ or (" );
- }
-
- if ( range.endsWith( "]" ) )
- {
- upperBoundInclusive = true;
- }
- else if ( range.endsWith( ")" ) )
- {
- upperBoundInclusive = false;
- }
- else
- {
- throw new InvalidVersionSpecificationException( range, "Invalid version range " + range
- + ", a range must end with either [ or (" );
- }
-
- process = process.substring( 1, process.length() - 1 );
-
- int index = process.indexOf( "," );
-
- if ( index < 0 )
- {
- if ( !lowerBoundInclusive || !upperBoundInclusive )
- {
- throw new InvalidVersionSpecificationException( range, "Invalid version range " + range
- + ", single version must be surrounded by []" );
- }
-
- String version = process.trim();
- if ( version.endsWith( ".*" ) )
- {
- String prefix = version.substring( 0, version.length() - 1 );
- lowerBound = parse( prefix + "min" );
- upperBound = parse( prefix + "max" );
- }
- else
- {
- lowerBound = upperBound = parse( version );
- }
- }
- else
- {
- String parsedLowerBound = process.substring( 0, index ).trim();
- String parsedUpperBound = process.substring( index + 1 ).trim();
-
- // more than two bounds, e.g. (1,2,3)
- if ( parsedUpperBound.contains( "," ) )
- {
- throw new InvalidVersionSpecificationException( range, "Invalid version range " + range
- + ", bounds may not contain additional ','" );
- }
-
- lowerBound = parsedLowerBound.length() > 0 ? parse( parsedLowerBound ) : null;
- upperBound = parsedUpperBound.length() > 0 ? parse( parsedUpperBound ) : null;
-
- if ( upperBound != null && lowerBound != null )
- {
- if ( upperBound.compareTo( lowerBound ) < 0 )
- {
- throw new InvalidVersionSpecificationException( range, "Invalid version range " + range
- + ", lower bound must not be greater than upper bound" );
- }
- }
- }
-
- this.lowerBound = ( lowerBound != null ) ? new Bound( lowerBound, lowerBoundInclusive ) : null;
- this.upperBound = ( upperBound != null ) ? new Bound( upperBound, upperBoundInclusive ) : null;
- }
-
- private Version parse( String version )
- {
- return new GenericVersion( version );
- }
-
- public Bound getLowerBound()
- {
- return lowerBound;
- }
-
- public Bound getUpperBound()
- {
- return upperBound;
- }
-
- public boolean containsVersion( Version version )
- {
- if ( lowerBound != null )
- {
- int comparison = lowerBound.getVersion().compareTo( version );
-
- if ( comparison == 0 && !lowerBound.isInclusive() )
- {
- return false;
- }
- if ( comparison > 0 )
- {
- return false;
- }
- }
-
- if ( upperBound != null )
- {
- int comparison = upperBound.getVersion().compareTo( version );
-
- if ( comparison == 0 && !upperBound.isInclusive() )
- {
- return false;
- }
- if ( comparison < 0 )
- {
- return false;
- }
- }
-
- return true;
- }
-
- @Override
- public boolean equals( Object obj )
- {
- if ( obj == this )
- {
- return true;
- }
- else if ( obj == null || !getClass().equals( obj.getClass() ) )
- {
- return false;
- }
-
- GenericVersionRange that = (GenericVersionRange) obj;
-
- return eq( upperBound, that.upperBound ) && eq( lowerBound, that.lowerBound );
- }
-
- private static <T> boolean eq( T s1, T s2 )
- {
- return s1 != null ? s1.equals( s2 ) : s2 == null;
- }
-
- @Override
- public int hashCode()
- {
- int hash = 17;
- hash = hash * 31 + hash( upperBound );
- hash = hash * 31 + hash( lowerBound );
- return hash;
- }
-
- private static int hash( Object obj )
- {
- return obj != null ? obj.hashCode() : 0;
- }
-
- @Override
- public String toString()
- {
- StringBuilder buffer = new StringBuilder( 64 );
- if ( lowerBound != null )
- {
- buffer.append( lowerBound.isInclusive() ? '[' : '(' );
- buffer.append( lowerBound.getVersion() );
- }
- else
- {
- buffer.append( '(' );
- }
- buffer.append( ',' );
- if ( upperBound != null )
- {
- buffer.append( upperBound.getVersion() );
- buffer.append( upperBound.isInclusive() ? ']' : ')' );
- }
- else
- {
- buffer.append( ')' );
- }
- return buffer.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-util/src/main/java/org/eclipse/aether/util/version/GenericVersionScheme.java
----------------------------------------------------------------------
diff --git a/aether-util/src/main/java/org/eclipse/aether/util/version/GenericVersionScheme.java b/aether-util/src/main/java/org/eclipse/aether/util/version/GenericVersionScheme.java
deleted file mode 100644
index 8fc0488..0000000
--- a/aether-util/src/main/java/org/eclipse/aether/util/version/GenericVersionScheme.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package org.eclipse.aether.util.version;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.aether.version.InvalidVersionSpecificationException;
-import org.eclipse.aether.version.Version;
-import org.eclipse.aether.version.VersionConstraint;
-import org.eclipse.aether.version.VersionRange;
-import org.eclipse.aether.version.VersionScheme;
-
-/**
- * A version scheme using a generic version syntax and common sense sorting.
- * <p>
- * This scheme accepts versions of any form, interpreting a version as a sequence of numeric and alphabetic segments.
- * The characters '-', '_', and '.' as well as the mere transitions from digit to letter and vice versa delimit the
- * version segments. Delimiters are treated as equivalent.
- * </p>
- * <p>
- * Numeric segments are compared mathematically, alphabetic segments are compared lexicographically and
- * case-insensitively. However, the following qualifier strings are recognized and treated specially: "alpha" = "a" <
- * "beta" = "b" < "milestone" = "m" < "cr" = "rc" < "snapshot" < "final" = "ga" < "sp". All of those
- * well-known qualifiers are considered smaller/older than other strings. An empty segment/string is equivalent to 0.
- * </p>
- * <p>
- * In addition to the above mentioned qualifiers, the tokens "min" and "max" may be used as final version segment to
- * denote the smallest/greatest version having a given prefix. For example, "1.2.min" denotes the smallest version in
- * the 1.2 line, "1.2.max" denotes the greatest version in the 1.2 line. A version range of the form "[M.N.*]" is short
- * for "[M.N.min, M.N.max]".
- * </p>
- * <p>
- * Numbers and strings are considered incomparable against each other. Where version segments of different kind would
- * collide, comparison will instead assume that the previous segments are padded with trailing 0 or "ga" segments,
- * respectively, until the kind mismatch is resolved, e.g. "1-alpha" = "1.0.0-alpha" < "1.0.1-ga" = "1.0.1".
- * </p>
- */
-public final class GenericVersionScheme
- implements VersionScheme
-{
-
- /**
- * Creates a new instance of the version scheme for parsing versions.
- */
- public GenericVersionScheme()
- {
- }
-
- public Version parseVersion( final String version )
- throws InvalidVersionSpecificationException
- {
- return new GenericVersion( version );
- }
-
- public VersionRange parseVersionRange( final String range )
- throws InvalidVersionSpecificationException
- {
- return new GenericVersionRange( range );
- }
-
- public VersionConstraint parseVersionConstraint( final String constraint )
- throws InvalidVersionSpecificationException
- {
- Collection<VersionRange> ranges = new ArrayList<VersionRange>();
-
- String process = constraint;
-
- while ( process.startsWith( "[" ) || process.startsWith( "(" ) )
- {
- int index1 = process.indexOf( ')' );
- int index2 = process.indexOf( ']' );
-
- int index = index2;
- if ( index2 < 0 || ( index1 >= 0 && index1 < index2 ) )
- {
- index = index1;
- }
-
- if ( index < 0 )
- {
- throw new InvalidVersionSpecificationException( constraint, "Unbounded version range " + constraint );
- }
-
- VersionRange range = parseVersionRange( process.substring( 0, index + 1 ) );
- ranges.add( range );
-
- process = process.substring( index + 1 ).trim();
-
- if ( process.length() > 0 && process.startsWith( "," ) )
- {
- process = process.substring( 1 ).trim();
- }
- }
-
- if ( process.length() > 0 && !ranges.isEmpty() )
- {
- throw new InvalidVersionSpecificationException( constraint, "Invalid version range " + constraint
- + ", expected [ or ( but got " + process );
- }
-
- VersionConstraint result;
- if ( ranges.isEmpty() )
- {
- result = new GenericVersionConstraint( parseVersion( constraint ) );
- }
- else
- {
- result = new GenericVersionConstraint( UnionVersionRange.from( ranges ) );
- }
-
- return result;
- }
-
- @Override
- public boolean equals( final Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
-
- return obj != null && getClass().equals( obj.getClass() );
- }
-
- @Override
- public int hashCode()
- {
- return getClass().hashCode();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-util/src/main/java/org/eclipse/aether/util/version/UnionVersionRange.java
----------------------------------------------------------------------
diff --git a/aether-util/src/main/java/org/eclipse/aether/util/version/UnionVersionRange.java b/aether-util/src/main/java/org/eclipse/aether/util/version/UnionVersionRange.java
deleted file mode 100644
index c54a4b4..0000000
--- a/aether-util/src/main/java/org/eclipse/aether/util/version/UnionVersionRange.java
+++ /dev/null
@@ -1,181 +0,0 @@
-package org.eclipse.aether.util.version;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.aether.version.Version;
-import org.eclipse.aether.version.VersionRange;
-
-/**
- * A union of version ranges.
- */
-final class UnionVersionRange
- implements VersionRange
-{
-
- private final Set<VersionRange> ranges;
-
- private final Bound lowerBound;
-
- private final Bound upperBound;
-
- public static VersionRange from( VersionRange... ranges )
- {
- if ( ranges == null )
- {
- return from( Collections.<VersionRange>emptySet() );
- }
- return from( Arrays.asList( ranges ) );
- }
-
- public static VersionRange from( Collection<? extends VersionRange> ranges )
- {
- if ( ranges != null && ranges.size() == 1 )
- {
- return ranges.iterator().next();
- }
- return new UnionVersionRange( ranges );
- }
-
- private UnionVersionRange( Collection<? extends VersionRange> ranges )
- {
- if ( ranges == null || ranges.isEmpty() )
- {
- this.ranges = Collections.emptySet();
- lowerBound = upperBound = null;
- }
- else
- {
- this.ranges = new HashSet<VersionRange>( ranges );
- Bound lowerBound = null, upperBound = null;
- for ( VersionRange range : this.ranges )
- {
- Bound lb = range.getLowerBound();
- if ( lb == null )
- {
- lowerBound = null;
- break;
- }
- else if ( lowerBound == null )
- {
- lowerBound = lb;
- }
- else
- {
- int c = lb.getVersion().compareTo( lowerBound.getVersion() );
- if ( c < 0 || ( c == 0 && !lowerBound.isInclusive() ) )
- {
- lowerBound = lb;
- }
- }
- }
- for ( VersionRange range : this.ranges )
- {
- Bound ub = range.getUpperBound();
- if ( ub == null )
- {
- upperBound = null;
- break;
- }
- else if ( upperBound == null )
- {
- upperBound = ub;
- }
- else
- {
- int c = ub.getVersion().compareTo( upperBound.getVersion() );
- if ( c > 0 || ( c == 0 && !upperBound.isInclusive() ) )
- {
- upperBound = ub;
- }
- }
- }
- this.lowerBound = lowerBound;
- this.upperBound = upperBound;
- }
- }
-
- public boolean containsVersion( Version version )
- {
- for ( VersionRange range : ranges )
- {
- if ( range.containsVersion( version ) )
- {
- return true;
- }
- }
- return false;
- }
-
- public Bound getLowerBound()
- {
- return lowerBound;
- }
-
- public Bound getUpperBound()
- {
- return upperBound;
- }
-
- @Override
- public boolean equals( Object obj )
- {
- if ( obj == this )
- {
- return true;
- }
- else if ( obj == null || !getClass().equals( obj.getClass() ) )
- {
- return false;
- }
-
- UnionVersionRange that = (UnionVersionRange) obj;
-
- return ranges.equals( that.ranges );
- }
-
- @Override
- public int hashCode()
- {
- int hash = 97 * ranges.hashCode();
- return hash;
- }
-
- @Override
- public String toString()
- {
- StringBuilder buffer = new StringBuilder( 128 );
- for ( VersionRange range : ranges )
- {
- if ( buffer.length() > 0 )
- {
- buffer.append( ", " );
- }
- buffer.append( range );
- }
- return buffer.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-util/src/main/java/org/eclipse/aether/util/version/package-info.java
----------------------------------------------------------------------
diff --git a/aether-util/src/main/java/org/eclipse/aether/util/version/package-info.java b/aether-util/src/main/java/org/eclipse/aether/util/version/package-info.java
deleted file mode 100644
index 18dc724..0000000
--- a/aether-util/src/main/java/org/eclipse/aether/util/version/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-// CHECKSTYLE_OFF: RegexpHeader
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * Ready-to-use version schemes for parsing/comparing versions.
- */
-package org.eclipse.aether.util.version;
-
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-util/src/site/site.xml
----------------------------------------------------------------------
diff --git a/aether-util/src/site/site.xml b/aether-util/src/site/site.xml
deleted file mode 100644
index 3a16bf9..0000000
--- a/aether-util/src/site/site.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd">
- <body>
- <menu name="Overview">
- <item name="Introduction" href="index.html"/>
- <item name="JavaDocs" href="apidocs/index.html"/>
- <item name="Source Xref" href="xref/index.html"/>
- <!--item name="FAQ" href="faq.html"/-->
- </menu>
-
- <menu ref="parent"/>
- <menu ref="reports"/>
- </body>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-util/src/test/java/org/eclipse/aether/util/ChecksumUtilTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/ChecksumUtilTest.java b/aether-util/src/test/java/org/eclipse/aether/util/ChecksumUtilTest.java
deleted file mode 100644
index 05da6f4..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/ChecksumUtilTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-package org.eclipse.aether.util;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import static org.eclipse.aether.internal.test.util.TestFileUtils.*;
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.aether.util.ChecksumUtils;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class ChecksumUtilTest
-{
- private File emptyFile;
-
- private File patternFile;
-
- private File textFile;
-
- private static Map<String, String> emptyFileChecksums = new HashMap<String, String>();
-
- private static Map<String, String> patternFileChecksums = new HashMap<String, String>();
-
- private static Map<String, String> textFileChecksums = new HashMap<String, String>();
-
- private Map<File, Map<String, String>> sums = new HashMap<File, Map<String, String>>();
-
- @BeforeClass
- public static void beforeClass()
- throws IOException
- {
- emptyFileChecksums.put( "MD5", "d41d8cd98f00b204e9800998ecf8427e" );
- emptyFileChecksums.put( "SHA-1", "da39a3ee5e6b4b0d3255bfef95601890afd80709" );
- patternFileChecksums.put( "MD5", "14f01d6c7de7d4cf0a4887baa3528b5a" );
- patternFileChecksums.put( "SHA-1", "feeeda19f626f9b0ef6cbf5948c1ec9531694295" );
- textFileChecksums.put( "MD5", "12582d1a662cefe3385f2113998e43ed" );
- textFileChecksums.put( "SHA-1", "a8ae272db549850eef2ff54376f8cac2770745ee" );
- }
-
- @Before
- public void before()
- throws IOException
- {
- sums.clear();
-
- emptyFile = createTempFile( new byte[] {}, 0 );
- sums.put( emptyFile, emptyFileChecksums );
-
- patternFile =
- createTempFile( new byte[] { 0, 1, 2, 4, 8, 16, 32, 64, 127, -1, -2, -4, -8, -16, -32, -64, -127 }, 1000 );
- sums.put( patternFile, patternFileChecksums );
-
- textFile = createTempFile( "the quick brown fox jumps over the lazy dog\n".getBytes( "UTF-8" ), 500 );
- sums.put( textFile, textFileChecksums );
-
- }
-
- @Test
- public void testEquality()
- throws Throwable
- {
- Map<String, Object> checksums = null;
-
- for ( File file : new File[] { emptyFile, patternFile, textFile } )
- {
-
- checksums = ChecksumUtils.calc( file, Arrays.asList( "SHA-1", "MD5" ) );
-
- for ( Entry<String, Object> entry : checksums.entrySet() )
- {
- if ( entry.getValue() instanceof Throwable )
- {
- throw (Throwable) entry.getValue();
- }
- String actual = entry.getValue().toString();
- String expected = sums.get( file ).get( entry.getKey() );
- assertEquals( String.format( "checksums do not match for '%s', algorithm '%s'", file.getName(),
- entry.getKey() ), expected, actual );
- }
- assertTrue( "Could not delete file", file.delete() );
- }
- }
-
- @Test
- public void testFileHandleLeakage()
- throws IOException
- {
- for ( File file : new File[] { emptyFile, patternFile, textFile } )
- {
- for ( int i = 0; i < 150; i++ )
- {
- ChecksumUtils.calc( file, Arrays.asList( "SHA-1", "MD5" ) );
- }
- assertTrue( "Could not delete file", file.delete() );
- }
-
- }
-
- @Test
- public void testRead()
- throws IOException
- {
- for ( Map<String, String> checksums : sums.values() )
- {
- String sha1 = checksums.get( "SHA-1" );
- String md5 = checksums.get( "MD5" );
-
- File sha1File = createTempFile( sha1 );
- File md5File = createTempFile( md5 );
-
- assertEquals( sha1, ChecksumUtils.read( sha1File ) );
- assertEquals( md5, ChecksumUtils.read( md5File ) );
-
- assertTrue( "ChecksumUtils leaks file handles (cannot delete checksums.sha1)", sha1File.delete() );
- assertTrue( "ChecksumUtils leaks file handles (cannot delete checksums.md5)", md5File.delete() );
- }
- }
-
- @Test
- public void testReadSpaces()
- throws IOException
- {
- for ( Map<String, String> checksums : sums.values() )
- {
- String sha1 = checksums.get( "SHA-1" );
- String md5 = checksums.get( "MD5" );
-
- File sha1File = createTempFile( "sha1-checksum = " + sha1 );
- File md5File = createTempFile( md5 + " test" );
-
- assertEquals( sha1, ChecksumUtils.read( sha1File ) );
- assertEquals( md5, ChecksumUtils.read( md5File ) );
-
- assertTrue( "ChecksumUtils leaks file handles (cannot delete checksums.sha1)", sha1File.delete() );
- assertTrue( "ChecksumUtils leaks file handles (cannot delete checksums.md5)", md5File.delete() );
- }
- }
-
- @Test
- public void testReadEmptyFile()
- throws IOException
- {
- File file = createTempFile( "" );
-
- assertEquals( "", ChecksumUtils.read( file ) );
-
- assertTrue( "ChecksumUtils leaks file handles (cannot delete checksum.empty)", file.delete() );
- }
-
- @Test
- public void testToHexString()
- {
- assertEquals( null, ChecksumUtils.toHexString( null ) );
- assertEquals( "", ChecksumUtils.toHexString( new byte[] {} ) );
- assertEquals( "00", ChecksumUtils.toHexString( new byte[] { 0 } ) );
- assertEquals( "ff", ChecksumUtils.toHexString( new byte[] { -1 } ) );
- assertEquals( "00017f", ChecksumUtils.toHexString( new byte[] { 0, 1, 127 } ) );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-util/src/test/java/org/eclipse/aether/util/ConfigUtilsTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/ConfigUtilsTest.java b/aether-util/src/test/java/org/eclipse/aether/util/ConfigUtilsTest.java
deleted file mode 100644
index 9218031..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/ConfigUtilsTest.java
+++ /dev/null
@@ -1,247 +0,0 @@
-package org.eclipse.aether.util;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Test;
-
-public class ConfigUtilsTest
-{
-
- Map<Object, Object> config = new HashMap<Object, Object>();
-
- @Test
- public void testGetObject_Default()
- {
- Object val = new Object();
- assertSame( val, ConfigUtils.getObject( config, val, "no-value" ) );
- }
-
- @Test
- public void testGetObject_AlternativeKeys()
- {
- Object val = new Object();
- config.put( "some-object", val );
- assertSame( val, ConfigUtils.getObject( config, null, "no-object", "some-object" ) );
- }
-
- @Test
- public void testGetMap_Default()
- {
- Map<?, ?> val = new HashMap<Object, Object>();
- assertSame( val, ConfigUtils.getMap( config, val, "no-value" ) );
- }
-
- @Test
- public void testGetMap_AlternativeKeys()
- {
- Map<?, ?> val = new HashMap<Object, Object>();
- config.put( "some-map", val );
- assertSame( val, ConfigUtils.getMap( config, null, "no-object", "some-map" ) );
- }
-
- @Test
- public void testGetList_Default()
- {
- List<?> val = new ArrayList<Object>();
- assertSame( val, ConfigUtils.getList( config, val, "no-value" ) );
- }
-
- @Test
- public void testGetList_AlternativeKeys()
- {
- List<?> val = new ArrayList<Object>();
- config.put( "some-list", val );
- assertSame( val, ConfigUtils.getList( config, null, "no-object", "some-list" ) );
- }
-
- @Test
- public void testGetList_CollectionConversion()
- {
- Collection<?> val = Collections.singleton( "item" );
- config.put( "some-collection", val );
- assertEquals( Arrays.asList( "item" ), ConfigUtils.getList( config, null, "some-collection" ) );
- }
-
- @Test
- public void testGetString_Default()
- {
- config.put( "no-string", new Object() );
- assertEquals( "default", ConfigUtils.getString( config, "default", "no-value" ) );
- assertEquals( "default", ConfigUtils.getString( config, "default", "no-string" ) );
- }
-
- @Test
- public void testGetString_AlternativeKeys()
- {
- config.put( "no-string", new Object() );
- config.put( "some-string", "passed" );
- assertEquals( "passed", ConfigUtils.getString( config, "default", "no-string", "some-string" ) );
- }
-
- @Test
- public void testGetString_BooleanConversion()
- {
- config.put( "some-string", Boolean.TRUE );
- assertEquals( "true", ConfigUtils.getString( config, "default", "some-string" ) );
- config.put( "some-string", Boolean.FALSE );
- assertEquals( "false", ConfigUtils.getString( config, "default", "some-string" ) );
- }
-
- @Test
- public void testGetString_NumberConversion()
- {
- config.put( "some-string", Integer.valueOf( -7 ) );
- assertEquals( "-7", ConfigUtils.getString( config, "default", "some-string" ) );
- config.put( "some-string", new Float( -1.5f ) );
- assertEquals( "-1.5", ConfigUtils.getString( config, "default", "some-string" ) );
- }
-
- @Test
- public void testGetBoolean_Default()
- {
- config.put( "no-boolean", new Object() );
- assertEquals( true, ConfigUtils.getBoolean( config, true, "no-value" ) );
- assertEquals( false, ConfigUtils.getBoolean( config, false, "no-value" ) );
- assertEquals( true, ConfigUtils.getBoolean( config, true, "no-boolean" ) );
- assertEquals( false, ConfigUtils.getBoolean( config, false, "no-boolean" ) );
- }
-
- @Test
- public void testGetBoolean_AlternativeKeys()
- {
- config.put( "no-boolean", new Object() );
- config.put( "some-boolean", true );
- assertEquals( true, ConfigUtils.getBoolean( config, false, "no-boolean", "some-boolean" ) );
- config.put( "some-boolean", false );
- assertEquals( false, ConfigUtils.getBoolean( config, true, "no-boolean", "some-boolean" ) );
- }
-
- @Test
- public void testGetBoolean_StringConversion()
- {
- config.put( "some-boolean", "true" );
- assertEquals( true, ConfigUtils.getBoolean( config, false, "some-boolean" ) );
- config.put( "some-boolean", "false" );
- assertEquals( false, ConfigUtils.getBoolean( config, true, "some-boolean" ) );
- }
-
- @Test
- public void testGetInteger_Default()
- {
- config.put( "no-integer", new Object() );
- assertEquals( -17, ConfigUtils.getInteger( config, -17, "no-value" ) );
- assertEquals( 43, ConfigUtils.getInteger( config, 43, "no-integer" ) );
- }
-
- @Test
- public void testGetInteger_AlternativeKeys()
- {
- config.put( "no-integer", "text" );
- config.put( "some-integer", 23 );
- assertEquals( 23, ConfigUtils.getInteger( config, 0, "no-integer", "some-integer" ) );
- }
-
- @Test
- public void testGetInteger_StringConversion()
- {
- config.put( "some-integer", "-123456" );
- assertEquals( -123456, ConfigUtils.getInteger( config, 0, "some-integer" ) );
- }
-
- @Test
- public void testGetInteger_NumberConversion()
- {
- config.put( "some-number", -123456.789 );
- assertEquals( -123456, ConfigUtils.getInteger( config, 0, "some-number" ) );
- }
-
- @Test
- public void testGetLong_Default()
- {
- config.put( "no-long", new Object() );
- assertEquals( -17, ConfigUtils.getLong( config, -17L, "no-value" ) );
- assertEquals( 43, ConfigUtils.getLong( config, 43L, "no-long" ) );
- }
-
- @Test
- public void testGetLong_AlternativeKeys()
- {
- config.put( "no-long", "text" );
- config.put( "some-long", 23 );
- assertEquals( 23, ConfigUtils.getLong( config, 0, "no-long", "some-long" ) );
- }
-
- @Test
- public void testGetLong_StringConversion()
- {
- config.put( "some-long", "-123456789012" );
- assertEquals( -123456789012L, ConfigUtils.getLong( config, 0, "some-long" ) );
- }
-
- @Test
- public void testGetLong_NumberConversion()
- {
- config.put( "some-number", -123456789012.789 );
- assertEquals( -123456789012L, ConfigUtils.getLong( config, 0, "some-number" ) );
- }
-
- @Test
- public void testGetFloat_Default()
- {
- config.put( "no-float", new Object() );
- assertEquals( -17.1f, ConfigUtils.getFloat( config, -17.1f, "no-value" ), 0.01f );
- assertEquals( 43.2f, ConfigUtils.getFloat( config, 43.2f, "no-float" ), 0.01f );
- }
-
- @Test
- public void testGetFloat_AlternativeKeys()
- {
- config.put( "no-float", "text" );
- config.put( "some-float", 12.3f );
- assertEquals( 12.3f, ConfigUtils.getFloat( config, 0, "no-float", "some-float" ), 0.01f );
- }
-
- @Test
- public void testGetFloat_StringConversion()
- {
- config.put( "some-float", "-12.3" );
- assertEquals( -12.3f, ConfigUtils.getFloat( config, 0, "some-float" ), 0.01f );
- config.put( "some-float", "NaN" );
- assertEquals( true, Float.isNaN( ConfigUtils.getFloat( config, 0, "some-float" ) ) );
- }
-
- @Test
- public void testGetFloat_NumberConversion()
- {
- config.put( "some-number", -1234 );
- assertEquals( -1234f, ConfigUtils.getFloat( config, 0, "some-number" ), 0.1f );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-util/src/test/java/org/eclipse/aether/util/StringUtilsTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/StringUtilsTest.java b/aether-util/src/test/java/org/eclipse/aether/util/StringUtilsTest.java
deleted file mode 100644
index 4ac2f7e..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/StringUtilsTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.eclipse.aether.util;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import static org.junit.Assert.*;
-
-import org.eclipse.aether.util.StringUtils;
-import org.junit.Test;
-
-/**
- */
-public class StringUtilsTest
-{
-
- @Test
- public void testIsEmpty()
- {
- assertTrue( StringUtils.isEmpty( null ) );
- assertTrue( StringUtils.isEmpty( "" ) );
- assertFalse( StringUtils.isEmpty( " " ) );
- assertFalse( StringUtils.isEmpty( "test" ) );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-util/src/test/java/org/eclipse/aether/util/artifact/ArtifactIdUtilsTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/artifact/ArtifactIdUtilsTest.java b/aether-util/src/test/java/org/eclipse/aether/util/artifact/ArtifactIdUtilsTest.java
deleted file mode 100644
index 36193f3..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/artifact/ArtifactIdUtilsTest.java
+++ /dev/null
@@ -1,201 +0,0 @@
-package org.eclipse.aether.util.artifact;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import static org.junit.Assert.*;
-
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.junit.Test;
-
-/**
- */
-public class ArtifactIdUtilsTest
-{
-
- @Test
- public void testToIdArtifact()
- {
- Artifact artifact = null;
- assertSame( null, ArtifactIdUtils.toId( artifact ) );
-
- artifact = new DefaultArtifact( "gid", "aid", "ext", "1.0-20110205.132618-23" );
- assertEquals( "gid:aid:ext:1.0-20110205.132618-23", ArtifactIdUtils.toId( artifact ) );
-
- artifact = new DefaultArtifact( "gid", "aid", "cls", "ext", "1.0-20110205.132618-23" );
- assertEquals( "gid:aid:ext:cls:1.0-20110205.132618-23", ArtifactIdUtils.toId( artifact ) );
- }
-
- @Test
- public void testToIdStrings()
- {
- assertEquals( ":::", ArtifactIdUtils.toId( null, null, null, null, null ) );
-
- assertEquals( "gid:aid:ext:1", ArtifactIdUtils.toId( "gid", "aid", "ext", "", "1" ) );
-
- assertEquals( "gid:aid:ext:cls:1", ArtifactIdUtils.toId( "gid", "aid", "ext", "cls", "1" ) );
- }
-
- @Test
- public void testToBaseIdArtifact()
- {
- Artifact artifact = null;
- assertSame( null, ArtifactIdUtils.toBaseId( artifact ) );
-
- artifact = new DefaultArtifact( "gid", "aid", "ext", "1.0-20110205.132618-23" );
- assertEquals( "gid:aid:ext:1.0-SNAPSHOT", ArtifactIdUtils.toBaseId( artifact ) );
-
- artifact = new DefaultArtifact( "gid", "aid", "cls", "ext", "1.0-20110205.132618-23" );
- assertEquals( "gid:aid:ext:cls:1.0-SNAPSHOT", ArtifactIdUtils.toBaseId( artifact ) );
- }
-
- @Test
- public void testToVersionlessIdArtifact()
- {
- Artifact artifact = null;
- assertSame( null, ArtifactIdUtils.toId( artifact ) );
-
- artifact = new DefaultArtifact( "gid", "aid", "ext", "1" );
- assertEquals( "gid:aid:ext", ArtifactIdUtils.toVersionlessId( artifact ) );
-
- artifact = new DefaultArtifact( "gid", "aid", "cls", "ext", "1" );
- assertEquals( "gid:aid:ext:cls", ArtifactIdUtils.toVersionlessId( artifact ) );
- }
-
- @Test
- public void testToVersionlessIdStrings()
- {
- assertEquals( "::", ArtifactIdUtils.toVersionlessId( null, null, null, null ) );
-
- assertEquals( "gid:aid:ext", ArtifactIdUtils.toVersionlessId( "gid", "aid", "ext", "" ) );
-
- assertEquals( "gid:aid:ext:cls", ArtifactIdUtils.toVersionlessId( "gid", "aid", "ext", "cls" ) );
- }
-
- @Test
- public void testEqualsId()
- {
- Artifact artifact1 = null;
- Artifact artifact2 = null;
- assertEquals( false, ArtifactIdUtils.equalsId( artifact1, artifact2 ) );
- assertEquals( false, ArtifactIdUtils.equalsId( artifact2, artifact1 ) );
-
- artifact1 = new DefaultArtifact( "gid", "aid", "ext", "1.0-20110205.132618-23" );
- assertEquals( false, ArtifactIdUtils.equalsId( artifact1, artifact2 ) );
- assertEquals( false, ArtifactIdUtils.equalsId( artifact2, artifact1 ) );
-
- artifact2 = new DefaultArtifact( "gidX", "aid", "ext", "1.0-20110205.132618-23" );
- assertEquals( false, ArtifactIdUtils.equalsId( artifact1, artifact2 ) );
- assertEquals( false, ArtifactIdUtils.equalsId( artifact2, artifact1 ) );
-
- artifact2 = new DefaultArtifact( "gid", "aidX", "ext", "1.0-20110205.132618-23" );
- assertEquals( false, ArtifactIdUtils.equalsId( artifact1, artifact2 ) );
- assertEquals( false, ArtifactIdUtils.equalsId( artifact2, artifact1 ) );
-
- artifact2 = new DefaultArtifact( "gid", "aid", "extX", "1.0-20110205.132618-23" );
- assertEquals( false, ArtifactIdUtils.equalsId( artifact1, artifact2 ) );
- assertEquals( false, ArtifactIdUtils.equalsId( artifact2, artifact1 ) );
-
- artifact2 = new DefaultArtifact( "gid", "aid", "ext", "1.0-20110205.132618-24" );
- assertEquals( false, ArtifactIdUtils.equalsId( artifact1, artifact2 ) );
- assertEquals( false, ArtifactIdUtils.equalsId( artifact2, artifact1 ) );
-
- artifact2 = new DefaultArtifact( "gid", "aid", "ext", "1.0-20110205.132618-23" );
- assertEquals( true, ArtifactIdUtils.equalsId( artifact1, artifact2 ) );
- assertEquals( true, ArtifactIdUtils.equalsId( artifact2, artifact1 ) );
-
- assertEquals( true, ArtifactIdUtils.equalsId( artifact1, artifact1 ) );
- }
-
- @Test
- public void testEqualsBaseId()
- {
- Artifact artifact1 = null;
- Artifact artifact2 = null;
- assertEquals( false, ArtifactIdUtils.equalsBaseId( artifact1, artifact2 ) );
- assertEquals( false, ArtifactIdUtils.equalsBaseId( artifact2, artifact1 ) );
-
- artifact1 = new DefaultArtifact( "gid", "aid", "ext", "1.0-20110205.132618-23" );
- assertEquals( false, ArtifactIdUtils.equalsBaseId( artifact1, artifact2 ) );
- assertEquals( false, ArtifactIdUtils.equalsBaseId( artifact2, artifact1 ) );
-
- artifact2 = new DefaultArtifact( "gidX", "aid", "ext", "1.0-20110205.132618-23" );
- assertEquals( false, ArtifactIdUtils.equalsBaseId( artifact1, artifact2 ) );
- assertEquals( false, ArtifactIdUtils.equalsBaseId( artifact2, artifact1 ) );
-
- artifact2 = new DefaultArtifact( "gid", "aidX", "ext", "1.0-20110205.132618-23" );
- assertEquals( false, ArtifactIdUtils.equalsBaseId( artifact1, artifact2 ) );
- assertEquals( false, ArtifactIdUtils.equalsBaseId( artifact2, artifact1 ) );
-
- artifact2 = new DefaultArtifact( "gid", "aid", "extX", "1.0-20110205.132618-23" );
- assertEquals( false, ArtifactIdUtils.equalsBaseId( artifact1, artifact2 ) );
- assertEquals( false, ArtifactIdUtils.equalsBaseId( artifact2, artifact1 ) );
-
- artifact2 = new DefaultArtifact( "gid", "aid", "ext", "X.0-20110205.132618-23" );
- assertEquals( false, ArtifactIdUtils.equalsBaseId( artifact1, artifact2 ) );
- assertEquals( false, ArtifactIdUtils.equalsBaseId( artifact2, artifact1 ) );
-
- artifact2 = new DefaultArtifact( "gid", "aid", "ext", "1.0-20110205.132618-24" );
- assertEquals( true, ArtifactIdUtils.equalsBaseId( artifact1, artifact2 ) );
- assertEquals( true, ArtifactIdUtils.equalsBaseId( artifact2, artifact1 ) );
-
- artifact2 = new DefaultArtifact( "gid", "aid", "ext", "1.0-20110205.132618-23" );
- assertEquals( true, ArtifactIdUtils.equalsBaseId( artifact1, artifact2 ) );
- assertEquals( true, ArtifactIdUtils.equalsBaseId( artifact2, artifact1 ) );
-
- assertEquals( true, ArtifactIdUtils.equalsBaseId( artifact1, artifact1 ) );
- }
-
- @Test
- public void testEqualsVersionlessId()
- {
- Artifact artifact1 = null;
- Artifact artifact2 = null;
- assertEquals( false, ArtifactIdUtils.equalsVersionlessId( artifact1, artifact2 ) );
- assertEquals( false, ArtifactIdUtils.equalsVersionlessId( artifact2, artifact1 ) );
-
- artifact1 = new DefaultArtifact( "gid", "aid", "ext", "1.0-20110205.132618-23" );
- assertEquals( false, ArtifactIdUtils.equalsVersionlessId( artifact1, artifact2 ) );
- assertEquals( false, ArtifactIdUtils.equalsVersionlessId( artifact2, artifact1 ) );
-
- artifact2 = new DefaultArtifact( "gidX", "aid", "ext", "1.0-20110205.132618-23" );
- assertEquals( false, ArtifactIdUtils.equalsVersionlessId( artifact1, artifact2 ) );
- assertEquals( false, ArtifactIdUtils.equalsVersionlessId( artifact2, artifact1 ) );
-
- artifact2 = new DefaultArtifact( "gid", "aidX", "ext", "1.0-20110205.132618-23" );
- assertEquals( false, ArtifactIdUtils.equalsVersionlessId( artifact1, artifact2 ) );
- assertEquals( false, ArtifactIdUtils.equalsVersionlessId( artifact2, artifact1 ) );
-
- artifact2 = new DefaultArtifact( "gid", "aid", "extX", "1.0-20110205.132618-23" );
- assertEquals( false, ArtifactIdUtils.equalsVersionlessId( artifact1, artifact2 ) );
- assertEquals( false, ArtifactIdUtils.equalsVersionlessId( artifact2, artifact1 ) );
-
- artifact2 = new DefaultArtifact( "gid", "aid", "ext", "1.0-20110205.132618-24" );
- assertEquals( true, ArtifactIdUtils.equalsVersionlessId( artifact1, artifact2 ) );
- assertEquals( true, ArtifactIdUtils.equalsVersionlessId( artifact2, artifact1 ) );
-
- artifact2 = new DefaultArtifact( "gid", "aid", "ext", "1.0-20110205.132618-23" );
- assertEquals( true, ArtifactIdUtils.equalsVersionlessId( artifact1, artifact2 ) );
- assertEquals( true, ArtifactIdUtils.equalsVersionlessId( artifact2, artifact1 ) );
-
- assertEquals( true, ArtifactIdUtils.equalsVersionlessId( artifact1, artifact1 ) );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-util/src/test/java/org/eclipse/aether/util/artifact/SubArtifactTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/artifact/SubArtifactTest.java b/aether-util/src/test/java/org/eclipse/aether/util/artifact/SubArtifactTest.java
deleted file mode 100644
index dc0e472..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/artifact/SubArtifactTest.java
+++ /dev/null
@@ -1,158 +0,0 @@
-package org.eclipse.aether.util.artifact;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.aether.util.artifact.SubArtifact;
-import org.junit.Test;
-
-/**
- */
-public class SubArtifactTest
-{
-
- private Artifact newMainArtifact( String coords )
- {
- return new DefaultArtifact( coords );
- }
-
- @Test
- public void testMainArtifactFileNotRetained()
- {
- Artifact a = newMainArtifact( "gid:aid:ver" ).setFile( new File( "" ) );
- assertNotNull( a.getFile() );
- a = new SubArtifact( a, "", "pom" );
- assertNull( a.getFile() );
- }
-
- @Test
- public void testMainArtifactPropertiesNotRetained()
- {
- Artifact a = newMainArtifact( "gid:aid:ver" ).setProperties( Collections.singletonMap( "key", "value" ) );
- assertEquals( 1, a.getProperties().size() );
- a = new SubArtifact( a, "", "pom" );
- assertEquals( 0, a.getProperties().size() );
- assertSame( null, a.getProperty( "key", null ) );
- }
-
- @Test( expected = IllegalArgumentException.class )
- public void testMainArtifactMissing()
- {
- new SubArtifact( null, "", "pom" );
- }
-
- @Test
- public void testEmptyClassifier()
- {
- Artifact main = newMainArtifact( "gid:aid:ext:cls:ver" );
- Artifact sub = new SubArtifact( main, "", "pom" );
- assertEquals( "", sub.getClassifier() );
- sub = new SubArtifact( main, null, "pom" );
- assertEquals( "", sub.getClassifier() );
- }
-
- @Test
- public void testEmptyExtension()
- {
- Artifact main = newMainArtifact( "gid:aid:ext:cls:ver" );
- Artifact sub = new SubArtifact( main, "tests", "" );
- assertEquals( "", sub.getExtension() );
- sub = new SubArtifact( main, "tests", null );
- assertEquals( "", sub.getExtension() );
- }
-
- @Test
- public void testSameClassifier()
- {
- Artifact main = newMainArtifact( "gid:aid:ext:cls:ver" );
- Artifact sub = new SubArtifact( main, "*", "pom" );
- assertEquals( "cls", sub.getClassifier() );
- }
-
- @Test
- public void testSameExtension()
- {
- Artifact main = newMainArtifact( "gid:aid:ext:cls:ver" );
- Artifact sub = new SubArtifact( main, "tests", "*" );
- assertEquals( "ext", sub.getExtension() );
- }
-
- @Test
- public void testDerivedClassifier()
- {
- Artifact main = newMainArtifact( "gid:aid:ext:cls:ver" );
- Artifact sub = new SubArtifact( main, "*-tests", "pom" );
- assertEquals( "cls-tests", sub.getClassifier() );
- sub = new SubArtifact( main, "tests-*", "pom" );
- assertEquals( "tests-cls", sub.getClassifier() );
-
- main = newMainArtifact( "gid:aid:ext:ver" );
- sub = new SubArtifact( main, "*-tests", "pom" );
- assertEquals( "tests", sub.getClassifier() );
- sub = new SubArtifact( main, "tests-*", "pom" );
- assertEquals( "tests", sub.getClassifier() );
- }
-
- @Test
- public void testDerivedExtension()
- {
- Artifact main = newMainArtifact( "gid:aid:ext:cls:ver" );
- Artifact sub = new SubArtifact( main, "", "*.asc" );
- assertEquals( "ext.asc", sub.getExtension() );
- sub = new SubArtifact( main, "", "asc.*" );
- assertEquals( "asc.ext", sub.getExtension() );
- }
-
- @Test
- public void testImmutability()
- {
- Artifact a = new SubArtifact( newMainArtifact( "gid:aid:ver" ), "", "pom" );
- assertNotSame( a, a.setFile( new File( "file" ) ) );
- assertNotSame( a, a.setVersion( "otherVersion" ) );
- assertNotSame( a, a.setProperties( Collections.singletonMap( "key", "value" ) ) );
- }
-
- @Test
- public void testPropertiesCopied()
- {
- Map<String, String> props = new HashMap<String, String>();
- props.put( "key", "value1" );
-
- Artifact a = new SubArtifact( newMainArtifact( "gid:aid:ver" ), "", "pom", props, null );
- assertEquals( "value1", a.getProperty( "key", null ) );
- props.clear();
- assertEquals( "value1", a.getProperty( "key", null ) );
-
- props.put( "key", "value2" );
- a = a.setProperties( props );
- assertEquals( "value2", a.getProperty( "key", null ) );
- props.clear();
- assertEquals( "value2", a.getProperty( "key", null ) );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-util/src/test/java/org/eclipse/aether/util/filter/AbstractDependencyFilterTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/filter/AbstractDependencyFilterTest.java b/aether-util/src/test/java/org/eclipse/aether/util/filter/AbstractDependencyFilterTest.java
deleted file mode 100644
index 835c1ce..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/filter/AbstractDependencyFilterTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.eclipse.aether.util.filter;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.List;
-
-import org.eclipse.aether.graph.DependencyFilter;
-import org.eclipse.aether.graph.DependencyNode;
-
-public abstract class AbstractDependencyFilterTest
-{
-
- protected DependencyFilter getAcceptFilter()
- {
- return new DependencyFilter()
- {
-
- public boolean accept( DependencyNode node, List<DependencyNode> parents )
- {
- return true;
- }
-
- };
- }
-
- protected DependencyFilter getDenyFilter()
- {
- return new DependencyFilter()
- {
-
- public boolean accept( DependencyNode node, List<DependencyNode> parents )
- {
- return false;
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/maven-aether/blob/27f8bd73/aether-util/src/test/java/org/eclipse/aether/util/filter/AndDependencyFilterTest.java
----------------------------------------------------------------------
diff --git a/aether-util/src/test/java/org/eclipse/aether/util/filter/AndDependencyFilterTest.java b/aether-util/src/test/java/org/eclipse/aether/util/filter/AndDependencyFilterTest.java
deleted file mode 100644
index 45a7f3d..0000000
--- a/aether-util/src/test/java/org/eclipse/aether/util/filter/AndDependencyFilterTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package org.eclipse.aether.util.filter;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import static org.junit.Assert.*;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.aether.graph.DependencyFilter;
-import org.eclipse.aether.graph.DependencyNode;
-import org.eclipse.aether.internal.test.util.NodeBuilder;
-import org.eclipse.aether.util.filter.AndDependencyFilter;
-import org.junit.Test;
-
-public class AndDependencyFilterTest
- extends AbstractDependencyFilterTest
-{
- @Test
- public void acceptTest()
- {
- NodeBuilder builder = new NodeBuilder();
- builder.artifactId( "test" );
- List<DependencyNode> parents = new LinkedList<DependencyNode>();
-
- // Empty AND
- assertTrue( new AndDependencyFilter().accept( builder.build(), parents ) );
-
- // Basic Boolean Input
- assertTrue( new AndDependencyFilter( getAcceptFilter() ).accept( builder.build(), parents ) );
- assertFalse( new AndDependencyFilter( getDenyFilter() ).accept( builder.build(), parents ) );
-
- assertFalse( new AndDependencyFilter( getDenyFilter(), getDenyFilter() ).accept( builder.build(), parents ) );
- assertFalse( new AndDependencyFilter( getDenyFilter(), getAcceptFilter() ).accept( builder.build(), parents ) );
- assertFalse( new AndDependencyFilter( getAcceptFilter(), getDenyFilter() ).accept( builder.build(), parents ) );
- assertTrue( new AndDependencyFilter( getAcceptFilter(), getAcceptFilter() ).accept( builder.build(), parents ) );
-
- assertFalse( new AndDependencyFilter( getDenyFilter(), getDenyFilter(), getDenyFilter() ).accept( builder.build(),
- parents ) );
- assertFalse( new AndDependencyFilter( getAcceptFilter(), getDenyFilter(), getDenyFilter() ).accept( builder.build(),
- parents ) );
- assertFalse( new AndDependencyFilter( getAcceptFilter(), getAcceptFilter(), getDenyFilter() ).accept( builder.build(),
- parents ) );
- assertTrue( new AndDependencyFilter( getAcceptFilter(), getAcceptFilter(), getAcceptFilter() ).accept( builder.build(),
- parents ) );
-
- // User another constructor
- Collection<DependencyFilter> filters = new LinkedList<DependencyFilter>();
- filters.add( getDenyFilter() );
- filters.add( getAcceptFilter() );
- assertFalse( new AndDependencyFilter( filters ).accept( builder.build(), parents ) );
-
- filters = new LinkedList<DependencyFilter>();
- filters.add( getDenyFilter() );
- filters.add( getDenyFilter() );
- assertFalse( new AndDependencyFilter( filters ).accept( builder.build(), parents ) );
-
- filters = new LinkedList<DependencyFilter>();
- filters.add( getAcceptFilter() );
- filters.add( getAcceptFilter() );
- assertTrue( new AndDependencyFilter( filters ).accept( builder.build(), parents ) );
-
- // newInstance
- assertTrue( AndDependencyFilter.newInstance( getAcceptFilter(), getAcceptFilter() ).accept( builder.build(),
- parents ) );
- assertFalse( AndDependencyFilter.newInstance( getAcceptFilter(), getDenyFilter() ).accept( builder.build(),
- parents ) );
-
- assertFalse( AndDependencyFilter.newInstance( getDenyFilter(), null ).accept( builder.build(), parents ) );
- assertTrue( AndDependencyFilter.newInstance( getAcceptFilter(), null ).accept( builder.build(), parents ) );
- assertNull( AndDependencyFilter.newInstance( null, null ) );
- }
-
-}