有些奇怪,但是突然之间(例如,我的验收测试套件运行良好,并且我正忙于进行一些无关的*单元测试),当我开始在测试运行中复制资源失败时。
Failed to copy /org/demo/foo/../../../concordion.css to target [Resource: /org/demo/foo/../../../concordion.css]
java.lang.RuntimeException: Failed to copy /org/demo/foo/../../../concordion.css to target [Resource: /org/demo/foo/../../../concordion.css]
at org.concordion.internal.ConcordionBuilder.copyResources(ConcordionBuilder.java:354)
at org.concordion.internal.ConcordionBuilder.build(ConcordionBuilder.java:307)
at org.concordion.internal.FixtureRunner.<init>(FixtureRunner.java:21)
at org.concordion.integration.junit4.ConcordionRunner.<init>(ConcordionRunner.java:62)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:78)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:66)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy1.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:155)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:137)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.FileNotFoundException: /var/folders/wg/3nnv2yf90914pqpx69wmd9cc0000gn/T/concordion/org/demo/foo/../../../concordion.css (No such file or directory)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
at org.concordion.internal.FileTarget.createOutputStream(FileTarget.java:72)
at org.concordion.internal.FileTarget.copyTo(FileTarget.java:35)
at org.concordion.internal.ConcordionBuilder.copyResources(ConcordionBuilder.java:352)
... 43 more
我在IntelliJ IDEA和终端运行gradle中得到了它。
我的测试都以类似于以下内容的方式开始:
@RunWith(ConcordionRunner.class)
@ConcordionResources(value = { "../../../concordion.css" })
public class Index {
}
...并且.css
文件始终位于文件源树中。我检查了打开的手柄,并在重建之前清洗了所有东西。文件夹权限似乎很好。所讨论的/var
文件夹确实为空。
有什么想法吗?
*我认为
更新:在Mac和Linux上,如果分别删除/var/folders/../concordion
或/tmp/concordion
,则会重现该问题。
答案 0 :(得分:0)
问题在于Concordion的FileTarget#createOutputStream(Resource)
方法无法创建OutputStream
来写入资源。
假设您的装置位于a.b.c
包中,Concordion尝试为文件OutputStream
(其中"<concordion.output.dir>/a/b/c/../../../concordion.css"
是concorordion输出目录)创建一个<concordion.output.dir>
。如果"<concordion.output.dir>/a/b/c/"
文件夹尚不存在,则会失败-看来Java不会自动“规范化”删除“ ..
”的路径。
解决方案是规范化路径(可能使用Path.normalize()
)。
要解决此问题,您可以更新到应立即可用的2.2.1版本,也可以使用绝对路径(例如@ConcordionResources("/concordion.css")
)。
答案 1 :(得分:-1)
您是否考虑过文件名或目录大写? Linux是严格的,而Mac在文件名大写方面很奇怪。
蒂姆