1
1
#! /bin/bash
2
2
3
3
# Tests for the functions used in universalJavaApplicationStub script
4
- # tofi86 @ 2018-02-12
4
+ # tofi86 @ 2018-03-10
5
5
6
6
7
7
@@ -27,7 +27,7 @@ function get_java_version_from_cmd() {
27
27
# @return the major version (e.g. '7', '8' or '9', etc.)
28
28
# ###############################################################################
29
29
function 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/' )
31
31
}
32
32
33
33
@@ -39,8 +39,8 @@ function extract_java_major_version() {
39
39
# @return an 8 digit numeral ('1.8.0_45'->'08000045'; '9.1.13'->'09001013')
40
40
# ###############################################################################
41
41
function 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' )
44
44
# splitting at '.' into an array
45
45
local arr=( ${cleaned// ./ } )
46
46
# echo a string with left padded version numbers
@@ -181,6 +181,7 @@ testExtractMajor "1.6+" "6"
181
181
testExtractMajor " 1.6.0" " 6"
182
182
testExtractMajor " 1.6.0_07" " 6"
183
183
testExtractMajor " 1.6.0_45" " 6"
184
+ testExtractMajor " 1.6.0_65-b14-468" " 6"
184
185
echo " "
185
186
echo " Tests with Java 1.7:"
186
187
testExtractMajor " 1.7" " 7"
@@ -245,6 +246,7 @@ echo "Tests with Java 1.6:"
245
246
testComparable " 1.6" " 06000000"
246
247
testComparable " 1.6+" " 06000000"
247
248
testComparable " 1.6.0_45" " 06000045"
249
+ testComparable " 1.6.0_65-b14-468" " 06000065"
248
250
testComparable " 1.6.0_100" " 06000100"
249
251
testComparable " 1.6.1_87" " 06001087"
250
252
echo " "
0 commit comments