Skip to content

Commit 646e073

Browse files
committed
fix emulated tests
1 parent cc13be7 commit 646e073

File tree

7 files changed

+88
-42
lines changed

7 files changed

+88
-42
lines changed

emulatedtests/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<properties>
2222
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2323
<java.version>1.8</java.version>
24-
<azure.functions.maven.plugin.version>1.18.0</azure.functions.maven.plugin.version>
24+
<azure.functions.maven.plugin.version>1.37.1</azure.functions.maven.plugin.version>
2525
<azure.functions.java.library.version>3.1.0</azure.functions.java.library.version>
2626
<azure.functions.java.library.sql.version>2.1.0</azure.functions.java.library.sql.version>
2727
<durabletask.azure.functions>1.0.0-beta.1</durabletask.azure.functions>

emulatedtests/src/main/java/com/microsoft/azure/functions/endtoend/BlobTriggerTests.java

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.microsoft.azure.functions.endtoend;
22

3+
import com.azure.storage.blob.BlobClientBuilder;
34
import com.microsoft.azure.functions.annotation.*;
45

6+
import java.io.ByteArrayInputStream;
57
import java.io.ByteArrayOutputStream;
6-
import java.util.List;
7-
import java.util.Optional;
88

99
import com.microsoft.azure.functions.*;
1010

@@ -69,7 +69,6 @@ public void BlobTriggerStringTest(
6969
public void BlobTriggerToBlobTest_BlobClient(
7070
@BlobTrigger(name = "triggerBlob", path = "test-triggerinput-blobclient/{name}", dataType = "binary") BlobClient triggerBlobClient,
7171
@BindingName("name") String fileName,
72-
@BlobOutput(name = "outputBlob", path = "test-output-java-new/{name}", dataType = "binary") OutputBinding<byte[]> outputBlob,
7372
final ExecutionContext context
7473
) {
7574
context.getLogger().info("BlobTriggerUsingBlobClient triggered for blob: " + fileName);
@@ -78,9 +77,21 @@ public void BlobTriggerToBlobTest_BlobClient(
7877
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
7978
triggerBlobClient.downloadStream(outputStream);
8079

81-
// Set the downloaded content as output
82-
outputBlob.setValue(outputStream.toByteArray());
83-
context.getLogger().info("Blob content copied successfully from trigger blob to output blob.");
80+
// Get connection string from environment variable
81+
String connectionString = System.getenv("AzureWebJobsStorage");
82+
83+
// Define the BlobClient for the destination blob
84+
BlobClient outputBlobClient = new BlobClientBuilder()
85+
.connectionString(connectionString)
86+
.containerName("test-output-java-new")
87+
.blobName(fileName)
88+
.buildClient();
89+
90+
// Upload the blob content to the destination container
91+
byte[] data = outputStream.toByteArray();
92+
outputBlobClient.upload(new ByteArrayInputStream(data), data.length, true);
93+
94+
context.getLogger().info("Uploaded blob " + fileName + " to container test-output-java-new");
8495
}
8596

8697
/**
@@ -91,7 +102,6 @@ public void BlobTriggerToBlobTest_BlobClient(
91102
public void BlobTriggerToBlobTest_BlobContainerClient(
92103
@BlobTrigger(name = "triggerBlob", path = "test-triggerinput-blobcontclient/{name}", dataType = "binary") BlobContainerClient triggerBlobContainerClient,
93104
@BindingName("name") String fileName,
94-
@BlobOutput(name = "outputBlob", path = "test-output-java-new/{name}", dataType = "binary") OutputBinding<byte[]> outputBlob,
95105
final ExecutionContext context
96106
) {
97107
context.getLogger().info("BlobTriggerUsingBlobContainerClient triggered for blob: " + fileName);
@@ -101,9 +111,21 @@ public void BlobTriggerToBlobTest_BlobContainerClient(
101111
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
102112
triggerBlobClient.downloadStream(outputStream);
103113

104-
// Set the downloaded content as output
105-
outputBlob.setValue(outputStream.toByteArray());
106-
context.getLogger().info("Blob content copied successfully from trigger blob to output blob.");
114+
// Get connection string from environment variable
115+
String connectionString = System.getenv("AzureWebJobsStorage");
116+
117+
// Define the BlobClient for the destination blob
118+
BlobClient outputBlobClient = new BlobClientBuilder()
119+
.connectionString(connectionString)
120+
.containerName("test-output-java-new")
121+
.blobName(fileName)
122+
.buildClient();
123+
124+
// Upload the blob content to the destination container
125+
byte[] data = outputStream.toByteArray();
126+
outputBlobClient.upload(new ByteArrayInputStream(data), data.length, true);
127+
128+
context.getLogger().info("Uploaded blob " + fileName + " to container test-output-java-new");
107129
}
108130

109131
public static class TestBlobData {

eng/ci/templates/jobs/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
java -version
1616
displayName: 'Check default java version'
1717
- pwsh: |
18-
.\installJavaAdditions.ps1
18+
.\installLibsLocally.ps1
1919
displayName: 'Install java-additions locally'
2020
- pwsh: |
2121
mvn clean package

eng/ci/templates/jobs/run-emulated-tests-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
java -version
5959
displayName: 'Check default java version'
6060
- pwsh: |
61-
.\installJavaAdditions.ps1
61+
.\installLibsLocally.ps1
6262
displayName: 'Install java-additions locally'
6363
- pwsh: |
6464
if ("$(isTag)"){

eng/ci/templates/jobs/run-emulated-tests-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
java -version
4949
displayName: 'Check default java version'
5050
- pwsh: |
51-
.\installJavaAdditions.ps1
51+
.\installLibsLocally.ps1
5252
displayName: 'Install java-additions locally'
5353
- pwsh: |
5454
if ("$(isTag)"){

installJavaAdditions.ps1

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

installLibsLocally.ps1

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Variables for first repository
2+
$repoUrl1 = 'https://github.com/ahmedmuhsin/azure-functions-java-additions.git'
3+
$branchName1 = 'sdk-types'
4+
$repoName1 = 'azure-functions-java-additions'
5+
6+
# Clone the first repository
7+
git clone $repoUrl1
8+
9+
# Change directory to the cloned repository
10+
Set-Location $repoName1
11+
12+
# Checkout the desired branch
13+
git checkout $branchName1
14+
15+
# Detect OS and execute build accordingly
16+
if ($IsWindows) {
17+
# Run the batch script (mvnBuild.bat)
18+
& ".\mvnBuild.bat"
19+
} else {
20+
# Extract and explicitly invoke the mvn command from mvnBuild.bat
21+
$mvnCommand = Get-Content "./mvnBuild.bat" | Where-Object { $_ -match '^mvn\s+' }
22+
if ($null -ne $mvnCommand) {
23+
# Execute the extracted mvn command explicitly as a single line
24+
bash -c "$mvnCommand"
25+
} else {
26+
Write-Error "No mvn command found in mvnBuild.bat."
27+
}
28+
}
29+
30+
# Return to the parent directory before working on the second repository
31+
Set-Location ..
32+
33+
# Variables for second repository
34+
$repoUrl2 = 'https://github.com/ahmedmuhsin/azure-maven-plugins.git'
35+
$branchName2 = 'sdk-types'
36+
$repoName2 = 'azure-maven-plugins'
37+
38+
# Clone the second repository
39+
git clone $repoUrl2
40+
41+
# Change directory to the cloned repository
42+
Set-Location $repoName2
43+
44+
# Checkout the desired branch
45+
git checkout $branchName2
46+
47+
# Run Maven command to build/install, skipping tests and javadoc
48+
if ($IsWindows) {
49+
& "mvn" "clean" "install" "-DskipTests" "-Dmaven.javadoc.skip=true"
50+
} else {
51+
bash -c "mvn clean install -DskipTests -Dmaven.javadoc.skip=true"
52+
}

0 commit comments

Comments
 (0)