001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019
020 package org.apache.maven.toolchain;
021
022 import junit.framework.TestCase;
023
024 /**
025 *
026 * @author mkleint
027 */
028 public class RequirementMatcherFactoryTest
029 extends TestCase
030 {
031
032 public RequirementMatcherFactoryTest( String testName )
033 {
034 super( testName );
035 }
036
037 /**
038 * Test of createExactMatcher method, of class RequirementMatcherFactory.
039 */
040 public void testCreateExactMatcher()
041 {
042 RequirementMatcher matcher;
043 matcher = RequirementMatcherFactory.createExactMatcher( "foo" );
044 assertFalse( matcher.matches( "bar" ) );
045 assertFalse( matcher.matches( "foobar" ) );
046 assertFalse( matcher.matches( "foob" ) );
047 assertTrue( matcher.matches( "foo" ) );
048 }
049
050 /**
051 * Test of createVersionMatcher method, of class RequirementMatcherFactory.
052 */
053 public void testCreateVersionMatcher()
054 {
055 RequirementMatcher matcher;
056 matcher = RequirementMatcherFactory.createVersionMatcher( "1.5.2" );
057 assertFalse( matcher.matches( "1.5" ) );
058 assertTrue( matcher.matches( "1.5.2" ) );
059 assertFalse( matcher.matches( "[1.4,1.5)" ) );
060 assertFalse( matcher.matches( "[1.5,1.5.2)" ) );
061 assertFalse( matcher.matches( "(1.5.2,1.6)" ) );
062 assertTrue( matcher.matches( "(1.4,1.5.2]" ) );
063 assertTrue( matcher.matches( "(1.5,)" ) );
064 }
065
066 }