문제

Is it possible to get Package.getImplementationVersion() method available for junits? I am using maven and eclipse. I tried to execute mvn war:manifest to create the manifest file, so I could verify that the Implementation Version is not null.

Currently here is my test unit which is failing:

assertNotNull(Version.class.getPackage().getImplementationVersion());

도움이 되었습니까?

해결책

If you want to verify if the MANIFEST file of the war contains certain fields, a standard unit-test is too early, since the war hasn't been packaged yet. Instead I would write a junit-test for the maven-failsafe-plugin. Now your testclass has to end with IT instead of Test so it is recognized as an integration test by the plugin. Next, find the war-file in the target-directory and read it as a JarFile, so you have direct access to the Manifest. The rest shouldn't be too hard.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top