Conversation
# Conflicts: # lib/cds-test.js
Split test/app into test/node-app (pure Node, no pom.xml) and test/java-app (minimal Spring Boot app for java.js integration tests). The pom.xml presence in test/app was causing CDS's project-nature detection to activate the java profile for all tests, replacing cds.exec with the Java launcher even in Node-only CI environments. - git mv test/app → test/node-app; Java files → test/java-app - Add test/java-app with minimal bookshop model and sample-java.it.js - Add .github/workflows/java.yml (SAP Machine JDK 21, Maven cache) - sample-java.it.js uses .it.js suffix to stay out of chest discovery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on original changes from @BobdenOs fork: https://github.com/BobdenOs/cds-test/tree/feat/java
Description
This PR adds the "run tests against a CAP Java app" feature, based on the changes from the fork linked above.
Requirements
Running
cds-testtests against a Java app requires:cds.qlwork)cds.entities(...)work)The goal must be to create a developer experience, where there is no distinguishable difference between writing tests for a node app and writing tests for a java app - as long as the two apps share the same
.cdsmodel. Additionally, the test setup must be easy to comprehend, robust and reliable. Developers must be able to trust their test setup explicitly; i.e. it must not introduce unnecessary obfuscation; it must be easy to prove that the test setup it-self isn't the root cause of test failures.Solution
This PR introduces a Java "run-mode". This mode will be selected in environments where
cds.env.profiles.includes('java'). Selecting the java runner will causecds.execto be overridden for thecds.test(...)run.The overridden
execwill:cds.rootbased onartifactidfrompom.xml@hcqlbaseddbProxyservice into the Java app-runtime modelcds.linkedmodel that will become part ofschema-h2.sqlcds.env.requires.dbin the test-runtime ...java-hcql.js) that will intercept all queries sent todbduringcds.test(...)and route them to thedbProxywe injected into the Java app-runtimecds.modelof the test runtime, to include.draftsand make them accessible viacds.entities(db.schema.namespace.activeEntity.drafts)sequenceDiagram participant W as test-worker participant J as java.js participant Lock as .mvn-build.lock participant H as java-hcql.js participant App as CAP Java App participant DB as Java H2 Note over W,App: Setup — serialized across parallel workers W->>J: cds.exec() J->>Lock: open('wx') [exclusive create — polls every 500ms until free] Lock-->>J: acquired J->>J: buildDatabaseProxy() → dbProxy CSN alt model changed or JAR absent J->>App: mvn package -DskipTests App-->>J: JAR ready end J->>Lock: unlink() [finally — always released] J->>App: java -jar app-exec.jar --server.port=N App-->>J: HTTP 200 (startup ping) J->>J: cds.env.requires.db = java-hcql.js J->>H: cds.connect.to('db') J-->>W: { server, url } Note over W,DB: Test execution W->>H: req.query (original entity names) H->>H: JSON-serialize → regex-rewrite all entity name positions via proxyMap H->>H: normalize null comparisons H->>App: POST /hcql/dbProxy App->>DB: SQL DB-->>App: rows App-->>H: { data: [...] } H-->>W: result Note over W,App: Cleanup — cds.shutdown() in after() hook W->>W: delete cds.services.db + cds.db W->>App: app.kill() App-->>W: exit [awaited unless CDS_ENV_TEST_SKIP_AWAIT_SHUTDOWN]I updated the directory structure of
testto separatejava,nodeandcds-testtests cleanly.Implementation Details
Updated
testdirectory structureSpecific changes compared to https://github.com/BobdenOs/cds-test/tree/feat/java
db->dbProxy.drafts,.textsgapjava.jsto re-compile only when a model change is detected; will not switch to spring-bootDRAFT.DraftAdministrativeDatawhen required to enableINSERT.info(Entity.drafts)up_filter for children of managed compositions indata.reset.Notes
compile/for/lean_draftsvscds-compiler/lib/transform/draft/odatacds.ql:SELECT.localized/healthafterEach?