From 802613ffffe7512db944f561219373909d5e6c45 Mon Sep 17 00:00:00 2001 From: chenchuchuan <13554600537@163.com> Date: Fri, 6 Nov 2026 15:05:16 +0800 Subject: [PATCH] =?UTF-8?q?test(lingxing):=20=E6=96=B0=E5=A2=9E=20listing?= =?UTF-8?q?=20=E8=81=94=E8=B0=83=E6=8E=A2=E9=92=88=EF=BC=8C=E5=87=AD?= =?UTF-8?q?=E6=8D=AE=E6=94=B9=E4=B8=BA=E7=B3=BB=E7=BB=9F=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E4=BC=A0=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ListingSmokeProbeTest:从 ChannelSdk 门面逐平台拉一页 listing, 打印统一模型关键字段并用样本回查平台 SKU / 本地 SKU - ListingParamProbeTest:核对 Target 时间窗上限、Temu 窗口边界等参数形态 - SearchFieldProbeTest / ShopListProbeTest:去掉硬编码的真实凭据, 改从 -Dlingxing.probe.appKey / -Dlingxing.probe.appSecret 读取; 未提供时 assumeTrue 跳过,避免本地与 CI 默认打真机 - SearchFieldProbeTest 的 TARGET_STORE_ID 置空(store_ids 非必填)、 样本为空不再断言失败、单个编码报错不中断整轮扫描 所有探针仍默认跳过且只做查询。 Co-Authored-By: Claude --- .../lingxing/probe/ListingParamProbeTest.java | 165 ++++++++++++++++ .../lingxing/probe/ListingSmokeProbeTest.java | 217 +++++++++++++++++++++ .../lingxing/probe/SearchFieldProbeTest.java | 39 +++- .../lingxing/probe/ShopListProbeTest.java | 15 +- 4 files changed, 420 insertions(+), 16 deletions(-) create mode 100644 lingxing/src/test/java/common/ecommerce/lingxing/probe/ListingParamProbeTest.java create mode 100644 lingxing/src/test/java/common/ecommerce/lingxing/probe/ListingSmokeProbeTest.java diff --git a/lingxing/src/test/java/common/ecommerce/lingxing/probe/ListingParamProbeTest.java b/lingxing/src/test/java/common/ecommerce/lingxing/probe/ListingParamProbeTest.java new file mode 100644 index 0000000..1b2ec66 --- /dev/null +++ b/lingxing/src/test/java/common/ecommerce/lingxing/probe/ListingParamProbeTest.java @@ -0,0 +1,165 @@ +package common.ecommerce.lingxing.probe; + +import common.ecommerce.http.HttpRequest; +import common.ecommerce.http.HttpResponse; +import common.ecommerce.http.HttpTransport; +import common.ecommerce.http.JacksonJsonCodec; +import common.ecommerce.http.OkHttpTransport; +import common.ecommerce.lingxing.LingxingApi; +import common.ecommerce.lingxing.LingxingConstants; +import common.ecommerce.lingxing.auth.LingxingTokenClient; +import common.ecommerce.lingxing.http.LingxingEnvelope; +import common.ecommerce.lingxing.http.LingxingRateLimiter; +import common.ecommerce.lingxing.http.LingxingRequestFactory; +import common.ecommerce.lingxing.platform.LingxingCall; +import common.ecommerce.model.ChannelProvider; +import common.ecommerce.model.Platform; +import common.ecommerce.model.account.AccountKey; +import common.ecommerce.model.account.ChannelAccount; +import common.ecommerce.sdk.ChannelConnection; +import common.ecommerce.sdk.ChannelContext; +import common.ecommerce.spi.AccessToken; +import common.ecommerce.spi.ChannelSecret; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfSystemProperty; + +import java.time.Clock; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * 只读探针(收尾第三轮):Target 时间窗上限与单边窗口。 + * + *

默认跳过;用 {@code -Dlingxing.probe=true} 显式开启。只做查询。

+ */ +@EnabledIfSystemProperty(named = "lingxing.probe", matches = "true") +class ListingParamProbeTest { + + // 真实凭据不入库:本地跑探针时用 -Dlingxing.probe.appKey=... -Dlingxing.probe.appSecret=... + private static final String APP_KEY = System.getProperty("lingxing.probe.appKey", ""); + private static final String APP_SECRET = System.getProperty("lingxing.probe.appSecret", ""); + private static final String BASE_URL = LingxingConstants.PRODUCTION_BASE_URL; + + private static final JacksonJsonCodec JSON = new JacksonJsonCodec(); + private final HttpTransport transport = new OkHttpTransport("common-ecommerce-param-probe"); + + private static final String TARGET_STORE = "110593321260223488"; + private static final String TEMU_STORE = "110544498784182784"; + + @Test + void targetWindowLimits() { + requireCredentials(); + LingxingCall call = call(Platform.TARGET, 0, TARGET_STORE); + System.out.println("\n===== TARGET 时间窗上限 ====="); + for (int days : new int[]{30, 31, 60, 90, 180, 365}) { + Map body = base(); + body.put("listing_time_field", 2); + body.put("listing_start_time", minusDays(days)); + body.put("listing_end_time", "2026-11-06"); + probe(call, LingxingApi.LISTING_SHOPIFY, days + " 天", body); + } + System.out.println("\n===== TARGET 单边窗口(field=2)====="); + Map startOnly = base(); + startOnly.put("listing_time_field", 2); + startOnly.put("listing_start_time", "2026-10-01"); + probe(call, LingxingApi.LISTING_SHOPIFY, "只 start", startOnly); + + Map endOnly = base(); + endOnly.put("listing_time_field", 2); + endOnly.put("listing_end_time", "2026-11-06"); + probe(call, LingxingApi.LISTING_SHOPIFY, "只 end", endOnly); + + System.out.println("\n===== TARGET time_field 取值 ====="); + for (int field : new int[]{1, 2, 3}) { + Map body = base(); + body.put("listing_time_field", field); + body.put("listing_start_time", "2021-01-01"); + body.put("listing_end_time", "2023-12-31"); + probe(call, LingxingApi.LISTING_SHOPIFY, "field=" + field + " 2021-2023", body); + } + } + + @Test + void temuWindowBoundary() { + requireCredentials(); + LingxingCall call = call(Platform.TEMU, 10024, TEMU_STORE); + System.out.println("\n===== TEMU 窗口边界(数据时间未知,只看是否报错)====="); + for (int days : new int[]{1, 7, 30}) { + Map body = new LinkedHashMap(); + body.put("offset", 0); + body.put("length", 3); + body.put("useCursor", Boolean.FALSE); + body.put("storeIds", Collections.singletonList(TEMU_STORE)); + body.put("updateStartTime", minusDays(days) + " 00:00:00"); + body.put("updateEndTime", "2026-11-06 00:00:00"); + probe(call, LingxingApi.LISTING_TEMU, days + " 天", body); + } + } + + // ---------------------------------------------------------------- 工具 + + private static Map base() { + Map body = new LinkedHashMap(); + body.put("offset", 0); + body.put("length", 10); + body.put("store_ids", Collections.singletonList(TARGET_STORE)); + return body; + } + + private static String minusDays(int days) { + return java.time.LocalDate.parse("2026-11-06").minusDays(days).toString(); + } + + /** 没有真实凭据时跳过,避免本地/CI 默认跑真机。 */ + private static void requireCredentials() { + org.junit.jupiter.api.Assumptions.assumeTrue( + !APP_KEY.trim().isEmpty() && !APP_SECRET.trim().isEmpty(), + "未提供 -Dlingxing.probe.appKey / -Dlingxing.probe.appSecret,跳过探针"); + } + + private void probe(LingxingCall call, LingxingApi api, String label, Map body) { + try { + HttpRequest req = call.signed(api, body, "probe.param"); + HttpResponse resp = call.execute(req); + LingxingEnvelope env = call.envelope(resp, "probe.param"); + JsonNode root = JSON.mapper().readTree(env.body()); + JsonNode data = root == null ? null : root.get("data"); + int items = 0; + if (data != null) { + items = data.isArray() ? data.size() : data.path("list").size(); + } + System.out.println(" [" + label + "] items=" + items); + } catch (JsonProcessingException e) { + System.out.println(" [" + label + "] 解析失败"); + } catch (RuntimeException e) { + System.out.println(" [" + label + "] 失败: " + shortMsg(e)); + } + } + + private static String shortMsg(RuntimeException e) { + String msg = e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage(); + return msg.length() <= 150 ? msg : msg.substring(0, 150); + } + + private LingxingCall call(Platform platform, int code, String storeId) { + ChannelAccount account = ChannelAccount.builder() + .key(AccountKey.of(ChannelProvider.LINGXING, platform, "oms-probe")) + .externalStoreId(storeId == null || storeId.isEmpty() ? "probe" : storeId) + .platformCode(code == 0 ? null : code) + .credentialRef("probe") + .marketplaceZone("America/Los_Angeles") + .currency("USD") + .build(); + Clock clock = Clock.systemUTC(); + ChannelSecret secret = ChannelSecret.builder().appKey(APP_KEY).appSecret(APP_SECRET).build(); + ChannelConnection conn = ChannelConnection.of(BASE_URL, secret); + ChannelContext ctx = ChannelContext.of(account, conn, "probe-" + System.currentTimeMillis(), clock); + AccessToken token = new LingxingTokenClient(transport, JSON, clock) + .fetch(BASE_URL, APP_KEY, APP_SECRET); + return new LingxingCall(ctx, token, new LingxingRequestFactory(JSON, clock), + new LingxingRateLimiter(), JSON, transport); + } +} diff --git a/lingxing/src/test/java/common/ecommerce/lingxing/probe/ListingSmokeProbeTest.java b/lingxing/src/test/java/common/ecommerce/lingxing/probe/ListingSmokeProbeTest.java new file mode 100644 index 0000000..d2968a4 --- /dev/null +++ b/lingxing/src/test/java/common/ecommerce/lingxing/probe/ListingSmokeProbeTest.java @@ -0,0 +1,217 @@ +package common.ecommerce.lingxing.probe; + +import common.ecommerce.capability.AggregatorCapable.SubChannel; +import common.ecommerce.http.HttpRequest; +import common.ecommerce.http.HttpResponse; +import common.ecommerce.http.HttpTransport; +import common.ecommerce.http.JacksonJsonCodec; +import common.ecommerce.http.OkHttpTransport; +import common.ecommerce.lingxing.LingxingConstants; +import common.ecommerce.lingxing.adapter.LingxingAdapter; +import common.ecommerce.model.ChannelProvider; +import common.ecommerce.model.Platform; +import common.ecommerce.model.account.AccountKey; +import common.ecommerce.model.account.ChannelAccount; +import common.ecommerce.model.product.ProductListing; +import common.ecommerce.model.product.ProductQuery; +import common.ecommerce.model.product.ProductSearchField; +import common.ecommerce.model.support.Page; +import common.ecommerce.sdk.ChannelConnection; +import common.ecommerce.sdk.ChannelContext; +import common.ecommerce.sdk.ChannelSdk; +import common.ecommerce.spi.ChannelSecret; +import common.ecommerce.testkit.InMemoryAccounts; +import common.ecommerce.testkit.InMemoryLockProvider; +import common.ecommerce.testkit.InMemoryTokenStore; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfSystemProperty; + +import java.time.Clock; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; + +/** + * 只读冒烟:从 {@link ChannelSdk} 门面逐个平台拉一页 listing,核对出入参。 + * + *

默认跳过;用 {@code -Dlingxing.probe=true} 显式开启。

+ * + *

只做查询。会打印请求体(截断)与统一模型的关键字段, + * 便于对照接口文档核对分页、日期、SKU 搜索三项参数。

+ */ +@EnabledIfSystemProperty(named = "lingxing.probe", matches = "true") +class ListingSmokeProbeTest { + + // 真实凭据不入库:本地跑探针时用 -Dlingxing.probe.appKey=... -Dlingxing.probe.appSecret=... + private static final String APP_KEY = System.getProperty("lingxing.probe.appKey", ""); + private static final String APP_SECRET = System.getProperty("lingxing.probe.appSecret", ""); + private static final String BASE_URL = LingxingConstants.PRODUCTION_BASE_URL; + + private static final JacksonJsonCodec JSON = new JacksonJsonCodec(); + private final LoggingTransport transport = new LoggingTransport(new OkHttpTransport("common-ecommerce-listing-probe")); + private final InMemoryTokenStore tokens = new InMemoryTokenStore(); + + /** 平台 → 实测店铺 id,取自 ShopListProbeTest 的输出。 */ + private static final Object[][] TARGETS = { + {Platform.AMAZON_SC, 10001, "127524991355697152", "AMZ-TOY-US"}, + {Platform.AMAZON_VC, 10035, "134543850419473408", "AMZ-CL-US"}, + {Platform.WALMART_SC, 10008, "110528861382225920", "WMT-CYB-US"}, + {Platform.EBAY, 10003, "110627593325390848", "EBA-STE-US"}, + {Platform.TIKTOK, 10011, "110541661459314688", "TTK-STE"}, + {Platform.TEMU, 10024, "110544498784182784", "TEMU OFFICE DIRECT"}, + {Platform.SHEIN, 10028, "110541676737748480", "SHE-JCK-US"}, + {Platform.ALIEXPRESS, 0, "", "全部阿里店铺(接口不需要 store)"}, + // shopify/variantList 下真正有商品的是 SPF-BM(10002),Target DVS 是空店 + {Platform.TARGET, 0, "110593321260223488", "SPF-BM"}, + }; + + /** + * 列表页不传时间窗:部分平台的数据很久没更新(Temu 最近更新时间早于窗口), + * 传窄窗口会得到 0 条,看不出字段映射。时间窗参数另行核对,见 {@link ListingParamProbeTest}。 + */ + @Test + void pullOnePagePerPlatform() { + Assumptions.assumeTrue(!APP_KEY.trim().isEmpty() && !APP_SECRET.trim().isEmpty(), + "未提供 -Dlingxing.probe.appKey / -Dlingxing.probe.appSecret,跳过探针"); + ChannelSdk sdk = sdk(); + + for (Object[] row : TARGETS) { + Platform platform = (Platform) row[0]; + int code = (Integer) row[1]; + String storeId = (String) row[2]; + String label = (String) row[3]; + System.out.println("\n================ " + platform + " / " + label + " ================"); + + ChannelAccount account = account(platform, code, storeId); + AccountKey key = account.key(); + ChannelConnection conn = connection(); + + try { + sdk.capabilities(key); + Page page = sdk.products(key, conn).pull(ProductQuery.builder() + .pageSize(3) + .build()); + System.out.println("[result] items=" + page.size() + " nextCursor=" + page.nextCursor()); + for (ProductListing p : page.items()) { + System.out.println(" platformSku=" + p.platformSku() + + " localSku=" + localSkuOf(p) + + " listingId=" + p.listingId() + + " status=" + p.status() + + " title=" + shorten(p.title()) + + " listedAt=" + p.listedAt() + + " updatedAt=" + p.updatedAt()); + } + + // 用样本回查平台 SKU + 本地 SKU,核对 search 条件 + if (!page.items().isEmpty()) { + ProductListing sample = page.items().get(0); + probeSearch(sdk, key, conn, platform, ProductSearchField.PLATFORM_SKU, sample.platformSku()); + String localSku = localSkuOf(sample); + if (localSku != null && !localSku.isEmpty()) { + probeSearch(sdk, key, conn, platform, ProductSearchField.LOCAL_SKU, localSku); + } else { + System.out.println(" [search] 本地 SKU 为空,跳过 LOCAL_SKU 回查"); + } + } + } catch (RuntimeException e) { + System.out.println("[ERROR] " + e.getClass().getSimpleName() + ": " + e.getMessage()); + } + } + } + + private void probeSearch(ChannelSdk sdk, AccountKey key, ChannelConnection conn, + Platform platform, ProductSearchField field, String value) { + try { + Page got = sdk.products(key, conn).pull(ProductQuery.builder() + .searchField(field) + .searchValue(value) + .pageSize(3) + .build()); + System.out.println(" [search] " + field + "=" + value + " → items=" + got.size()); + } catch (RuntimeException e) { + String msg = e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage(); + System.out.println(" [search] " + field + "=" + value + " → 失败:" + shorten(msg)); + } + } + + /** 统一模型没有 localSku 字段,从 attributes 里取原始值。 */ + private static String localSkuOf(ProductListing p) { + Object v = p.attributes().get("local_sku"); + return v == null ? null : String.valueOf(v); + } + + private ChannelSdk sdk() { + ChannelAccount[] accounts = new ChannelAccount[TARGETS.length]; + InMemoryAccounts repo = new InMemoryAccounts(); + for (int i = 0; i < TARGETS.length; i++) { + Object[] row = TARGETS[i]; + accounts[i] = account((Platform) row[0], (Integer) row[1], (String) row[2]); + repo.put(accounts[i]); + } + LingxingAdapter adapter = new LingxingAdapter(transport, JSON, tokens, + new InMemoryLockProvider(), Clock.systemUTC()); + return ChannelSdk.builder() + .accountRepository(repo) + .clock(Clock.systemUTC()) + .register(adapter) + .build(); + } + + private static ChannelAccount account(Platform platform, int code, String storeId) { + return ChannelAccount.builder() + .key(AccountKey.of(ChannelProvider.LINGXING, platform, + "oms-" + platform.name().toLowerCase())) + .externalStoreId(storeId == null || storeId.trim().isEmpty() ? "probe" : storeId) + .platformCode(code == 0 ? null : code) + .credentialRef("probe") + .marketplaceZone("America/Los_Angeles") + .currency("USD") + .build(); + } + + private static ChannelConnection connection() { + return ChannelConnection.of(BASE_URL, ChannelSecret.builder() + .appKey(APP_KEY).appSecret(APP_SECRET).build()); + } + + private static String shorten(String s) { + if (s == null) { + return "null"; + } + return s.length() <= 40 ? s : s.substring(0, 40) + "…"; + } + + /** 打印请求/响应(截断),只读排查用。 */ + static final class LoggingTransport implements HttpTransport { + + private static final int MAX_BODY = 1200; + + private final HttpTransport delegate; + + LoggingTransport(HttpTransport delegate) { + this.delegate = delegate; + } + + @Override + public HttpResponse execute(HttpRequest request) { + System.out.println(" --> " + request.method() + " " + pathOf(request.url())); + System.out.println(" body " + truncate(request.body())); + HttpResponse response = delegate.execute(request); + System.out.println(" <-- " + response.statusCode() + " " + truncate(response.body())); + return response; + } + + private static String pathOf(String url) { + int i = url.indexOf('/', url.indexOf("://") + 3); + return i < 0 ? url : url.substring(i); + } + + private static String truncate(String body) { + if (body == null) { + return "null"; + } + return body.length() <= MAX_BODY ? body : body.substring(0, MAX_BODY) + "...(" + body.length() + " chars)"; + } + } +} diff --git a/lingxing/src/test/java/common/ecommerce/lingxing/probe/SearchFieldProbeTest.java b/lingxing/src/test/java/common/ecommerce/lingxing/probe/SearchFieldProbeTest.java index a9f1e79..956e52c 100644 --- a/lingxing/src/test/java/common/ecommerce/lingxing/probe/SearchFieldProbeTest.java +++ b/lingxing/src/test/java/common/ecommerce/lingxing/probe/SearchFieldProbeTest.java @@ -35,9 +35,11 @@ import java.util.Map; * *

只做查询,不创建、不修改任何数据。

* - *

用法:填好下面四个常量后运行

+ *

用法:通过系统属性提供凭据后运行(凭据不入库)

*
- * mvn -pl lingxing test -Dtest=SearchFieldProbeTest -DfailIfNoTests=false
+ * mvn -pl lingxing test -Dtest=SearchFieldProbeTest -DfailIfNoTests=false \
+ *     -Dlingxing.probe=true \
+ *     -Dlingxing.probe.appKey=你的appId -Dlingxing.probe.appSecret=你的appSecret
  * 
* *

输出会告诉你:对同一个 SKU 值,哪个 searchField 编码能命中; @@ -48,8 +50,9 @@ import java.util.Map; class SearchFieldProbeTest { // ==================== 填写这里 ==================== - private static final String APP_KEY = "ak_MWoHJz2tcIwKF"; - private static final String APP_SECRET = "YOUkd5efWJSK71jLvDyz+g=="; + // 真实凭据不入库:本地跑探针时用 -Dlingxing.probe.appKey=... -Dlingxing.probe.appSecret=... + private static final String APP_KEY = System.getProperty("lingxing.probe.appKey", ""); + private static final String APP_SECRET = System.getProperty("lingxing.probe.appSecret", ""); /** AliExpress 探针开关:该接口不需要店铺 id,只要 app 下有阿里商品就能查。 */ private static final boolean PROBE_ALIEXPRESS = true; @@ -58,7 +61,7 @@ class SearchFieldProbeTest { * Target 店铺的 storeId。可选——文档里 store_ids 不是必填项, * 不填就查该 app 下全部店铺的商品。 */ - private static final String TARGET_STORE_ID = "110593321260223488"; + private static final String TARGET_STORE_ID = ""; /** AliExpress 的领星 platform_code(待实测确认;该码不影响商品接口调用)。 */ private static final int ALIEXPRESS_PLATFORM_CODE = 0; @@ -117,15 +120,18 @@ class SearchFieldProbeTest { Map probe = new LinkedHashMap(); List> sample = queryShopify(call, probe, 2); if (sample.isEmpty()) { - throw new AssertionError("店铺没有商品,无法做样本;换个有商品的 store_id"); + System.out.println("[target] 样本为空,原始响应在 LoggingTransport 输出中;" + + "store_ids=" + (TARGET_STORE_ID.isEmpty() ? "未传" : TARGET_STORE_ID)); + return; } String sampleMsku = str(sample.get(0).get("msku")); String sampleSku = str(sample.get(0).get("local_sku")); System.out.println("[target] 样本 msku=" + sampleMsku + " local_sku=" + sampleSku); for (int field = 1; field <= 9; field++) { - int hitByMsku = countBySearch(call, field, sampleMsku, 10, true); - int hitBySku = countBySearch(call, field, sampleSku, 10, true); + // 平台可能对某些编码直接返回参数错误:单独接住,继续试下一个 + String hitByMsku = safeCount(call, field, sampleMsku, true); + String hitBySku = safeCount(call, field, sampleSku, true); System.out.println("[target] search_field=" + field + " 用msku查命中=" + hitByMsku + " 用local_sku查命中=" + hitBySku); @@ -187,6 +193,19 @@ class SearchFieldProbeTest { return queryShopify(call, body, length, null, null); } + /** 单个编码查询失败时返回错误摘要,不中断整轮探针。 */ + private String safeCount(LingxingCall call, int field, String value, boolean target) { + if (value == null || value.isEmpty()) { + return "样本为空"; + } + try { + return String.valueOf(countBySearch(call, field, value, 10, target)); + } catch (RuntimeException e) { + String msg = e.getMessage() == null ? e.getClass().getSimpleName() : e.getMessage(); + return "失败:" + msg; + } + } + private int countBySearch(LingxingCall call, int field, String value, int length, boolean shopify) { if (value == null || value.isEmpty()) { return -1; @@ -221,8 +240,8 @@ class SearchFieldProbeTest { // ---------------------------------------------------------------- 公共设施 private void requireConfigured() { - Assumptions.assumeTrue(!APP_KEY.startsWith("在这里填") && !APP_SECRET.startsWith("在这里填"), - "请先填写 APP_KEY / APP_SECRET"); + Assumptions.assumeTrue(!APP_KEY.trim().isEmpty() && !APP_SECRET.trim().isEmpty(), + "未提供 -Dlingxing.probe.appKey / -Dlingxing.probe.appSecret,跳过探针"); } private static void skipIfBlank(String value, String name) { diff --git a/lingxing/src/test/java/common/ecommerce/lingxing/probe/ShopListProbeTest.java b/lingxing/src/test/java/common/ecommerce/lingxing/probe/ShopListProbeTest.java index c94977a..def6211 100644 --- a/lingxing/src/test/java/common/ecommerce/lingxing/probe/ShopListProbeTest.java +++ b/lingxing/src/test/java/common/ecommerce/lingxing/probe/ShopListProbeTest.java @@ -41,9 +41,11 @@ import java.util.TreeMap; * *

只做查询,不创建、不修改数据。

* - *

用法:填好 APP_KEY / APP_SECRET,然后

+ *

用法:通过系统属性提供凭据后运行(凭据不入库),然后

*
- * mvn -pl lingxing test -Dtest=ShopListProbeTest -DfailIfNoTests=false
+ * mvn -pl lingxing test -Dtest=ShopListProbeTest -DfailIfNoTests=false \
+ *     -Dlingxing.probe=true \
+ *     -Dlingxing.probe.appKey=你的appId -Dlingxing.probe.appSecret=你的appSecret
  * 
* *

输出会按 platform_code 分组,形如:

@@ -60,8 +62,9 @@ import java.util.TreeMap; class ShopListProbeTest { // ==================== 填写这里 ==================== - private static final String APP_KEY = "ak_MWoHJz2tcIwKF"; - private static final String APP_SECRET = "YOUkd5efWJSK71jLvDyz+g=="; + // 真实凭据不入库:本地跑探针时用 -Dlingxing.probe.appKey=... -Dlingxing.probe.appSecret=... + private static final String APP_KEY = System.getProperty("lingxing.probe.appKey", ""); + private static final String APP_SECRET = System.getProperty("lingxing.probe.appSecret", ""); /** 可选:只查某个 platform_code 的店铺。留空查全部。 */ private static final Integer ONLY_PLATFORM_CODE = null; @@ -197,8 +200,8 @@ class ShopListProbeTest { // ---------------------------------------------------------------- 公共设施 private void requireConfigured() { - Assumptions.assumeTrue(!APP_KEY.startsWith("在这里填") && !APP_SECRET.startsWith("在这里填"), - "请先填写 APP_KEY / APP_SECRET"); + Assumptions.assumeTrue(!APP_KEY.trim().isEmpty() && !APP_SECRET.trim().isEmpty(), + "未提供 -Dlingxing.probe.appKey / -Dlingxing.probe.appSecret,跳过探针"); } private LingxingCall call(ChannelAccount account) {