diff --git a/sdk/storage/microsoft-azure-storage-blob/pom.xml b/sdk/storage/microsoft-azure-storage-blob/pom.xml index f3c8eebd6d669..bd3c878569ad8 100644 --- a/sdk/storage/microsoft-azure-storage-blob/pom.xml +++ b/sdk/storage/microsoft-azure-storage-blob/pom.xml @@ -73,22 +73,6 @@ test - - com.azure - azure-core-test - 1.23.0 - test - - - - com.azure - azure-storage-common - 12.24.2 - tests - test-jar - test - - org.spockframework spock-core diff --git a/sdk/storage/microsoft-azure-storage-blob/src/test/java/com/microsoft/azure/storage/APISpec.groovy b/sdk/storage/microsoft-azure-storage-blob/src/test/java/com/microsoft/azure/storage/APISpec.groovy index 413196192d11b..89c1f88de38a1 100644 --- a/sdk/storage/microsoft-azure-storage-blob/src/test/java/com/microsoft/azure/storage/APISpec.groovy +++ b/sdk/storage/microsoft-azure-storage-blob/src/test/java/com/microsoft/azure/storage/APISpec.groovy @@ -3,7 +3,6 @@ package com.microsoft.azure.storage -import com.azure.storage.common.test.shared.extensions.LiveOnly import com.microsoft.aad.adal4j.AuthenticationContext import com.microsoft.aad.adal4j.ClientCredential import com.microsoft.azure.storage.blob.* @@ -603,8 +602,8 @@ class APISpec extends Specification { StorageURL.createPipeline(new TokenCredentials(token))) } - def getTestMode(){ - String testMode = System.getenv("AZURE_TEST_MODE") + static def getTestMode(){ + def testMode = System.getenv("AZURE_TEST_MODE") if(testMode == null){ testMode = "PLAYBACK" } diff --git a/sdk/storage/microsoft-azure-storage-blob/src/test/java/com/microsoft/azure/storage/LiveOnly.java b/sdk/storage/microsoft-azure-storage-blob/src/test/java/com/microsoft/azure/storage/LiveOnly.java new file mode 100644 index 0000000000000..9e383596da445 --- /dev/null +++ b/sdk/storage/microsoft-azure-storage-blob/src/test/java/com/microsoft/azure/storage/LiveOnly.java @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.microsoft.azure.storage; + +import org.spockframework.runtime.extension.ExtensionAnnotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Inherited +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD}) +@ExtensionAnnotation(LiveOnlyExtension.class) +public @interface LiveOnly { +} diff --git a/sdk/storage/microsoft-azure-storage-blob/src/test/java/com/microsoft/azure/storage/LiveOnlyExtension.java b/sdk/storage/microsoft-azure-storage-blob/src/test/java/com/microsoft/azure/storage/LiveOnlyExtension.java new file mode 100644 index 0000000000000..f154d37940de7 --- /dev/null +++ b/sdk/storage/microsoft-azure-storage-blob/src/test/java/com/microsoft/azure/storage/LiveOnlyExtension.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.microsoft.azure.storage; + +import org.spockframework.runtime.extension.IAnnotationDrivenExtension; +import org.spockframework.runtime.model.FeatureInfo; +import org.spockframework.runtime.model.SpecInfo; + +public class LiveOnlyExtension implements IAnnotationDrivenExtension { + + @Override + public void visitFeatureAnnotation(LiveOnly annotation, FeatureInfo feature) { + String testMode = (String) APISpec.getTestMode(); + if (!"LIVE".equalsIgnoreCase(testMode)) { + feature.skip(String.format("Test ignored in %s mode", testMode)); + } + } + + @Override + public void visitSpecAnnotation(LiveOnly annotation, SpecInfo spec) { + String testMode = (String) APISpec.getTestMode(); + if (!"LIVE".equalsIgnoreCase(testMode)) { + spec.skip(String.format("Test ignored in %s mode", testMode)); + } + } +}