是否有使用 ant junit 任务的可自定义类加载顺序?
在我们的网络应用程序项目中,我们包含一些 jar 文件。为了修补 jar 文件中某个类的一些问题,我们在补丁源文件夹中更改了该类的实现。
由于tomcat中有一个定义的类加载顺序(WEB-INF/classes在WEB-INF/lib之前),所以tomcat会加载该类的修补版本,而不是jar文件中的原始版本。因此,一旦我们部署了应用程序,一切都会按预期进行。
现在,我们想要从 ant 中针对这个修补过的类运行 junit 测试。因此,我们配置类路径来保存原始 jar 和修补后的类文件。但似乎没有办法告诉 ant 的 junit 任务首先加载已修补的类,而不是 jar 文件中未修补的版本。
有办法解决这个问题吗?有没有办法确定ant的junit任务加载类的顺序?还有其他方法可以从 ant 测试我们的修补类吗?
in our web-app project, we include some jar files. For patching some issues of one of the classes in a jar file, we changed the implemention of this class in a patches source folder.
Since there is a defined class loading order in tomcat (WEB-INF/classes before WEB-INF/lib), the patched version of the class is loaded by tomcat, not the original one in the jar file. So, as soon as we deploy our application, everything works as expected.
Now, we want to run junit tests from ant against this patched class. So we configure the class path to hold both, the original jar and the patched class file. But there seems to be no way to tell the ant's junit task to first load the patched class, not the unpatched version from the jar file.
Is there a way to get around the problem? Is there a way to determine the order in which the classes are loaded by ant's junit task? Is there any other way to test our patched class from ant?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为 ant 类路径的工作方式就像标准 Java 类路径一样。按照声明路径的顺序搜索类路径,并从找到的第一个路径加载类。
junit 任务的类路径元素应该类似于:
I think an ant classpath works just like the standard Java classpath. The classpath is searched in the order that paths are declared and a class is loaded from the first path where it is found.
Your classpath element for your junit task should be something like: