in jetbrains-core/it/software/aws/toolkits/jetbrains/services/clouddebug/java/JavaDebugEndToEndTest.kt [45:120]
fun testEndToEnd() {
// setup project workspace
addJavaFile()
val basePath = Paths.get(projectRule.module.moduleFilePath).parent
val jarFile = basePath.resolve(Paths.get("build", "libs", "main.jar"))
// TODO: figure out how to turn this into a before task
// ./gradlew jar
val buildSettings = ExternalSystemTaskExecutionSettings().apply {
externalSystemIdString = "GRADLE"
externalProjectPath = basePath.toString()
taskNames = listOf("jar")
}
val future = CompletableFuture<Nothing>()
ExternalSystemUtil.runTask(
buildSettings,
DefaultRunExecutor.EXECUTOR_ID,
projectRule.project,
GradleConstants.SYSTEM_ID,
object : TaskCallback {
override fun onSuccess() {
future.complete(null)
}
override fun onFailure() {
future.completeExceptionally(RuntimeException("Jar task failed"))
}
},
ProgressExecutionMode.IN_BACKGROUND_ASYNC,
false
)
future.join()
// set breakpoint
projectRule.addBreakpoint()
val debuggerIsHit = checkBreakPointHit(projectRule.project)
setUpMocks()
// run a run configuration
val configuration = EcsCloudDebugRunConfiguration(
projectRule.project,
EcsCloudDebugRunConfigurationProducer.getFactory()
).apply {
beforeRunTasks = mutableListOf(Mockito.mock(BeforeRunTask::class.java))
clusterArn(service.clusterArn())
// TODO: remove this once we fix the UX around which service is debugged
serviceArn(
service.serviceArn().let {
// replace service name with instrumented service name
val instrumentedServiceName = "cloud-debug-${EcsUtils.serviceArnToName(service.serviceArn())}"
it.replace(EcsUtils.serviceArnToName(it), instrumentedServiceName)
}
)
containerOptions(
mapOf(
"ContainerName" to ContainerOptions().apply {
platform = CloudDebuggingPlatform.JVM
startCommand = "java -cp /main.jar Main"
artifactMappings = listOf(ArtifactMapping(jarFile.toString(), "/main.jar"))
}
)
)
}
runUnderRealCredentials(projectRule.project) {
configuration.regionId(projectRule.project.activeRegion().id)
configuration.credentialProviderId(projectRule.project.activeCredentialProvider().id)
configuration.checkConfiguration()
executeRunConfigurationAndWait(configuration, DefaultDebugExecutor.EXECUTOR_ID)
}
// check breakpoint hit
assertThat(debuggerIsHit.get()).isTrue()
}