diff --git a/parquet-common/pom.xml b/parquet-common/pom.xml index eacf2ab2f3..d026d9d0a0 100644 --- a/parquet-common/pom.xml +++ b/parquet-common/pom.xml @@ -36,6 +36,12 @@ + + org.semver + api + ${semver.api.version} + test + diff --git a/parquet-common/src/test/java/org/apache/parquet/VersionTest.java b/parquet-common/src/test/java/org/apache/parquet/VersionTest.java new file mode 100644 index 0000000000..e68b2f297a --- /dev/null +++ b/parquet-common/src/test/java/org/apache/parquet/VersionTest.java @@ -0,0 +1,62 @@ +/* + * 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. + */ +package org.apache.parquet; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * This test doesn't do much, but it makes sure that the Version class + * was properly generated, and that it's VERSION_NUMBER field has been + * populated correctly. The hope is to catch any issues like the version + * being an empty string or something along those lines. + */ +public class VersionTest { + + private void assertVersionValid(String v) { + try { + org.semver.Version.parse(v); + } catch (RuntimeException e) { + throw new RuntimeException(v + " is not a valid semver!" , e); + } + } + + @Test + public void testVersion() { + assertVersionValid(Version.VERSION_NUMBER); + } + + @Test + public void testFullVersion() { + // example: parquet-mr version 1.8.0rc2-SNAPSHOT (build ddb469afac70404ea63b72ed2f07a911a8592ff7) + String regex = "parquet-mr version (.*) \\(build (.*)\\)"; + Pattern pattern = Pattern.compile(regex); + Matcher m = pattern.matcher(Version.FULL_VERSION); + assertTrue(Version.FULL_VERSION + " did not match " + pattern, m.matches()); + assertVersionValid(m.group(1)); + assertEquals(Version.VERSION_NUMBER, m.group(1)); + assertFalse(m.group(2).isEmpty()); + } +} diff --git a/pom.xml b/pom.xml index c4240710cf..c171660b3d 100644 --- a/pom.xml +++ b/pom.xml @@ -90,6 +90,7 @@ 0.7.0 6.5.7 + 0.9.33