Skip to content

Commit

Permalink
完善测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanwu committed Apr 8, 2024
1 parent 75c00be commit 9cd85d1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ public Builder certificatesFromPath(String... certificatePaths) {
return this;
}

public Builder publicKey(String publicKey) {
this.publicKey = PemUtil.loadPublicKeyFromString(publicKey);
return this;
}

public Builder publicKey(PublicKey publicKey) {
this.publicKey = publicKey;
return this;
}

public Builder publicFromPath(String publicKeyPath) {
this.publicKey = PemUtil.loadPublicKeyFromPath(publicKeyPath);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import static com.wechat.pay.java.core.model.TestConfig.API_V3_KEY;
import static com.wechat.pay.java.core.model.TestConfig.WECHAT_PAY_CERTIFICATE;
import static com.wechat.pay.java.core.model.TestConfig.WECHAT_PAY_CERTIFICATE_PATH;
import static com.wechat.pay.java.core.model.TestConfig.WECHAT_PAY_CERTIFICATE_SERIAL_NUMBER;
import static com.wechat.pay.java.core.model.TestConfig.WECHAT_PAY_CERTIFICATE_STRING;
import static com.wechat.pay.java.core.model.TestConfig.WECHAT_PAY_PUBLIC_KEY;
import static com.wechat.pay.java.core.model.TestConfig.WECHAT_PAY_PUBLIC_KEY_PATH;
import static com.wechat.pay.java.core.model.TestConfig.WECHAT_PAY_PUBLIC_KEY_STRING;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

Expand Down Expand Up @@ -39,15 +43,33 @@ void testBuildConfigFromStr() {

static Stream<Builder> BuilderProvider() {
return Stream.of(
// from string
// certificates from string
new RSANotificationConfig.Builder()
.apiV3Key(API_V3_KEY)
.certificates(WECHAT_PAY_CERTIFICATE),

// form path
// certificates form path
new RSANotificationConfig.Builder()
.apiV3Key(API_V3_KEY)
.certificatesFromPath(WECHAT_PAY_CERTIFICATE_PATH));
.certificatesFromPath(WECHAT_PAY_CERTIFICATE_PATH),

// publickey form string
new RSANotificationConfig.Builder()
.apiV3Key(API_V3_KEY)
.publicKey(WECHAT_PAY_PUBLIC_KEY_STRING)
.publicKeyId(WECHAT_PAY_CERTIFICATE_SERIAL_NUMBER),

// publickey form path
new RSANotificationConfig.Builder()
.apiV3Key(API_V3_KEY)
.publicFromPath(WECHAT_PAY_PUBLIC_KEY_PATH)
.publicKeyId(WECHAT_PAY_CERTIFICATE_SERIAL_NUMBER),

// publickey
new RSANotificationConfig.Builder()
.apiV3Key(API_V3_KEY)
.publicKey(WECHAT_PAY_PUBLIC_KEY)
.publicKeyId(WECHAT_PAY_CERTIFICATE_SERIAL_NUMBER));
}

@Test
Expand Down

0 comments on commit 9cd85d1

Please sign in to comment.