-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
121 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,14 @@ | |
*/ | ||
package com.ctrip.framework.apollo.openapi.client; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import org.junit.Test; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import com.ctrip.framework.apollo.openapi.dto.OpenAppDTO; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ApolloOpenApiClientTest { | ||
|
||
|
@@ -32,11 +38,67 @@ public void testCreate() { | |
assertEquals(someToken, client.getToken()); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
@Test | ||
public void testCreateWithInvalidUrl() { | ||
String someInvalidUrl = "someInvalidUrl"; | ||
String someToken = "someToken"; | ||
|
||
ApolloOpenApiClient.newBuilder().withPortalUrl(someInvalidUrl).withToken(someToken).build(); | ||
assertThrows( | ||
IllegalArgumentException.class, | ||
() -> ApolloOpenApiClient.newBuilder().withPortalUrl(someInvalidUrl).withToken(someToken).build() | ||
); | ||
} | ||
|
||
@Test | ||
@Disabled("only for integration test") | ||
public void testCreateApp() { | ||
String someUrl = "http://localhost:8070"; | ||
// String someToken = "0627b87948c30517157e8b2a9565e473b5a97323a50128f584838ed10559d3fd"; | ||
String someToken = "9d0a241e9cb2300f302a875b1195340b2b6f56373cf5ca5d006a3f4e1a46b3ef"; | ||
|
||
ApolloOpenApiClient client = ApolloOpenApiClient.newBuilder() | ||
.withPortalUrl(someUrl) | ||
.withToken(someToken) | ||
.withReadTimeout(200 * 1000) | ||
.withConnectTimeout(200 * 1000) | ||
.build(); | ||
|
||
final String appId = "openapi-create-app"; | ||
OpenAppDTO openAppDTO = new OpenAppDTO(); | ||
openAppDTO.setName("openapi create app 测试名字"); | ||
openAppDTO.setAppId(appId); | ||
openAppDTO.setOwnerName("user-test-xxx1"); | ||
openAppDTO.setOwnerEmail("[email protected]"); | ||
openAppDTO.setOrgId("orgId1"); | ||
openAppDTO.setOrgName("orgName1"); | ||
// client.createApp(openAppDTO); | ||
|
||
List<OpenAppDTO> list = client.getAppsByIds(Collections.singletonList(appId)); | ||
} | ||
|
||
@Test | ||
@Disabled("only for integration test") | ||
public void testCreateAppWithEnv() { | ||
String someUrl = "http://localhost:8070"; | ||
String someToken = "9d0a241e9cb2300f302a875b1195340b2b6f56373cf5ca5d006a3f4e1a46b3ef"; | ||
|
||
ApolloOpenApiClient client = ApolloOpenApiClient.newBuilder() | ||
.withPortalUrl(someUrl) | ||
.withToken(someToken) | ||
.withReadTimeout(200 * 1000) | ||
.withConnectTimeout(200 * 1000) | ||
.build(); | ||
|
||
final String appId = "openapi-create-app-in-dev"; | ||
OpenAppDTO openAppDTO = new OpenAppDTO(); | ||
openAppDTO.setName("openapi create app 测试名字"); | ||
openAppDTO.setAppId(appId); | ||
openAppDTO.setOwnerName("user-test-xxx1"); | ||
openAppDTO.setOwnerEmail("[email protected]"); | ||
openAppDTO.setOrgId("orgId1"); | ||
openAppDTO.setOrgName("orgName1"); | ||
client.createApp("dev", openAppDTO); | ||
|
||
List<OpenAppDTO> list = client.getAppsByIds(Collections.singletonList(appId)); | ||
} | ||
} |