public ApiClient() { httpClient = new OkHttpClient(); verifyingSsl = true; json = new JSON(); // Set default User-Agent. setUserAgent("Swagger-Codegen/1.0-SNAPSHOT/java"); // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap<String, Authentication>(); authentications.put("BearerToken", new ApiKeyAuth("header", "authorization")); authentications.put("BasicAuth", new HttpBasicAuth()); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); }
public ApiClient() { httpClient = new OkHttpClient(); verifyingSsl = true; json = new JSON(); // Set default User-Agent. setUserAgent("Swagger-Codegen/1.0-SNAPSHOT/java"); // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap<String, Authentication>(); authentications.put("BearerToken", new ApiKeyAuth("header", "authorization")); authentications.put("BasicAuth", new HttpBasicAuth()); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); }
@Test public void testSerializeByteArray() { final JSON json = new JSON(); final String plainText = "string that contains '=' when encoded"; final String base64String = json.serialize(plainText.getBytes()); //serialize returns string surrounded by quotes: "\"[base64]\"" final String pureString = base64String.replaceAll("^\"|\"$", ""); final ByteString byteStr = ByteString.decodeBase64(pureString); //Check encoded to valid base64 assertNotNull(byteStr); //Check encoded string correctly final String decodedText = new String(byteStr.toByteArray()); assertThat(decodedText, is(plainText)); } }