linghengqian commented on issue #29657:
URL:
https://github.com/apache/shardingsphere/issues/29657#issuecomment-1913659844
- To be honest, I hit a limitation of Java itself while trying to write a
unit test for `System.getenv()`. Of course I know that `System.getenv()` almost
certainly serves the usage process of Docker Image.
- `@org.junitpioneer.jupiter.SetEnvironmentVariable` of
`org.junit-pioneer:junit-pioneer:2.2.0` requires additional `--add-open` for
`maven-surefire-plugin` on JDK21, which This is something I hope to avoid at
this stage because it involves questionable changes on the JDK22-ea milestone.
- `uk.org.webcompere:system-stubs-jupiter:2.1.6` will break
ShardingSphere's unit test CI for JDK8 because it uses JDK11's bytecode.
- `com.github.stefanbirkner:system-rules:1.19.0` and
`com.github.stefanbirkner:system-lambda:1.2.1` will break ShardingSphere's unit
test CI for JDK17+. They lack maintenance.
- For Mockito 4, I personally don't think the method of `Mockito.spy` is
appropriate, and doing `Mockito.spy` on `ShardingSphereURLManager` is too
weird. Of course we can do this, but unit testing will look a lot more obscure.
- It's hard for me to imagine that there will be a good way to simulate
environment variables on JDK8-JDK21 before ShardingSphere improves the JDK
baseline to JDK11. Yes, the runtime requirement for ShardingSphere has always
been JDK8.
- Rather than using `Environment Variables`(`System.getenv()`), I personally
prefer to use `System Property Variables`(`System.getProperty()`). I anticipate
adjusting the final outcome in this direction. Another idea is to set
`Args`/`buildArgs` directly on the ShardingSphere URL string.
- The regular expression of `\$\$\{(.+?)\}$` also looks good. Although more
can be restricted. Expecting a match like
```yaml
dataSources:
ds_0:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.h2.Driver
jdbcUrl: $${FIXTURE_JDBC_URL:jdbc:h2:mem:foo_ds_do_not_use}
username: sa
password:
```
- I'm still organizing a PR for this issue. But my vacations are always full
of fun things to distract me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]