255 references to Path
Aspire.Hosting.Java.Tests (255)
AddJavaAppPublishTests.cs (76)
113builder.AddJavaApp("worker", tempDir.Path, "target/worker.jar") 149var app = builder.AddJavaApp("api", tempDir.Path) 199WritePom(appDirectory.Path, javaVersion: "21"); 202var app = builder.AddJavaApp("api", appDirectory.Path) 298var app = builder.AddJavaApp("api", appDirectory.Path, jarPath); 522File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), $""" 533Assert.Equal(expected, JavaVersionDetector.Detect(appDirectory.Path)); 543File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 563Assert.Equal("17", JavaVersionDetector.Detect(appDirectory.Path)); 571File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 586Assert.Equal("25", JavaVersionDetector.Detect(appDirectory.Path)); 594File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 610Assert.Equal("25", JavaVersionDetector.Detect(appDirectory.Path)); 618File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 638Assert.Equal("25", JavaVersionDetector.Detect(appDirectory.Path)); 653WriteProfilePom(appDirectory.Path); 655Assert.Equal("25", JavaVersionDetector.Detect(appDirectory.Path, JavaBuildTool.Maven, buildArgs)); 665WriteProfilePom(appDirectory.Path); 667Assert.Equal("21", JavaVersionDetector.Detect(appDirectory.Path, JavaBuildTool.Maven, buildArgs)); 679WriteProfilePom(appDirectory.Path); 681Assert.Equal("17", JavaVersionDetector.Detect(appDirectory.Path, JavaBuildTool.Maven, buildArgs)); 688WriteProfilePom(appDirectory.Path); 689File.WriteAllText(Path.Combine(appDirectory.Path, "build.gradle"), "plugins { id 'java' }"); 691Assert.Equal("17", JavaVersionDetector.Detect(appDirectory.Path, JavaBuildTool.Gradle, ["-Pprod"])); 699File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 714Assert.Equal("21", JavaVersionDetector.Detect(appDirectory.Path)); 724File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 738Assert.Equal(JavaVersionDetector.DefaultJavaVersion, JavaVersionDetector.Detect(appDirectory.Path)); 908File.WriteAllText(Path.Combine(appDirectory.Path, "build.gradle"), script); 910Assert.Equal(expected, JavaVersionDetector.Detect(appDirectory.Path)); 1020File.WriteAllText(Path.Combine(appDirectory.Path, fileName), script); 1022Assert.Equal("25", JavaVersionDetector.Detect(appDirectory.Path)); 1030File.WriteAllText(Path.Combine(appDirectory.Path, "build.gradle"), """ 1035Assert.Equal("21", JavaVersionDetector.Detect(appDirectory.Path)); 1043File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 1046File.WriteAllText(Path.Combine(appDirectory.Path, "build.gradle"), "sourceCompatibility = '21'"); 1048Assert.Equal("17", JavaVersionDetector.Detect(appDirectory.Path)); 1062File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 1065File.WriteAllText(Path.Combine(appDirectory.Path, "build.gradle"), "sourceCompatibility = '21'"); 1069Assert.Equal(expected, JavaVersionDetector.Detect(appDirectory.Path, tool)); 1079File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 1082File.WriteAllText(Path.Combine(appDirectory.Path, "build.gradle"), "plugins { id 'java' }"); 1084Assert.Equal("17", JavaVersionDetector.Detect(appDirectory.Path, JavaBuildTool.Gradle)); 1094File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 1109Assert.Equal("21", JavaVersionDetector.Detect(appDirectory.Path)); 1117File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 1131Assert.Equal("17", JavaVersionDetector.Detect(appDirectory.Path)); 1139File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), """ 1150Assert.Equal(JavaVersionDetector.DefaultJavaVersion, JavaVersionDetector.Detect(appDirectory.Path)); 1160File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), "<project>"); 1162Assert.Equal(JavaVersionDetector.DefaultJavaVersion, JavaVersionDetector.Detect(appDirectory.Path)); 1171var app = builder.AddJavaApp("api", appDirectory.Path, "target/api.jar"); 1174() => JavaDockerfileGenerator.ResolveBuildTool(app.Resource, appDirectory.Path)); 1178$"Add a pom.xml, build.gradle, build.gradle.kts, settings.gradle, or settings.gradle.kts to '{appDirectory.Path}', " + 1192File.WriteAllText(Path.Combine(appDirectory.Path, fileName), ""); 1195var app = builder.AddJavaApp("api", appDirectory.Path, "build/libs/api.jar"); 1197var (tool, args) = JavaDockerfileGenerator.ResolveBuildTool(app.Resource, appDirectory.Path); 1209File.WriteAllText(Path.Combine(appDirectory.Path, "pom.xml"), "<project />"); 1210File.WriteAllText(Path.Combine(appDirectory.Path, "build.gradle"), ""); 1213var app = builder.AddJavaApp("api", appDirectory.Path).WithGradleTask("bootRun").WithGradleBuild("bootJar"); 1215var (tool, args) = JavaDockerfileGenerator.ResolveBuildTool(app.Resource, appDirectory.Path); 1824var stagingDirectory = Path.Combine(workspace.Path, "staged"); 1859workspace.Path); 2003var app = builder.AddJavaApp("api", tempDir.Path, jarPath); 2008() => JavaDockerfileGenerator.TryGetPrebuiltJarPath(app.Resource, tempDir.Path, out _)); 2020var app = builder.AddJavaApp("api", tempDir.Path) 2286WritePom(appDirectory.Path, javaVersion: "21"); 2289var app = builder.AddJavaApp("api", appDirectory.Path, "../shared/worker.jar").WithMavenBuild(); 2307WritePom(appDirectory.Path, javaVersion: "21"); 2310var app = builder.AddJavaApp("api", appDirectory.Path, jarPath).WithMavenBuild(); 2324WritePom(appDirectory.Path, javaVersion: "21"); 2327var app = builder.AddJavaApp("api", appDirectory.Path).WithMavenBuild().WithJarArtifact(@"C:\out\app.jar"); 2330() => JavaDockerfileGenerator.JavaContainerBuild.Resolve(app.Resource, appDirectory.Path)); 2339WritePom(appDirectory.Path, javaVersion: "21"); 2342var app = builder.AddJavaApp("api", appDirectory.Path).WithMavenBuild().WithWrapperPath(@"C:\tools\mvnw"); 2345() => JavaDockerfileGenerator.JavaContainerBuild.Resolve(app.Resource, appDirectory.Path));
AddJavaAppTests.cs (121)
41var app = builder.AddJavaApp("api", tempDir.Path).WithMavenGoal("spring-boot:run"); 46Assert.Equal(ExpectedWrapperInvocation.Args(Path.Combine(tempDir.Path, JavaHostingExtensions.s_defaultMavenWrapper), tempDir.Path, "spring-boot:run"), await ArgumentEvaluator.GetArgumentListAsync(app.Resource)); 56var app = builder.AddJavaApp("api", tempDir.Path).WithGradleTask("bootRun", "--no-daemon"); 59Assert.Equal(ExpectedWrapperInvocation.Args(Path.Combine(tempDir.Path, JavaHostingExtensions.s_defaultGradleWrapper), tempDir.Path, "bootRun", "--no-daemon"), await ArgumentEvaluator.GetArgumentListAsync(app.Resource)); 137var app = builder.AddJavaApp("api", tempDir.Path); 139var expectedPath = Path.GetFullPath(tempDir.Path, builder.AppHostDirectory); 222var app = builder.AddJavaApp("api", tempDir.Path); 240var app = builder.AddJavaApp("api", tempDir.Path) 254var app = builder.AddJavaApp("api", tempDir.Path) 281var app = builder.AddJavaApp("api", tempDir.Path); 299var app = builder.AddJavaApp("api", tempDir.Path) 314var app = builder.AddJavaApp("api", tempDir.Path) 320var expectedWrapper = Path.GetFullPath(Path.Combine(tempDir.Path, JavaHostingExtensions.s_defaultGradleWrapper)); 322Assert.Equal(ExpectedWrapperInvocation.Args(expectedWrapper, tempDir.Path, "bootRun"), args); 332var app = builder.AddJavaApp("api", tempDir.Path) 338var expectedWrapper = Path.GetFullPath(Path.Combine(tempDir.Path, JavaHostingExtensions.s_defaultMavenWrapper)); 340Assert.Equal(ExpectedWrapperInvocation.Args(expectedWrapper, tempDir.Path, "spring-boot:run"), args); 351File.WriteAllText(Path.Combine(repo.Path, "settings.gradle"), "include 'services:api'"); 352var module = Directory.CreateDirectory(Path.Combine(repo.Path, "services", "api")).FullName; 359var expectedWrapper = Path.GetFullPath(Path.Combine(repo.Path, JavaHostingExtensions.s_defaultGradleWrapper)); 371File.WriteAllText(Path.Combine(repo.Path, "pom.xml"), "<project />"); 372var module = Directory.CreateDirectory(Path.Combine(repo.Path, "services", "api")).FullName; 379var expectedWrapper = Path.GetFullPath(Path.Combine(repo.Path, JavaHostingExtensions.s_defaultMavenWrapper)); 391var module = Directory.CreateDirectory(Path.Combine(repo.Path, "services", "api")).FullName; 438var app = builder.AddJavaApp("api", tempDir.Path) 453var app = builder.AddJavaApp("api", tempDir.Path, "app.jar"); 469var app = builder.AddJavaApp("api", tempDir.Path, "app.jar"); 485var app = builder.AddJavaApp("api", tempDir.Path).WithMavenGoal("spring-boot:run"); 501var app = builder.AddJavaApp("api", tempDir.Path).WithGradleTask("bootRun"); 546var app = builder.AddJavaApp("api", tempDir.Path) 553var expectedWrapper = Path.GetFullPath(Path.Combine(tempDir.Path, "scripts/custom-mvnw")); 555Assert.Equal(ExpectedWrapperInvocation.Args(expectedWrapper, tempDir.Path, "spring-boot:run"), args); 564var app = builder.AddJavaApp("api", tempDir.Path) 571var expectedWrapper = Path.GetFullPath(Path.Combine(tempDir.Path, "scripts/custom-gradlew")); 573Assert.Equal(ExpectedWrapperInvocation.Args(expectedWrapper, tempDir.Path, "bootRun"), args); 741var app = builder.AddJavaApp("api", tempDir.Path).WithMavenGoal("spring-boot:run"); 760var app = builder.AddJavaApp("api", tempDir.Path).WithGradleTask("bootRun"); 779var customWrapper = Path.Combine(tempDir.Path, "tools", "mvnw"); 786var app = builder.AddJavaApp("api", tempDir.Path) 802ExpectedWrapperInvocation.Args(Path.GetFullPath(customWrapper), Path.GetFullPath(tempDir.Path), "spring-boot:run"), 815var wrapper = Path.Combine(tempDir.Path, JavaHostingExtensions.s_defaultMavenWrapper); 822var app = builder.AddJavaApp("api", tempDir.Path).WithMavenGoal("spring-boot:run"); 830WorkingDirectory = tempDir.Path, 846var app = builder.AddJavaApp("api", tempDir.Path) 869var app = builder.AddJavaApp("api", tempDir.Path) 877ExpectedWrapperInvocation.Args("/opt/maven/bin/mvn", tempDir.Path, "spring-boot:run"), 1031builder.AddJavaApp("api", tempDir.Path) 1044builder.AddJavaApp("api", tempDir.Path) 1057builder.AddJavaApp("api", tempDir.Path) 1070builder.AddJavaApp("api", tempDir.Path) 1083builder.AddJavaApp("api", tempDir.Path) 1095builder.AddJavaApp("api", tempDir.Path) 1110var app = builder.AddJavaApp("api", tempDir.Path); 1149var app = builder.AddJavaApp("api", tempDir.Path) 1163var app = builder.AddJavaApp("api", tempDir.Path) 1220var app = builder.AddJavaApp("api", tempDir.Path) 1250var app = builder.AddJavaApp("api", tempDir.Path); 1271var app = builder.AddJavaApp("api", tempDir.Path) 1289var app = builder.AddJavaApp("api", tempDir.Path) 1307var app = builder.AddJavaApp("api", tempDir.Path) 1314var expectedWrapper = Path.GetFullPath(Path.Combine(tempDir.Path, "tools/mvn")); 1316Assert.Equal(ExpectedWrapperInvocation.Args(expectedWrapper, tempDir.Path, "spring-boot:run"), args); 1327var app = builder.AddJavaApp("api", tempDir.Path) 1344var app = builder.AddJavaApp("api", tempDir.Path) 1376var javaExecutable = Path.Combine(tempDir.Path, fileName); 1377var app = builder.AddJavaApp("api", tempDir.Path, "app.jar") 1392var command = Path.Combine(tempDir.Path, fileName); 1393var app = builder.AddJavaApp("api", tempDir.Path, "app.jar") 1405var app = builder.AddJavaApp("api", tempDir.Path, "app.jar") 1418var javaExecutable = Path.Combine(tempDir.Path, OperatingSystem.IsWindows() ? "java.exe" : "java"); 1419var app = builder.AddJavaApp("api", tempDir.Path, "app.jar") 1445var javaExecutable = Path.Combine(tempDir.Path, OperatingSystem.IsWindows() ? "java.exe" : "java"); 1446var app = builder.AddJavaApp("api", tempDir.Path); 1470var wrapperCommand = Path.Combine(tempDir.Path, OperatingSystem.IsWindows() ? "cmd.exe" : "sh"); 1471var app = builder.AddSpringBootApp("catalog", tempDir.Path) 1488var app = builder.AddSpringBootApp("catalog", tempDir.Path); 1508tempDir.Path, 1512var app = builder.AddQuarkusApp("inventory", tempDir.Path); 1568var app = builder.AddJavaApp("api", tempDir.Path).WithMavenGoal("spring-boot:run"); 1576Assert.Equal(tempDir.Path, launchConfiguration.WorkingDirectory); 1584var jarPath = WriteJarWithManifest(tempDir.Path, "api.jar", "com.example.catalog.CatalogApplication"); 1586var app = builder.AddJavaApp("api", tempDir.Path, "api.jar"); 1604var jarPath = WriteJarWithManifest(tempDir.Path, "target/api.jar", "com.example.catalog.CatalogApplication"); 1606var app = builder.AddJavaApp("api", tempDir.Path, @"target\api.jar"); 1620WriteJarWithManifest(tempDir.Path, "api.jar", MainClass, wrapLongValue: true); 1622var app = builder.AddJavaApp("api", tempDir.Path, "api.jar"); 1634var jarPath = WriteJarWithManifest(tempDir.Path, "api.jar", "org.springframework.boot.loader.JarLauncher"); 1636var app = builder.AddJavaApp("api", tempDir.Path, "api.jar") 1650WriteJarWithManifest(tempDir.Path, "no-main.jar", mainClass: null); 1652var noMainClass = builder.AddJavaApp("no-main", tempDir.Path, "no-main.jar"); 1653var missing = builder.AddJavaApp("missing", tempDir.Path, "does-not-exist.jar"); 1659Assert.Equal(Path.Combine(tempDir.Path, "no-main.jar"), Assert.Single(noMainClassConfiguration.ClassPaths!)); 1663Assert.Equal(Path.Combine(tempDir.Path, "does-not-exist.jar"), Assert.Single(missingConfiguration.ClassPaths!)); 1678tempDir.Path, 1683var app = builder.AddJavaApp("catalog", tempDir.Path); 1689Path.Combine(tempDir.Path, tool == "maven" ? "pom.xml" : "settings.gradle"), 1721WriteJarWithManifest(tempDir.Path, "build/libs/orders.jar", mainClass: null, startClass: "com.example.orders.OrdersApplication"); 1724WriteJarWithManifest(tempDir.Path, "build/libs/orders-plain.jar", mainClass: null); 1725WriteJarWithManifest(tempDir.Path, "build/libs/orders-sources.jar", mainClass: null); 1726WriteJarWithManifest(tempDir.Path, "build/libs/orders-javadoc.jar", mainClass: null); 1728var app = builder.AddJavaApp("orders", tempDir.Path).WithGradleTask("bootRun"); 1742WriteJarWithManifest(tempDir.Path, "target/catalog-0.0.1-SNAPSHOT.jar", mainClass: null, startClass: "com.example.catalog.CatalogApplication"); 1743WriteJarWithManifest(tempDir.Path, "target/catalog-0.0.1-SNAPSHOT-shaded.jar", mainClass: null, startClass: "com.example.catalog.Other"); 1745var app = builder.AddJavaApp("catalog", tempDir.Path).WithMavenGoal("spring-boot:run"); 1760WriteJarWithManifest(tempDir.Path, "target/catalog.jar", mainClass: "org.springframework.boot.loader.launch.JarLauncher"); 1762var app = builder.AddJavaApp("catalog", tempDir.Path).WithMavenGoal("spring-boot:run"); 1778WriteJarWithManifest(tempDir.Path, "target/catalog.jar", mainClass: null, startClass: "com.example.catalog.CatalogApplication"); 1780var app = builder.AddJavaApp("catalog", tempDir.Path) 1797File.WriteAllText(Path.Combine(tempDir.Path, "pom.xml"), """ 1812var app = builder.AddJavaApp("catalog", tempDir.Path).WithMavenGoal("spring-boot:run"); 1827File.WriteAllText(Path.Combine(tempDir.Path, "settings.gradle"), "rootProject.name = 'orders'\n"); 1829var app = builder.AddJavaApp("orders", tempDir.Path).WithGradleTask("bootRun"); 1844var app = builder.AddJavaApp("orders", tempDir.Path).WithGradleTask("bootRun"); 1849Path.GetFileName(tempDir.Path.TrimEnd(Path.DirectorySeparatorChar)), 1861Path.Combine(tempDir.Path, "settings.gradle"), 1864var app = builder.AddJavaApp("apphost", tempDir.Path).WithGradleTask("bootRun"); 1882File.WriteAllText(Path.Combine(tempDir.Path, "pom.xml"), """ 1893tempDir.Path, 1898.AddJavaApp("worker", tempDir.Path, Path.Combine("target", "worker-0.0.1-SNAPSHOT.jar"))
AddQuarkusAppTests.cs (21)
28var app = builder.AddQuarkusApp("inventory", tempDir.Path); 48var app = builder.AddQuarkusApp("inventory", tempDir.Path); 65var app = builder.AddSpringBootApp("catalog", tempDir.Path); 94var app = builder.AddQuarkusApp("inventory", tempDir.Path); 101Assert.Equal(ExpectedWrapperInvocation.Args(Path.Combine(tempDir.Path, JavaHostingExtensions.s_defaultMavenWrapper), tempDir.Path, "quarkus:dev"), await ArgumentEvaluator.GetArgumentListAsync(app.Resource)); 111var app = builder.AddQuarkusApp("pricing", tempDir.Path); 118Assert.Equal(ExpectedWrapperInvocation.Args(Path.Combine(tempDir.Path, JavaHostingExtensions.s_defaultGradleWrapper), tempDir.Path, "quarkusDev"), await ArgumentEvaluator.GetArgumentListAsync(app.Resource)); 130var app = builder.AddQuarkusApp("inventory", tempDir.Path); 142var app = builder.AddQuarkusApp("inventory", tempDir.Path); 159var app = builder.AddQuarkusApp("pricing", tempDir.Path); 174var app = builder.AddQuarkusApp("inventory", tempDir.Path); 192var app = builder.AddQuarkusApp("inventory", tempDir.Path); 209var app = builder.AddQuarkusApp("inventory", tempDir.Path); 228var app = builder.AddQuarkusApp("inventory", tempDir.Path); 252var app = builder.AddQuarkusApp("inventory", tempDir.Path); 270var app = builder.AddQuarkusApp("inventory", tempDir.Path); 281var app = builder.AddQuarkusApp("inventory", tempDir.Path); 290$"Directory '{tempDir.Path}' contains no pom.xml, build.gradle, build.gradle.kts, settings.gradle, or settings.gradle.kts, " + 302var app = builder.AddQuarkusApp("inventory", tempDir.Path)
AddSpringBootAppTests.cs (32)
19var app = builder.AddSpringBootApp("catalog", tempDir.Path); 26Assert.Equal(ExpectedWrapperInvocation.Args(Path.Combine(tempDir.Path, JavaHostingExtensions.s_defaultMavenWrapper), tempDir.Path, "spring-boot:run"), await ArgumentEvaluator.GetArgumentListAsync(app.Resource)); 36var app = builder.AddSpringBootApp("orders", tempDir.Path); 43Assert.Equal(ExpectedWrapperInvocation.Args(Path.Combine(tempDir.Path, JavaHostingExtensions.s_defaultGradleWrapper), tempDir.Path, "bootRun"), await ArgumentEvaluator.GetArgumentListAsync(app.Resource)); 53var app = builder.AddSpringBootApp("orders", tempDir.Path); 73var runApp = runBuilder.AddSpringBootApp("catalog", tempDir.Path); 81var publishApp = publishBuilder.AddJavaApp("catalog", tempDir.Path, "build/libs/catalog.jar"); 82var (publishTool, _) = JavaDockerfileGenerator.ResolveBuildTool(publishApp.Resource, tempDir.Path); 97var app = builder.AddSpringBootApp("catalog", tempDir.Path); 110var app = builder.AddSpringBootApp("catalog", tempDir.Path) 119Path.Combine(tempDir.Path, JavaHostingExtensions.s_defaultMavenWrapper), 120tempDir.Path, 133var app = builder.AddSpringBootApp("catalog", tempDir.Path) 154var app = builder.AddSpringBootApp("catalog", tempDir.Path); 174var app = builder.AddSpringBootApp("catalog", tempDir.Path); 185var app = builder.AddSpringBootApp("catalog", tempDir.Path); 194$"Directory '{tempDir.Path}' contains no pom.xml, build.gradle, build.gradle.kts, settings.gradle, or settings.gradle.kts, " + 207var runApp = runBuilder.AddSpringBootApp("catalog", tempDir.Path); 215var publishApp = publishBuilder.AddJavaApp("catalog", tempDir.Path, "target/catalog.jar"); 217() => JavaDockerfileGenerator.ResolveBuildTool(publishApp.Resource, tempDir.Path)); 220$"Directory '{tempDir.Path}' contains both Maven and Gradle build files, so the build tool for resource 'catalog' is ambiguous. " + 235var app = builder.AddSpringBootApp("catalog", tempDir.Path).WithOtelAgent(); 246var expected = Path.GetFullPath(Path.Combine(tempDir.Path, outputDirectory, "agent", "opentelemetry-javaagent.jar")); 261var app = builder.AddJavaApp("catalog", tempDir.Path).WithOtelAgent(); 277var expected = Path.GetFullPath(Path.Combine(tempDir.Path, outputDirectory, "agent", "opentelemetry-javaagent.jar")); 294var app = builder.AddSpringBootApp("catalog", tempDir.Path).WithOtelAgent(); 320var app = builder.AddSpringBootApp("catalog", tempDir.Path) 335var app = builder.AddJavaApp("api", tempDir.Path).WithOtelAgent(); 355var app = builder.AddSpringBootApp("catalog", tempDir.Path) 381var app = builder.AddSpringBootApp("catalog", tempDir.Path)
JavaBuildToolResolverTests.cs (4)
21var resource = new JavaAppResource("api", tempDir.Path); 26Assert.Equal(Path.GetFullPath(Path.Combine(tempDir.Path, expectedWrapperName)), wrapperPath); 36var app = builder.AddJavaApp("api", tempDir.Path).WithWrapperPath("tools/custom-wrapper"); 40Assert.Equal(Path.GetFullPath(Path.Combine(tempDir.Path, "tools", "custom-wrapper")), wrapperPath);
TempJavaAppDirectory.cs (1)
43var fullPath = System.IO.Path.Combine(Path, fileName);