223 references to Path
Aspire.Hosting.Java.Tests (223)
AddJavaAppPublishTests.cs (55)
113
builder.AddJavaApp("worker", tempDir.
Path
, "target/worker.jar")
149
var app = builder.AddJavaApp("api", tempDir.
Path
)
199
WritePom(appDirectory.
Path
, javaVersion: "21");
202
var app = builder.AddJavaApp("api", appDirectory.
Path
)
287
var app = builder.AddJavaApp("api", appDirectory.
Path
, jarPath);
511
File.WriteAllText(Path.Combine(appDirectory.
Path
, "pom.xml"), $"""
522
Assert.Equal(expected, JavaVersionDetector.Detect(appDirectory.
Path
));
532
File.WriteAllText(Path.Combine(appDirectory.
Path
, "pom.xml"), """
552
Assert.Equal("17", JavaVersionDetector.Detect(appDirectory.
Path
));
562
File.WriteAllText(Path.Combine(appDirectory.
Path
, "pom.xml"), """
576
Assert.Equal(JavaVersionDetector.DefaultJavaVersion, JavaVersionDetector.Detect(appDirectory.
Path
));
640
File.WriteAllText(Path.Combine(appDirectory.
Path
, "build.gradle"), script);
642
Assert.Equal(expected, JavaVersionDetector.Detect(appDirectory.
Path
));
650
File.WriteAllText(Path.Combine(appDirectory.
Path
, "pom.xml"), """
653
File.WriteAllText(Path.Combine(appDirectory.
Path
, "build.gradle"), "sourceCompatibility = '21'");
655
Assert.Equal("17", JavaVersionDetector.Detect(appDirectory.
Path
));
669
File.WriteAllText(Path.Combine(appDirectory.
Path
, "pom.xml"), """
672
File.WriteAllText(Path.Combine(appDirectory.
Path
, "build.gradle"), "sourceCompatibility = '21'");
676
Assert.Equal(expected, JavaVersionDetector.Detect(appDirectory.
Path
, tool));
686
File.WriteAllText(Path.Combine(appDirectory.
Path
, "pom.xml"), """
689
File.WriteAllText(Path.Combine(appDirectory.
Path
, "build.gradle"), "plugins { id 'java' }");
691
Assert.Equal("17", JavaVersionDetector.Detect(appDirectory.
Path
, JavaBuildTool.Gradle));
701
File.WriteAllText(Path.Combine(appDirectory.
Path
, "pom.xml"), """
716
Assert.Equal("21", JavaVersionDetector.Detect(appDirectory.
Path
));
724
File.WriteAllText(Path.Combine(appDirectory.
Path
, "pom.xml"), """
738
Assert.Equal("17", JavaVersionDetector.Detect(appDirectory.
Path
));
746
File.WriteAllText(Path.Combine(appDirectory.
Path
, "pom.xml"), """
757
Assert.Equal(JavaVersionDetector.DefaultJavaVersion, JavaVersionDetector.Detect(appDirectory.
Path
));
767
File.WriteAllText(Path.Combine(appDirectory.
Path
, "pom.xml"), "<project>");
769
Assert.Equal(JavaVersionDetector.DefaultJavaVersion, JavaVersionDetector.Detect(appDirectory.
Path
));
778
var app = builder.AddJavaApp("api", appDirectory.
Path
, "target/api.jar");
781
() => JavaDockerfileGenerator.ResolveBuildTool(app.Resource, appDirectory.
Path
));
785
$"Add a pom.xml, build.gradle, build.gradle.kts, settings.gradle, or settings.gradle.kts to '{appDirectory.
Path
}', " +
799
File.WriteAllText(Path.Combine(appDirectory.
Path
, fileName), "");
802
var app = builder.AddJavaApp("api", appDirectory.
Path
, "build/libs/api.jar");
804
var (tool, args) = JavaDockerfileGenerator.ResolveBuildTool(app.Resource, appDirectory.
Path
);
816
File.WriteAllText(Path.Combine(appDirectory.
Path
, "pom.xml"), "<project />");
817
File.WriteAllText(Path.Combine(appDirectory.
Path
, "build.gradle"), "");
820
var app = builder.AddJavaApp("api", appDirectory.
Path
).WithGradleTask("bootRun").WithGradleBuild("bootJar");
822
var (tool, args) = JavaDockerfileGenerator.ResolveBuildTool(app.Resource, appDirectory.
Path
);
1431
var stagingDirectory = Path.Combine(workspace.
Path
, "staged");
1466
workspace.
Path
);
1610
var app = builder.AddJavaApp("api", tempDir.
Path
, jarPath);
1615
() => JavaDockerfileGenerator.TryGetPrebuiltJarPath(app.Resource, tempDir.
Path
, out _));
1627
var app = builder.AddJavaApp("api", tempDir.
Path
)
1893
WritePom(appDirectory.
Path
, javaVersion: "21");
1896
var app = builder.AddJavaApp("api", appDirectory.
Path
, "../shared/worker.jar").WithMavenBuild();
1914
WritePom(appDirectory.
Path
, javaVersion: "21");
1917
var app = builder.AddJavaApp("api", appDirectory.
Path
, jarPath).WithMavenBuild();
1931
WritePom(appDirectory.
Path
, javaVersion: "21");
1934
var app = builder.AddJavaApp("api", appDirectory.
Path
).WithMavenBuild().WithJarArtifact(@"C:\out\app.jar");
1937
() => JavaDockerfileGenerator.JavaContainerBuild.Resolve(app.Resource, appDirectory.
Path
));
1946
WritePom(appDirectory.
Path
, javaVersion: "21");
1949
var app = builder.AddJavaApp("api", appDirectory.
Path
).WithMavenBuild().WithWrapperPath(@"C:\tools\mvnw");
1952
() => JavaDockerfileGenerator.JavaContainerBuild.Resolve(app.Resource, appDirectory.
Path
));
AddJavaAppTests.cs (110)
41
var app = builder.AddJavaApp("api", tempDir.
Path
).WithMavenGoal("spring-boot:run");
46
Assert.Equal(ExpectedWrapperInvocation.Args(Path.Combine(tempDir.
Path
, JavaHostingExtensions.s_defaultMavenWrapper), tempDir.
Path
, "spring-boot:run"), await ArgumentEvaluator.GetArgumentListAsync(app.Resource));
56
var app = builder.AddJavaApp("api", tempDir.
Path
).WithGradleTask("bootRun", "--no-daemon");
59
Assert.Equal(ExpectedWrapperInvocation.Args(Path.Combine(tempDir.
Path
, JavaHostingExtensions.s_defaultGradleWrapper), tempDir.
Path
, "bootRun", "--no-daemon"), await ArgumentEvaluator.GetArgumentListAsync(app.Resource));
137
var app = builder.AddJavaApp("api", tempDir.
Path
);
139
var expectedPath = Path.GetFullPath(tempDir.
Path
, builder.AppHostDirectory);
222
var app = builder.AddJavaApp("api", tempDir.
Path
);
240
var app = builder.AddJavaApp("api", tempDir.
Path
)
254
var app = builder.AddJavaApp("api", tempDir.
Path
)
281
var app = builder.AddJavaApp("api", tempDir.
Path
);
299
var app = builder.AddJavaApp("api", tempDir.
Path
)
314
var app = builder.AddJavaApp("api", tempDir.
Path
)
320
var expectedWrapper = Path.GetFullPath(Path.Combine(tempDir.
Path
, JavaHostingExtensions.s_defaultGradleWrapper));
322
Assert.Equal(ExpectedWrapperInvocation.Args(expectedWrapper, tempDir.
Path
, "bootRun"), args);
332
var app = builder.AddJavaApp("api", tempDir.
Path
)
338
var expectedWrapper = Path.GetFullPath(Path.Combine(tempDir.
Path
, JavaHostingExtensions.s_defaultMavenWrapper));
340
Assert.Equal(ExpectedWrapperInvocation.Args(expectedWrapper, tempDir.
Path
, "spring-boot:run"), args);
351
File.WriteAllText(Path.Combine(repo.
Path
, "settings.gradle"), "include 'services:api'");
352
var module = Directory.CreateDirectory(Path.Combine(repo.
Path
, "services", "api")).FullName;
359
var expectedWrapper = Path.GetFullPath(Path.Combine(repo.
Path
, JavaHostingExtensions.s_defaultGradleWrapper));
371
File.WriteAllText(Path.Combine(repo.
Path
, "pom.xml"), "<project />");
372
var module = Directory.CreateDirectory(Path.Combine(repo.
Path
, "services", "api")).FullName;
379
var expectedWrapper = Path.GetFullPath(Path.Combine(repo.
Path
, JavaHostingExtensions.s_defaultMavenWrapper));
391
var module = Directory.CreateDirectory(Path.Combine(repo.
Path
, "services", "api")).FullName;
438
var app = builder.AddJavaApp("api", tempDir.
Path
)
453
var app = builder.AddJavaApp("api", tempDir.
Path
, "app.jar");
469
var app = builder.AddJavaApp("api", tempDir.
Path
, "app.jar");
485
var app = builder.AddJavaApp("api", tempDir.
Path
).WithMavenGoal("spring-boot:run");
501
var app = builder.AddJavaApp("api", tempDir.
Path
).WithGradleTask("bootRun");
546
var app = builder.AddJavaApp("api", tempDir.
Path
)
553
var expectedWrapper = Path.GetFullPath(Path.Combine(tempDir.
Path
, "scripts/custom-mvnw"));
555
Assert.Equal(ExpectedWrapperInvocation.Args(expectedWrapper, tempDir.
Path
, "spring-boot:run"), args);
564
var app = builder.AddJavaApp("api", tempDir.
Path
)
571
var expectedWrapper = Path.GetFullPath(Path.Combine(tempDir.
Path
, "scripts/custom-gradlew"));
573
Assert.Equal(ExpectedWrapperInvocation.Args(expectedWrapper, tempDir.
Path
, "bootRun"), args);
741
var app = builder.AddJavaApp("api", tempDir.
Path
).WithMavenGoal("spring-boot:run");
760
var app = builder.AddJavaApp("api", tempDir.
Path
).WithGradleTask("bootRun");
779
var customWrapper = Path.Combine(tempDir.
Path
, "tools", "mvnw");
786
var app = builder.AddJavaApp("api", tempDir.
Path
)
802
ExpectedWrapperInvocation.Args(Path.GetFullPath(customWrapper), Path.GetFullPath(tempDir.
Path
), "spring-boot:run"),
815
var wrapper = Path.Combine(tempDir.
Path
, JavaHostingExtensions.s_defaultMavenWrapper);
822
var app = builder.AddJavaApp("api", tempDir.
Path
).WithMavenGoal("spring-boot:run");
830
WorkingDirectory = tempDir.
Path
,
846
var app = builder.AddJavaApp("api", tempDir.
Path
)
869
var app = builder.AddJavaApp("api", tempDir.
Path
)
877
ExpectedWrapperInvocation.Args("/opt/maven/bin/mvn", tempDir.
Path
, "spring-boot:run"),
1031
builder.AddJavaApp("api", tempDir.
Path
)
1044
builder.AddJavaApp("api", tempDir.
Path
)
1057
builder.AddJavaApp("api", tempDir.
Path
)
1070
builder.AddJavaApp("api", tempDir.
Path
)
1083
builder.AddJavaApp("api", tempDir.
Path
)
1095
builder.AddJavaApp("api", tempDir.
Path
)
1110
var app = builder.AddJavaApp("api", tempDir.
Path
);
1149
var app = builder.AddJavaApp("api", tempDir.
Path
)
1163
var app = builder.AddJavaApp("api", tempDir.
Path
)
1220
var app = builder.AddJavaApp("api", tempDir.
Path
)
1250
var app = builder.AddJavaApp("api", tempDir.
Path
);
1271
var app = builder.AddJavaApp("api", tempDir.
Path
)
1289
var app = builder.AddJavaApp("api", tempDir.
Path
)
1307
var app = builder.AddJavaApp("api", tempDir.
Path
)
1314
var expectedWrapper = Path.GetFullPath(Path.Combine(tempDir.
Path
, "tools/mvn"));
1316
Assert.Equal(ExpectedWrapperInvocation.Args(expectedWrapper, tempDir.
Path
, "spring-boot:run"), args);
1327
var app = builder.AddJavaApp("api", tempDir.
Path
)
1344
var app = builder.AddJavaApp("api", tempDir.
Path
)
1377
var app = builder.AddSpringBootApp("catalog", tempDir.
Path
);
1397
tempDir.
Path
,
1401
var app = builder.AddQuarkusApp("inventory", tempDir.
Path
);
1457
var app = builder.AddJavaApp("api", tempDir.
Path
).WithMavenGoal("spring-boot:run");
1464
Assert.Equal(tempDir.
Path
, launchConfiguration.WorkingDirectory);
1472
var jarPath = WriteJarWithManifest(tempDir.
Path
, "api.jar", "com.example.catalog.CatalogApplication");
1474
var app = builder.AddJavaApp("api", tempDir.
Path
, "api.jar");
1491
var jarPath = WriteJarWithManifest(tempDir.
Path
, "target/api.jar", "com.example.catalog.CatalogApplication");
1493
var app = builder.AddJavaApp("api", tempDir.
Path
, @"target\api.jar");
1507
WriteJarWithManifest(tempDir.
Path
, "api.jar", MainClass, wrapLongValue: true);
1509
var app = builder.AddJavaApp("api", tempDir.
Path
, "api.jar");
1521
var jarPath = WriteJarWithManifest(tempDir.
Path
, "api.jar", "org.springframework.boot.loader.JarLauncher");
1523
var app = builder.AddJavaApp("api", tempDir.
Path
, "api.jar")
1537
WriteJarWithManifest(tempDir.
Path
, "no-main.jar", mainClass: null);
1539
var noMainClass = builder.AddJavaApp("no-main", tempDir.
Path
, "no-main.jar");
1540
var missing = builder.AddJavaApp("missing", tempDir.
Path
, "does-not-exist.jar");
1546
Assert.Equal(Path.Combine(tempDir.
Path
, "no-main.jar"), Assert.Single(noMainClassConfiguration.ClassPaths!));
1550
Assert.Equal(Path.Combine(tempDir.
Path
, "does-not-exist.jar"), Assert.Single(missingConfiguration.ClassPaths!));
1565
tempDir.
Path
,
1570
var app = builder.AddJavaApp("catalog", tempDir.
Path
);
1576
Path.Combine(tempDir.
Path
, tool == "maven" ? "pom.xml" : "settings.gradle"),
1608
WriteJarWithManifest(tempDir.
Path
, "build/libs/orders.jar", mainClass: null, startClass: "com.example.orders.OrdersApplication");
1611
WriteJarWithManifest(tempDir.
Path
, "build/libs/orders-plain.jar", mainClass: null);
1612
WriteJarWithManifest(tempDir.
Path
, "build/libs/orders-sources.jar", mainClass: null);
1613
WriteJarWithManifest(tempDir.
Path
, "build/libs/orders-javadoc.jar", mainClass: null);
1615
var app = builder.AddJavaApp("orders", tempDir.
Path
).WithGradleTask("bootRun");
1629
WriteJarWithManifest(tempDir.
Path
, "target/catalog-0.0.1-SNAPSHOT.jar", mainClass: null, startClass: "com.example.catalog.CatalogApplication");
1630
WriteJarWithManifest(tempDir.
Path
, "target/catalog-0.0.1-SNAPSHOT-shaded.jar", mainClass: null, startClass: "com.example.catalog.Other");
1632
var app = builder.AddJavaApp("catalog", tempDir.
Path
).WithMavenGoal("spring-boot:run");
1647
WriteJarWithManifest(tempDir.
Path
, "target/catalog.jar", mainClass: "org.springframework.boot.loader.launch.JarLauncher");
1649
var app = builder.AddJavaApp("catalog", tempDir.
Path
).WithMavenGoal("spring-boot:run");
1665
WriteJarWithManifest(tempDir.
Path
, "target/catalog.jar", mainClass: null, startClass: "com.example.catalog.CatalogApplication");
1667
var app = builder.AddJavaApp("catalog", tempDir.
Path
)
1684
File.WriteAllText(Path.Combine(tempDir.
Path
, "pom.xml"), """
1699
var app = builder.AddJavaApp("catalog", tempDir.
Path
).WithMavenGoal("spring-boot:run");
1714
File.WriteAllText(Path.Combine(tempDir.
Path
, "settings.gradle"), "rootProject.name = 'orders'\n");
1716
var app = builder.AddJavaApp("orders", tempDir.
Path
).WithGradleTask("bootRun");
1731
var app = builder.AddJavaApp("orders", tempDir.
Path
).WithGradleTask("bootRun");
1736
Path.GetFileName(tempDir.
Path
.TrimEnd(Path.DirectorySeparatorChar)),
1748
Path.Combine(tempDir.
Path
, "settings.gradle"),
1751
var app = builder.AddJavaApp("apphost", tempDir.
Path
).WithGradleTask("bootRun");
1769
File.WriteAllText(Path.Combine(tempDir.
Path
, "pom.xml"), """
1780
tempDir.
Path
,
1785
.AddJavaApp("worker", tempDir.
Path
, Path.Combine("target", "worker-0.0.1-SNAPSHOT.jar"))
AddQuarkusAppTests.cs (21)
28
var app = builder.AddQuarkusApp("inventory", tempDir.
Path
);
48
var app = builder.AddQuarkusApp("inventory", tempDir.
Path
);
65
var app = builder.AddSpringBootApp("catalog", tempDir.
Path
);
94
var app = builder.AddQuarkusApp("inventory", tempDir.
Path
);
101
Assert.Equal(ExpectedWrapperInvocation.Args(Path.Combine(tempDir.
Path
, JavaHostingExtensions.s_defaultMavenWrapper), tempDir.
Path
, "quarkus:dev"), await ArgumentEvaluator.GetArgumentListAsync(app.Resource));
111
var app = builder.AddQuarkusApp("pricing", tempDir.
Path
);
118
Assert.Equal(ExpectedWrapperInvocation.Args(Path.Combine(tempDir.
Path
, JavaHostingExtensions.s_defaultGradleWrapper), tempDir.
Path
, "quarkusDev"), await ArgumentEvaluator.GetArgumentListAsync(app.Resource));
130
var app = builder.AddQuarkusApp("inventory", tempDir.
Path
);
142
var app = builder.AddQuarkusApp("inventory", tempDir.
Path
);
159
var app = builder.AddQuarkusApp("pricing", tempDir.
Path
);
174
var app = builder.AddQuarkusApp("inventory", tempDir.
Path
);
192
var app = builder.AddQuarkusApp("inventory", tempDir.
Path
);
209
var app = builder.AddQuarkusApp("inventory", tempDir.
Path
);
228
var app = builder.AddQuarkusApp("inventory", tempDir.
Path
);
252
var app = builder.AddQuarkusApp("inventory", tempDir.
Path
);
270
var app = builder.AddQuarkusApp("inventory", tempDir.
Path
);
281
var 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, " +
302
var app = builder.AddQuarkusApp("inventory", tempDir.
Path
)
AddSpringBootAppTests.cs (32)
19
var app = builder.AddSpringBootApp("catalog", tempDir.
Path
);
26
Assert.Equal(ExpectedWrapperInvocation.Args(Path.Combine(tempDir.
Path
, JavaHostingExtensions.s_defaultMavenWrapper), tempDir.
Path
, "spring-boot:run"), await ArgumentEvaluator.GetArgumentListAsync(app.Resource));
36
var app = builder.AddSpringBootApp("orders", tempDir.
Path
);
43
Assert.Equal(ExpectedWrapperInvocation.Args(Path.Combine(tempDir.
Path
, JavaHostingExtensions.s_defaultGradleWrapper), tempDir.
Path
, "bootRun"), await ArgumentEvaluator.GetArgumentListAsync(app.Resource));
53
var app = builder.AddSpringBootApp("orders", tempDir.
Path
);
73
var runApp = runBuilder.AddSpringBootApp("catalog", tempDir.
Path
);
81
var publishApp = publishBuilder.AddJavaApp("catalog", tempDir.
Path
, "build/libs/catalog.jar");
82
var (publishTool, _) = JavaDockerfileGenerator.ResolveBuildTool(publishApp.Resource, tempDir.
Path
);
97
var app = builder.AddSpringBootApp("catalog", tempDir.
Path
);
110
var app = builder.AddSpringBootApp("catalog", tempDir.
Path
)
119
Path.Combine(tempDir.
Path
, JavaHostingExtensions.s_defaultMavenWrapper),
120
tempDir.
Path
,
133
var app = builder.AddSpringBootApp("catalog", tempDir.
Path
)
154
var app = builder.AddSpringBootApp("catalog", tempDir.
Path
);
174
var app = builder.AddSpringBootApp("catalog", tempDir.
Path
);
185
var 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, " +
207
var runApp = runBuilder.AddSpringBootApp("catalog", tempDir.
Path
);
215
var 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. " +
235
var app = builder.AddSpringBootApp("catalog", tempDir.
Path
).WithOtelAgent();
246
var expected = Path.GetFullPath(Path.Combine(tempDir.
Path
, outputDirectory, "agent", "opentelemetry-javaagent.jar"));
261
var app = builder.AddJavaApp("catalog", tempDir.
Path
).WithOtelAgent();
277
var expected = Path.GetFullPath(Path.Combine(tempDir.
Path
, outputDirectory, "agent", "opentelemetry-javaagent.jar"));
294
var app = builder.AddSpringBootApp("catalog", tempDir.
Path
).WithOtelAgent();
320
var app = builder.AddSpringBootApp("catalog", tempDir.
Path
)
335
var app = builder.AddJavaApp("api", tempDir.
Path
).WithOtelAgent();
355
var app = builder.AddSpringBootApp("catalog", tempDir.
Path
)
381
var app = builder.AddSpringBootApp("catalog", tempDir.
Path
)
JavaBuildToolResolverTests.cs (4)
21
var resource = new JavaAppResource("api", tempDir.
Path
);
26
Assert.Equal(Path.GetFullPath(Path.Combine(tempDir.
Path
, expectedWrapperName)), wrapperPath);
36
var app = builder.AddJavaApp("api", tempDir.
Path
).WithWrapperPath("tools/custom-wrapper");
40
Assert.Equal(Path.GetFullPath(Path.Combine(tempDir.
Path
, "tools", "custom-wrapper")), wrapperPath);
TempJavaAppDirectory.cs (1)
43
var fullPath = System.IO.Path.Combine(
Path
, fileName);