OSDN Git Service

refactor
[bytom/bytom-java-sdk.git] / java-sdk / src / test / java / io / bytom / TestUtils.java
1 package io.bytom;
2
3 import io.bytom.offline.common.Configuration;
4 import io.bytom.offline.exception.BytomException;
5 import io.bytom.http.Client;
6 import org.apache.log4j.Logger;
7
8 /**
9  * TestUtils provides a simplified api for testing.
10  */
11 public class TestUtils {
12
13     public static Logger logger = Logger.getLogger(TestUtils.class);
14
15     public static Client generateClient() throws BytomException {
16
17         String coreURL = Configuration.getValue("bytom.api.url");
18         String accessToken = Configuration.getValue("client.access.token");
19
20         if (coreURL == null || coreURL.isEmpty()) {
21             coreURL = "http://127.0.0.1:9888";
22         }
23
24         if (coreURL.endsWith("/")) {
25             //split the last char "/"
26             coreURL = coreURL.substring(0, coreURL.length()-1);
27         }
28
29         return new Client(coreURL, accessToken);
30     }
31 }