This commit is contained in:
kaibocai 2023-02-14 15:25:11 -06:00
Родитель 8eba45843f
Коммит 31867a61f7
2 изменённых файлов: 31 добавлений и 0 удалений

Просмотреть файл

@ -65,6 +65,12 @@ namespace Azure.Functions.Java.Tests.E2E
public async Task HttpTrigger_BindingName()
{
Assert.True(await Utilities.InvokeHttpTrigger("BindingName", "/testMessage", HttpStatusCode.OK, "testMessage"));
}
[Fact]
public async Task HttpTrigger_StaticBlockFailure()
{
Assert.True(await Utilities.InvokeHttpTrigger("StaticBlockFailure", "", HttpStatusCode.InternalServerError, ""));
}
}
}

Просмотреть файл

@ -0,0 +1,25 @@
package com.microsoft.azure.functions.endtoend;
import com.microsoft.azure.functions.*;
import com.microsoft.azure.functions.annotation.AuthorizationLevel;
import com.microsoft.azure.functions.annotation.FunctionName;
import com.microsoft.azure.functions.annotation.HttpTrigger;
import java.util.Optional;
public class StaticBlockFailure {
static {
Optional.empty().orElseThrow(() -> new RuntimeException("exception raised in static block"));
}
@FunctionName("StaticBlockFailure")
public HttpResponseMessage run(
@HttpTrigger(
name = "req",
methods = {HttpMethod.GET, HttpMethod.POST},
authLevel = AuthorizationLevel.ANONYMOUS)
HttpRequestMessage<Optional<String>> request,
final ExecutionContext context) {
context.getLogger().info("Java HTTP trigger processed a request of function StaticBlockFailure.");
return request.createResponseBuilder(HttpStatus.OK).body("Hello, e2e test").build();
}
}