View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.juneau.internal;
18  
19  import static org.junit.jupiter.api.Assertions.*;
20  
21  import org.apache.juneau.*;
22  import org.junit.jupiter.params.*;
23  import org.junit.jupiter.params.provider.*;
24  
25  class VersionRange_Test extends TestBase {
26  
27  	private static final Input[] INPUT = {
28  		/* 00 */ input("1.1", "1.1.3", true),
29  		/* 01 */ input("1.1", "1.1", true),
30  		/* 02 */ input("1.1", "1.1.0", true),
31  		/* 03 */ input("1.1", "1.0", false),
32  		/* 04 */ input("1.1", "1.0.9", false),
33  		/* 05 */ input("[1.0,2.0)", ".9", false),
34  		/* 06 */ input("[1.0,2.0)", "1", true),
35  		/* 07 */ input("[1.0,2.0)", "1.0", true),
36  		/* 08 */ input("[1.0,2.0)", "1.0.0", true),
37  		/* 09 */ input("[1.0,2.0)", "1.1", true),
38  		/* 10 */ input("[1.0,2.0)", "2.0", false),
39  		/* 11 */ input("[1.0,2.0)", "2", false),
40  		/* 12 */ input("(1.0,2.0]", "2", true),
41  		/* 13 */ input("(1.0,2.0]", "2.0", true),
42  		/* 14 */ input("(1.0,2.0]", "2.0.1", true),
43  		/* 15 */ input("(1.0,2.0]", "2.1", false),
44  		/* 16 */ input("(.5.0,.6]", ".5", false),
45  		/* 17 */ input("(.5.0,.6]", ".5.1", true),
46  		/* 18 */ input("(.5.0,.6]", ".6", true),
47  		/* 19 */ input("(.5.0,.6]", ".6.1", true),
48  		/* 20 */ input("(.5.0,.6]", ".7", false),
49  		/* 21 */ input("[1.1,2.0)", "1", false)
50  	};
51  
52  	private static Input input(String range, String version, boolean shouldMatch) {
53  		return new Input(range, version, shouldMatch);
54  	}
55  
56  	private static class Input {
57  		VersionRange range;
58  		String version;
59  		boolean shouldMatch;
60  
61  		public Input(String range, String version, boolean shouldMatch) {
62  			this.version = version;
63  			this.range = new VersionRange(range);
64  			this.shouldMatch = shouldMatch;
65  		}
66  	}
67  
68  	static Input[] input() {
69  		return INPUT;
70  	}
71  
72  	@ParameterizedTest
73  	@MethodSource("input")
74  	void a01_basic(Input input) {
75  		assertEquals(input.shouldMatch, input.range.matches(input.version));
76  	}
77  }