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, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.util; 019 020import static org.junit.Assert.assertTrue; 021 022import org.apache.hadoop.hbase.HBaseClassTestRule; 023import org.apache.hadoop.hbase.testclassification.SmallTests; 024import org.junit.ClassRule; 025import org.junit.Test; 026import org.junit.experimental.categories.Category; 027 028@Category(SmallTests.class) 029public class TestVersionInfo { 030 031 @ClassRule 032 public static final HBaseClassTestRule CLASS_RULE = 033 HBaseClassTestRule.forClass(TestVersionInfo.class); 034 035 @Test 036 public void testCompareVersion() { 037 assertTrue(VersionInfo.compareVersion("1.0.0", "0.98.11") > 0); 038 assertTrue(VersionInfo.compareVersion("0.98.11", "1.0.1") < 0); 039 assertTrue(VersionInfo.compareVersion("2.0.0", "1.4.0") > 0); 040 assertTrue(VersionInfo.compareVersion("2.0.0", "2.0.0-SNAPSHOT") > 0); 041 assertTrue(VersionInfo.compareVersion("0.94.6.1", "0.96.1.1") < 0); 042 assertTrue(VersionInfo.compareVersion("0.96.1.1", "0.98.6.1") < 0); 043 assertTrue(VersionInfo.compareVersion("0.98.6.1", "0.98.10.1") < 0); 044 assertTrue(VersionInfo.compareVersion("0.98.10.1", "0.98.12.1") < 0); 045 assertTrue(VersionInfo.compareVersion("0.98.12.1", "0.98.16.1") < 0); 046 assertTrue(VersionInfo.compareVersion("0.98.16.1", "1.0.1.1") < 0); 047 assertTrue(VersionInfo.compareVersion("1.0.1.1", "1.1.0.1") < 0); 048 assertTrue(VersionInfo.compareVersion("2.0..1", "2.0.0") > 0); 049 assertTrue(VersionInfo.compareVersion("2.0.0", "2.0.0") == 0); 050 assertTrue(VersionInfo.compareVersion("1.99.14", "2.0.0-alpha-1") < 0); 051 assertTrue(VersionInfo.compareVersion("2.0.0-alpha-1", "2.0.0-beta-3") < 0); 052 assertTrue(VersionInfo.compareVersion("2.0.0-beta-3", "2.0.0-SNAPSHOT") < 0); 053 assertTrue(VersionInfo.compareVersion("2.0.0-SNAPSHOT", "2.0") < 0); 054 assertTrue(VersionInfo.compareVersion("2.0", "2.0.0.1") < 0); 055 assertTrue(VersionInfo.compareVersion("2.0.0.1", "2.0.1") < 0); 056 assertTrue(VersionInfo.compareVersion("3.0.0-alpha-2", "3.0.0-alpha-11") < 0); 057 assertTrue(VersionInfo.compareVersion("3.0.0-beta-2", "3.0.0-beta-11") < 0); 058 assertTrue(VersionInfo.compareVersion("2.0.0-foobar", "2.0.0.1") < 0); 059 assertTrue(VersionInfo.compareVersion("2.any.any", "2.0.0") < 0); 060 assertTrue(VersionInfo.compareVersion("2.0.0", "2.any.any") > 0); 061 assertTrue(VersionInfo.compareVersion("2.any.any", "2.0.0-alpha-1") < 0); 062 assertTrue(VersionInfo.compareVersion("2.0.0-alpha-1", "2.any.any") > 0); 063 assertTrue(VersionInfo.compareVersion("2.any.any", "2.0.0-beta-5-SNAPSHOT") < 0); 064 assertTrue(VersionInfo.compareVersion("2.0.0-beta-5-SNAPSHOT", "2.any.any") > 0); 065 assertTrue(VersionInfo.compareVersion("2.any.any", "1.4.4") > 0); 066 assertTrue(VersionInfo.compareVersion("1.4.4", "2.any.any") < 0); 067 } 068}