| File: JavaEmptyAppHostTemplateTests.cs | Web Access |
| Project: src\tests\Aspire.Cli.EndToEnd.Tests\Aspire.Cli.EndToEnd.Tests.csproj (Aspire.Cli.EndToEnd.Tests) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Aspire.Cli.EndToEnd.Tests.Helpers; using Hex1b.Automation; using Xunit; namespace Aspire.Cli.EndToEnd.Tests; /// <summary> /// End-to-end tests for the Java empty AppHost template (aspire-java-empty). /// Validates that aspire new creates a working Java AppHost project /// and that aspire start runs it successfully. /// </summary> public sealed class JavaEmptyAppHostTemplateTests(ITestOutputHelper output) { [Fact] [CaptureWorkspaceOnFailure] public async Task CreateAndRunJavaEmptyAppHostProject() { var repoRoot = CliE2ETestHelpers.GetRepoRoot(); var strategy = CliInstallStrategy.Detect(output.WriteLine); var workspace = TemporaryWorkspace.Create(output); using var terminal = CliE2ETestHelpers.CreateDockerTestTerminal(repoRoot, strategy, output, variant: CliE2ETestHelpers.DockerfileVariant.PolyglotJava, mountDockerSocket: true, workspace: workspace); var counter = new SequenceCounter(); var auto = new Hex1bTerminalAutomator(terminal, defaultTimeout: TimeSpan.FromSeconds(500)); await using var terminalRun = CliE2ETestHelpers.StartRun(terminal, workspace, auto, counter, output, TestContext.Current.CancellationToken); await auto.PrepareDockerEnvironmentAsync(counter, workspace); await auto.InstallAspireCliAsync(strategy, counter); await auto.EnableExperimentalJavaSupportAsync(counter); await auto.AspireNewAsync("JavaEmptyApp", counter, template: AspireTemplate.JavaEmptyAppHost); GitIgnoreAssertions.AssertContainsEntry( Path.Combine(workspace.WorkspaceRoot.FullName, "JavaEmptyApp"), ".aspire/"); await auto.TypeAsync("cd JavaEmptyApp"); await auto.EnterAsync(); await auto.WaitForSuccessPromptAsync(counter); await auto.AspireStartAsync(counter); await auto.AspireStopAsync(counter); } }