11#! /bin/bash
22
33# Tests for the functions used in universalJavaApplicationStub script
4- # tofi86 @ 2018-02-12
4+ # tofi86 @ 2018-03-10
55
66
77
@@ -27,7 +27,7 @@ function get_java_version_from_cmd() {
2727# @return the major version (e.g. '7', '8' or '9', etc.)
2828# ###############################################################################
2929function extract_java_major_version() {
30- echo $( echo " $1 " | sed -E ' s/^1\.//;s/^([0-9]+)(-ea|(\.[0-9_.]{1,7})?)[+*]?$/\1/' )
30+ echo $( echo " $1 " | sed -E ' s/^1\.//;s/^([0-9]+)(-ea|(\.[0-9_.]{1,7})?)(-b[0-9]+-[0-9]+)? [+*]?$/\1/' )
3131}
3232
3333
@@ -39,8 +39,8 @@ function extract_java_major_version() {
3939# @return an 8 digit numeral ('1.8.0_45'->'08000045'; '9.1.13'->'09001013')
4040# ###############################################################################
4141function get_comparable_java_version() {
42- # cleaning: 1) remove leading '1.'; 2) remove ' a-Z' and '-*+' (e.g. '-ea'); 3 ) replace '_' with '.'
43- local cleaned=$( echo " $1 " | sed -E ' s/^1\.//g;s/[a-zA-Z+*\-]//g;s/_/./g' )
42+ # cleaning: 1) remove leading '1.'; 2) remove build string (e.g. '-b14-468'); 3) remove ' a-Z' and '-*+' (e.g. '-ea'); 4 ) replace '_' with '.'
43+ local cleaned=$( echo " $1 " | sed -E ' s/^1\.//g;s/-b[0-9]+-[0-9]+$//g;s/ [a-zA-Z+*\-]//g;s/_/./g' )
4444 # splitting at '.' into an array
4545 local arr=( ${cleaned// ./ } )
4646 # echo a string with left padded version numbers
@@ -181,6 +181,7 @@ testExtractMajor "1.6+" "6"
181181testExtractMajor " 1.6.0" " 6"
182182testExtractMajor " 1.6.0_07" " 6"
183183testExtractMajor " 1.6.0_45" " 6"
184+ testExtractMajor " 1.6.0_65-b14-468" " 6"
184185echo " "
185186echo " Tests with Java 1.7:"
186187testExtractMajor " 1.7" " 7"
@@ -245,6 +246,7 @@ echo "Tests with Java 1.6:"
245246testComparable " 1.6" " 06000000"
246247testComparable " 1.6+" " 06000000"
247248testComparable " 1.6.0_45" " 06000045"
249+ testComparable " 1.6.0_65-b14-468" " 06000065"
248250testComparable " 1.6.0_100" " 06000100"
249251testComparable " 1.6.1_87" " 06001087"
250252echo " "
0 commit comments