File tree Expand file tree Collapse file tree 3 files changed +19
-13
lines changed
main/java/com/aspose/barcode/cloud
test/java/com/aspose/barcode/cloud/test Expand file tree Collapse file tree 3 files changed +19
-13
lines changed Original file line number Diff line number Diff line change 3232 TEST_CONFIGURATION_ACCESS_TOKEN : ${{ secrets.TEST_CONFIGURATION_ACCESS_TOKEN }}
3333 run : mvn test
3434
35- - name : Build the Docker image
36- run : docker build . --file Dockerfile
35+ # TODO: Move to pack.yml
36+ # - name: Build the Docker image
37+ # run: docker build . --file Dockerfile
Original file line number Diff line number Diff line change @@ -956,7 +956,8 @@ public void requestToken() throws ApiException {
956956
957957 Response response = httpClient .newCall (request ).execute ();
958958 if (response .code () != 200 ) {
959- throw new ApiException ("Error fetching token: " + response .message (), response .code ());
959+ throw new ApiException (
960+ "Error fetching token: " + response .message (), response .code ());
960961 }
961962 GetAccessTokenResult result =
962963 json .deserialize (response .body ().string (), GetAccessTokenResult .class );
Original file line number Diff line number Diff line change 22
33import com .aspose .barcode .cloud .Configuration ;
44
5- import java .io .File ;
65import java .io .IOException ;
76import java .nio .file .Path ;
87import java .nio .file .Paths ;
@@ -11,16 +10,21 @@ public class TestConfiguration {
1110 private static final Path ConfigFileName = Paths .get ("src" , "test" , "configuration.json" );
1211
1312 public static Configuration load () {
14- File maybeConfigFile = ConfigFileName .toFile ();
15- if (maybeConfigFile .exists ()) {
16- try {
17- return Configuration .loadFromFile (maybeConfigFile );
18- } catch (IOException ignored ) {
19- }
13+ String maybeToken = System .getenv ().get ("TEST_CONFIGURATION_ACCESS_TOKEN" );
14+
15+ // Prefer config from environment
16+ if (maybeToken != null && !maybeToken .isEmpty ()) {
17+ Configuration fromEnv = new Configuration ();
18+ fromEnv .AccessToken = maybeToken ;
19+ return fromEnv ;
2020 }
2121
22- Configuration fromEnv = new Configuration ();
23- fromEnv .AccessToken = System .getenv ().get ("TEST_CONFIGURATION_ACCESS_TOKEN" );
24- return fromEnv ;
22+ // And then try to load config from file
23+ try {
24+ return Configuration .loadFromFile (ConfigFileName .toFile ());
25+ } catch (IOException e ) {
26+ System .err .println ("ERROR: Cannot load config from file " + ConfigFileName );
27+ throw new RuntimeException (e );
28+ }
2529 }
2630}
You can’t perform that action at this time.
0 commit comments