Skip to content

Commit 451a119

Browse files
author
Changjian Wang
committed
Enable Record/Playback test mode for Sample tests
- Delete 13 @disabled test files (replaced by Sample tests) - Modify Sample00-Sample16 to extend ContentUnderstandingClientTestBase - Add testResourceNamer for reproducible random IDs in PLAYBACK mode - Remove problematic sanitizers (AZSDK2003, AZSDK2030, AZSDK3423, AZSDK3430, AZSDK3493) - Configure maven-surefire-plugin to include Sample*.java - Use AZURE_CONTENT_UNDERSTANDING_ENDPOINT env var (matches .NET naming)
1 parent e2af7aa commit 451a119

33 files changed

+142
-1373
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"AssetsRepo":"Azure/azure-sdk-assets","AssetsRepoPrefixPath":"java","TagPrefix":"java/contentunderstanding/azure-ai-contentunderstanding","Tag":"java/contentunderstanding/azure-ai-contentunderstanding_48343b30b7"}
1+
{"AssetsRepo":"Azure/azure-sdk-assets","AssetsRepoPrefixPath":"java","TagPrefix":"java/contentunderstanding/azure-ai-contentunderstanding","Tag":"java/contentunderstanding/azure-ai-contentunderstanding_1930ab1fdb"}

sdk/contentunderstanding/azure-ai-contentunderstanding/pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,23 @@
7373
<scope>test</scope>
7474
</dependency>
7575
</dependencies>
76+
77+
<build>
78+
<plugins>
79+
<plugin>
80+
<groupId>org.apache.maven.plugins</groupId>
81+
<artifactId>maven-surefire-plugin</artifactId>
82+
<version>3.5.3</version> <!-- {x-version-update;org.apache.maven.plugins:maven-surefire-plugin;external_dependency} -->
83+
<configuration>
84+
<includes>
85+
<!-- Include standard test naming conventions -->
86+
<include>**/*Test.java</include>
87+
<include>**/*Tests.java</include>
88+
<!-- Include Sample files as tests (they extend ContentUnderstandingClientTestBase) -->
89+
<include>**/Sample*.java</include>
90+
</includes>
91+
</configuration>
92+
</plugin>
93+
</plugins>
94+
</build>
7695
</project>

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/AnalyzeFileTests.java

Lines changed: 0 additions & 28 deletions
This file was deleted.

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/AnalyzeURLTests.java

Lines changed: 0 additions & 45 deletions
This file was deleted.

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/ContentUnderstandingClientTestBase.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,20 @@
2121
class ContentUnderstandingClientTestBase extends TestProxyTestBase {
2222
protected ContentUnderstandingClient contentUnderstandingClient;
2323

24+
// Sanitizer IDs to remove:
25+
// - AZSDK2003, AZSDK2030: Replace Location/Operation-Location headers with "https://example.com"
26+
// which breaks LRO polling that relies on Operation-Location header URLs
27+
// - AZSDK3423: Replaces $..source field with "Sanitized", breaking field source validation
28+
// - AZSDK3430: Replaces $..id field with "Sanitized"
29+
// - AZSDK3493: Replaces $..name field with "Sanitized", breaking fieldSchema.name validation
30+
private static final String[] REMOVE_SANITIZER_ID
31+
= { "AZSDK2003", "AZSDK2030", "AZSDK3423", "AZSDK3430", "AZSDK3493" };
32+
2433
@Override
2534
protected void beforeTest() {
2635
ContentUnderstandingClientBuilder contentUnderstandingClientbuilder = new ContentUnderstandingClientBuilder()
27-
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint"))
36+
.endpoint(
37+
Configuration.getGlobalConfiguration().get("AZURE_CONTENT_UNDERSTANDING_ENDPOINT", "https://localhost"))
2838
.httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null)))
2939
.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC));
3040
if (getTestMode() == TestMode.PLAYBACK) {
@@ -37,5 +47,9 @@ protected void beforeTest() {
3747
}
3848
contentUnderstandingClient = contentUnderstandingClientbuilder.buildClient();
3949

50+
// Remove sanitizers that break LRO polling by replacing entire URLs
51+
if (getTestMode() != TestMode.LIVE) {
52+
interceptorManager.removeSanitizers(REMOVE_SANITIZER_ID);
53+
}
4054
}
4155
}

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/CopyAnalyzerTests.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/CreateOrReplaceAnalyzerTests.java

Lines changed: 0 additions & 63 deletions
This file was deleted.

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/DeleteAnalyzerResultTests.java

Lines changed: 0 additions & 18 deletions
This file was deleted.

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/DeleteAnalyzerTests.java

Lines changed: 0 additions & 18 deletions
This file was deleted.

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/GetAnalysisResultFileTests.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)