11import { HttpClient } from '@actions/http-client' ;
22
3- import * as semver from 'semver' ;
4-
5- import { AdoptDistribution } from '../../src/distributions/adopt/installer' ;
3+ import { AdoptDistribution , AdoptImplementation } from '../../src/distributions/adopt/installer' ;
64import { JavaInstallerOptions } from '../../src/distributions/base-models' ;
75
86let manifestData = require ( '../data/adopt.json' ) as [ ] ;
@@ -28,26 +26,54 @@ describe('getAvailableVersions', () => {
2826 it . each ( [
2927 [
3028 { version : '11' , architecture : 'x64' , packageType : 'jdk' , checkLatest : false } ,
31- 'os=mac&architecture=x64&image_type=jdk&release_type=ga&page_size=20&page=0'
29+ AdoptImplementation . Hotspot ,
30+ 'os=mac&architecture=x64&image_type=jdk&release_type=ga&jvm_impl=hotspot&page_size=20&page=0'
3231 ] ,
3332 [
3433 { version : '11' , architecture : 'x86' , packageType : 'jdk' , checkLatest : false } ,
35- 'os=mac&architecture=x86&image_type=jdk&release_type=ga&page_size=20&page=0'
34+ AdoptImplementation . Hotspot ,
35+ 'os=mac&architecture=x86&image_type=jdk&release_type=ga&jvm_impl=hotspot&page_size=20&page=0'
3636 ] ,
3737 [
3838 { version : '11' , architecture : 'x64' , packageType : 'jre' , checkLatest : false } ,
39- 'os=mac&architecture=x64&image_type=jre&release_type=ga&page_size=20&page=0'
39+ AdoptImplementation . Hotspot ,
40+ 'os=mac&architecture=x64&image_type=jre&release_type=ga&jvm_impl=hotspot&page_size=20&page=0'
4041 ] ,
4142 [
4243 { version : '11-ea' , architecture : 'x64' , packageType : 'jdk' , checkLatest : false } ,
43- 'os=mac&architecture=x64&image_type=jdk&release_type=ea&page_size=20&page=0'
44+ AdoptImplementation . Hotspot ,
45+ 'os=mac&architecture=x64&image_type=jdk&release_type=ea&jvm_impl=hotspot&page_size=20&page=0'
46+ ] ,
47+ [
48+ { version : '11' , architecture : 'x64' , packageType : 'jdk' , checkLatest : false } ,
49+ AdoptImplementation . OpenJ9 ,
50+ 'os=mac&architecture=x64&image_type=jdk&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
51+ ] ,
52+ [
53+ { version : '11' , architecture : 'x86' , packageType : 'jdk' , checkLatest : false } ,
54+ AdoptImplementation . OpenJ9 ,
55+ 'os=mac&architecture=x86&image_type=jdk&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
56+ ] ,
57+ [
58+ { version : '11' , architecture : 'x64' , packageType : 'jre' , checkLatest : false } ,
59+ AdoptImplementation . OpenJ9 ,
60+ 'os=mac&architecture=x64&image_type=jre&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
61+ ] ,
62+ [
63+ { version : '11-ea' , architecture : 'x64' , packageType : 'jdk' , checkLatest : false } ,
64+ AdoptImplementation . OpenJ9 ,
65+ 'os=mac&architecture=x64&image_type=jdk&release_type=ea&jvm_impl=openj9&page_size=20&page=0'
4466 ]
4567 ] ) (
4668 'build correct url for %s' ,
47- async ( installerOptions : JavaInstallerOptions , expectedParameters ) => {
48- const distribution = new AdoptDistribution ( installerOptions ) ;
69+ async (
70+ installerOptions : JavaInstallerOptions ,
71+ impl : AdoptImplementation ,
72+ expectedParameters
73+ ) => {
74+ const distribution = new AdoptDistribution ( installerOptions , impl ) ;
4975 const baseUrl = 'https://api.adoptopenjdk.net/v3/assets/version/%5B1.0,100.0%5D' ;
50- const expectedUrl = `${ baseUrl } ?project=jdk&vendor=adoptopenjdk&heap_size=normal&jvm_impl=hotspot& sort_method=DEFAULT&sort_order=DESC&${ expectedParameters } ` ;
76+ const expectedUrl = `${ baseUrl } ?project=jdk&vendor=adoptopenjdk&heap_size=normal&sort_method=DEFAULT&sort_order=DESC&${ expectedParameters } ` ;
5177 distribution [ 'getPlatformOption' ] = ( ) => 'mac' ;
5278
5379 await distribution [ 'getAvailableVersions' ] ( ) ;
@@ -76,16 +102,32 @@ describe('getAvailableVersions', () => {
76102 result : [ ]
77103 } ) ;
78104
79- const distribution = new AdoptDistribution ( {
80- version : '11' ,
81- architecture : 'x64' ,
82- packageType : 'jdk' ,
83- checkLatest : false
84- } ) ;
105+ const distribution = new AdoptDistribution (
106+ { version : '11' , architecture : 'x64' , packageType : 'jdk' , checkLatest : false } ,
107+ AdoptImplementation . Hotspot
108+ ) ;
85109 const availableVersions = await distribution [ 'getAvailableVersions' ] ( ) ;
86110 expect ( availableVersions ) . not . toBeNull ( ) ;
87111 expect ( availableVersions . length ) . toBe ( manifestData . length * 2 ) ;
88112 } ) ;
113+
114+ it . each ( [
115+ [ AdoptImplementation . Hotspot , 'jdk' , 'Java_Adopt_jdk' ] ,
116+ [ AdoptImplementation . Hotspot , 'jre' , 'Java_Adopt_jre' ] ,
117+ [ AdoptImplementation . OpenJ9 , 'jdk' , 'Java_Adopt-OpenJ9_jdk' ] ,
118+ [ AdoptImplementation . OpenJ9 , 'jre' , 'Java_Adopt-OpenJ9_jre' ]
119+ ] ) (
120+ 'find right toolchain folder' ,
121+ ( impl : AdoptImplementation , packageType : string , expected : string ) => {
122+ const distribution = new AdoptDistribution (
123+ { version : '11' , architecture : 'x64' , packageType : packageType , checkLatest : false } ,
124+ impl
125+ ) ;
126+
127+ // @ts -ignore - because it is protected
128+ expect ( distribution . toolcacheFolderName ) . toBe ( expected ) ;
129+ }
130+ ) ;
89131} ) ;
90132
91133describe ( 'findPackageForDownload' , ( ) => {
@@ -102,50 +144,42 @@ describe('findPackageForDownload', () => {
102144 [ '15.0.1+9' , '15.0.1+9' ] ,
103145 [ '15.0.1+9.1' , '15.0.1+9.1' ]
104146 ] ) ( 'version is resolved correctly %s -> %s' , async ( input , expected ) => {
105- const distribution = new AdoptDistribution ( {
106- version : '11' ,
107- architecture : 'x64' ,
108- packageType : 'jdk' ,
109- checkLatest : false
110- } ) ;
147+ const distribution = new AdoptDistribution (
148+ { version : '11' , architecture : 'x64' , packageType : 'jdk' , checkLatest : false } ,
149+ AdoptImplementation . Hotspot
150+ ) ;
111151 distribution [ 'getAvailableVersions' ] = async ( ) => manifestData ;
112152 const resolvedVersion = await distribution [ 'findPackageForDownload' ] ( input ) ;
113153 expect ( resolvedVersion . version ) . toBe ( expected ) ;
114154 } ) ;
115155
116156 it ( 'version is found but binaries list is empty' , async ( ) => {
117- const distribution = new AdoptDistribution ( {
118- version : '11' ,
119- architecture : 'x64' ,
120- packageType : 'jdk' ,
121- checkLatest : false
122- } ) ;
157+ const distribution = new AdoptDistribution (
158+ { version : '11' , architecture : 'x64' , packageType : 'jdk' , checkLatest : false } ,
159+ AdoptImplementation . Hotspot
160+ ) ;
123161 distribution [ 'getAvailableVersions' ] = async ( ) => manifestData ;
124162 await expect ( distribution [ 'findPackageForDownload' ] ( '9.0.8' ) ) . rejects . toThrowError (
125163 / C o u l d n o t f i n d s a t i s f i e d v e r s i o n f o r S e m V e r * /
126164 ) ;
127165 } ) ;
128166
129167 it ( 'version is not found' , async ( ) => {
130- const distribution = new AdoptDistribution ( {
131- version : '11' ,
132- architecture : 'x64' ,
133- packageType : 'jdk' ,
134- checkLatest : false
135- } ) ;
168+ const distribution = new AdoptDistribution (
169+ { version : '11' , architecture : 'x64' , packageType : 'jdk' , checkLatest : false } ,
170+ AdoptImplementation . Hotspot
171+ ) ;
136172 distribution [ 'getAvailableVersions' ] = async ( ) => manifestData ;
137173 await expect ( distribution [ 'findPackageForDownload' ] ( '7.x' ) ) . rejects . toThrowError (
138174 / C o u l d n o t f i n d s a t i s f i e d v e r s i o n f o r S e m V e r * /
139175 ) ;
140176 } ) ;
141177
142178 it ( 'version list is empty' , async ( ) => {
143- const distribution = new AdoptDistribution ( {
144- version : '11' ,
145- architecture : 'x64' ,
146- packageType : 'jdk' ,
147- checkLatest : false
148- } ) ;
179+ const distribution = new AdoptDistribution (
180+ { version : '11' , architecture : 'x64' , packageType : 'jdk' , checkLatest : false } ,
181+ AdoptImplementation . Hotspot
182+ ) ;
149183 distribution [ 'getAvailableVersions' ] = async ( ) => [ ] ;
150184 await expect ( distribution [ 'findPackageForDownload' ] ( '11' ) ) . rejects . toThrowError (
151185 / C o u l d n o t f i n d s a t i s f i e d v e r s i o n f o r S e m V e r * /
0 commit comments