-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump the version from 1.12.1 to 1.12.2 (#202)
* Bump the version from 1.12.1 to 1.12.2 * Bump the version for the user agent, make it dynamic, add test to check it matches the value from pom * Adjust variable name and cleanup test * Extract constants
- Loading branch information
1 parent
bad77af
commit eac8b8d
Showing
4 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version=${project.version} |
60 changes: 60 additions & 0 deletions
60
src/test/java/com/amazonaws/kinesisvideo/util/VersionUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.amazonaws.kinesisvideo.util; | ||
|
||
import org.junit.Test; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.FileReader; | ||
import java.io.IOException; | ||
|
||
import static com.amazonaws.kinesisvideo.util.VersionUtil.AWS_SDK_KVS_PRODUCER_VERSION_STRING; | ||
import static com.amazonaws.kinesisvideo.util.VersionUtil.getUserAgent; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class VersionUtilTest { | ||
|
||
private static final String POM_XML_LOCATION = "pom.xml"; | ||
|
||
@Test | ||
public void test_versionString_isNotNullOrEmpty() { | ||
final String producerVersionString = AWS_SDK_KVS_PRODUCER_VERSION_STRING; | ||
assertNotNull(producerVersionString); | ||
assertNotEquals("", producerVersionString); | ||
} | ||
|
||
@Test | ||
public void test_versionString_isEqualToDeclaredInPomXML() throws IOException { | ||
final String producerVersionString = extractVersionFromPomXML(); | ||
|
||
assertNotNull("project.version was not found in pom.xml!", producerVersionString); | ||
assertNotEquals("", producerVersionString); | ||
assertEquals(producerVersionString, AWS_SDK_KVS_PRODUCER_VERSION_STRING); | ||
} | ||
|
||
@Test | ||
public void test_userAgent_containsProjectVersion() throws IOException { | ||
final String userAgent = getUserAgent(); | ||
final String pomDefinedProjectVersion = extractVersionFromPomXML(); | ||
|
||
assertNotNull(userAgent); | ||
assertNotEquals("", userAgent); | ||
|
||
assertNotNull(pomDefinedProjectVersion); | ||
assertNotEquals("", pomDefinedProjectVersion); | ||
|
||
assertTrue(userAgent.contains(pomDefinedProjectVersion)); | ||
} | ||
|
||
private String extractVersionFromPomXML() throws IOException { | ||
try (final BufferedReader reader = new BufferedReader(new FileReader(POM_XML_LOCATION))) { | ||
return reader.lines() | ||
.filter(line -> line.contains("<version>")) | ||
.map(line -> line.replace("<version>", "") | ||
.replace("</version>", "").trim()) | ||
.findFirst() | ||
.orElseThrow(() -> new IllegalStateException("'<version>projectVersion</version>' is not found in " + POM_XML_LOCATION)); | ||
} | ||
} | ||
} |