Skip to content

Commit

Permalink
[Testing][JShellAPI] Settings up gradle tasks for testing; ;
Browse files Browse the repository at this point in the history
Note: this includes adding a 1st class for tests;
  • Loading branch information
firasrg committed Aug 10, 2024
1 parent daddfe9 commit 9dc586e
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 3 deletions.
58 changes: 55 additions & 3 deletions JShellAPI/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,27 @@ dependencies {
implementation 'com.github.docker-java:docker-java-transport-httpclient5:3.3.6'
implementation 'com.github.docker-java:docker-java-core:3.3.6'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
configurations {
all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
exclude group: 'ch.qos.logback', module: 'logback-classic'
exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j'
}
}
}
testImplementation gradleTestKit()

annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"

}

def imageName = 'togetherjava.org:5001/togetherjava/jshellbackend:master' ?: 'latest';

jib {
from.image = 'eclipse-temurin:21'
to {
image = 'togetherjava.org:5001/togetherjava/jshellbackend:master' ?: 'latest'
image = imageName
auth {
username = System.getenv('ORG_REGISTRY_USER') ?: ''
password = System.getenv('ORG_REGISTRY_PASSWORD') ?: ''
Expand All @@ -36,4 +49,43 @@ shadowJar {
archiveBaseName.set('JShellPlaygroundBackend')
archiveClassifier.set('')
archiveVersion.set('')
}
}

tasks.register('buildDockerImage') {
group = 'Docker'
description = 'builds jshellwrapper as docker image'
dependsOn jibDockerBuild
doFirst{
println('creating docker image...')
}
doLast{
println('docker image is ready for use')
}
}

tasks.register('removeDockerImage', Exec) {
group = 'Docker'
description = 'removes jshellwrapper image'
commandLine 'docker', 'rmi', '-f', imageName
doLast{
println('docker image has been removed')
}
}

tasks.named('test') {
dependsOn tasks.named('buildDockerImage')

doFirst {
try {
println 'Running JShellAPI tests...'
} catch (Exception e) {
println 'JShellAPI tests failed'
tasks.named('removeDockerImage').get().execute()
throw e
}
}
doLast {
println 'JShellAPI tests completed.'
}
finalizedBy tasks.named('removeDockerImage')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.togetherjava.jshellapi;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import static org.assertj.core.api.Assertions.assertThat;

// TODO - write some integrations
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class JShellApiTests {

@Test
public void test() {
assertThat(true).isTrue();
}
}

0 comments on commit 9dc586e

Please sign in to comment.