Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions parquet-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
</properties>

<dependencies>
<dependency>
<groupId>org.semver</groupId>
<artifactId>api</artifactId>
<version>${semver.api.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
62 changes: 62 additions & 0 deletions parquet-common/src/test/java/org/apache/parquet/VersionTest.java
Original file line number Diff line number Diff line change
@@ -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);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use Assert.fail here? up to you

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to originally, but fail() doesn't let you chain another exception, like fail("message", e) and I didn't want to drop the original exception from the logs. But I wish it did

}

@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());
}
}
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<pig.classifier />
<thrift.version>0.7.0</thrift.version>
<fastutil.version>6.5.7</fastutil.version>
<semver.api.version>0.9.33</semver.api.version>
</properties>

<modules>
Expand Down