File tree 3 files changed +19
-13
lines changed
main/java/com/aspose/barcode/cloud
test/java/com/aspose/barcode/cloud/test
3 files changed +19
-13
lines changed Original file line number Diff line number Diff line change 32
32
TEST_CONFIGURATION_ACCESS_TOKEN : ${{ secrets.TEST_CONFIGURATION_ACCESS_TOKEN }}
33
33
run : mvn test
34
34
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 {
956
956
957
957
Response response = httpClient .newCall (request ).execute ();
958
958
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 ());
960
961
}
961
962
GetAccessTokenResult result =
962
963
json .deserialize (response .body ().string (), GetAccessTokenResult .class );
Original file line number Diff line number Diff line change 2
2
3
3
import com .aspose .barcode .cloud .Configuration ;
4
4
5
- import java .io .File ;
6
5
import java .io .IOException ;
7
6
import java .nio .file .Path ;
8
7
import java .nio .file .Paths ;
@@ -11,16 +10,21 @@ public class TestConfiguration {
11
10
private static final Path ConfigFileName = Paths .get ("src" , "test" , "configuration.json" );
12
11
13
12
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 ;
20
20
}
21
21
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
+ }
25
29
}
26
30
}
You can’t perform that action at this time.
0 commit comments