Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlResource does'nt see the file even if to set up absolute path it #1174

Open
ZuikovAV opened this issue May 31, 2024 · 5 comments
Open

sqlResource does'nt see the file even if to set up absolute path it #1174

ZuikovAV opened this issue May 31, 2024 · 5 comments
Labels
Prio: Medium State: To discuss In case there are open questions concerning the issue Type: Bug

Comments

@ZuikovAV
Copy link

Citrus Version

4.0.0

Expected behavior
sqlResource found the file and executed sql script

Actual behavior
sqlResource does'nt see the file even if to set up absolute path to file

java.lang.AssertionError: Before suite failed with errors

at org.citrusframework.Citrus.beforeSuite(Citrus.java:85)
at org.citrusframework.junit.jupiter.CitrusExtension.beforeAll(CitrusExtension.java:96)
at org.citrusframework.junit.jupiter.spring.CitrusSpringExtension.beforeAll(CitrusSpringExtension.java:67)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllCallbacks$12(ClassBasedTestDescriptor.java:395)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllCallbacks(ClassBasedTestDescriptor.java:395)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:211)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:84)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:148)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)

Caused by: org.citrusframework.exceptions.CitrusRuntimeException: org.citrusframework.exceptions.CitrusRuntimeException: Failed to load classpath resource C:\Users\Admin\Desktop\sqlScripts\sqlScript1.sql - does not exist
at org.citrusframework.container.SequenceBeforeSuite.doExecute(SequenceBeforeSuite.java:54)
at org.citrusframework.actions.AbstractTestAction.execute(AbstractTestAction.java:59)
at org.citrusframework.Citrus.beforeSuite(Citrus.java:79)
... 44 more
Caused by: org.citrusframework.exceptions.CitrusRuntimeException: Failed to load classpath resource C:\Users\Admin\Desktop\sqlScripts\sqlScript1.sql - does not exist

Test case sample
@bean
public SequenceBeforeSuite sequenceBeforeSuite(){

    SequenceBeforeSuite sequenceBeforeSuite = new SequenceBeforeSuite();

    TestAction executeSqlScript = sql()
            .dataSource(dataSource())
                .sqlResource("file:" + "C:\\Users\\Admin\\Desktop\\sqlScripts\\sqlScript1.sql")
            .build();

    sequenceBeforeSuite.addTestAction(executeSqlScript);
    

    return sequenceBeforeSuite;
}

At Windows explorer file can be found by the path. I've mentioned some anonymized data above just for example. 
@ZuikovAV ZuikovAV changed the title sqlResource does'nt see the file even if to set up absolute path to file sqlResource does'nt see the file even if to set up absolute path it May 31, 2024
@ZuikovAV
Copy link
Author

ZuikovAV commented Jun 3, 2024

I've copied file to the project folder from embedded folder to provide a pure test. I've tried to set up the following ways:
1)"file:" + "fileName"
2)"file:" + absolute file path

but the result was the same.

At the same time on version of citrus 2.8.0 it works fine

testRunner.sql(action -> action.dataSource(dataSource).sqlResource("file:" + "fileName"));

@bbortt bbortt added State: To discuss In case there are open questions concerning the issue Type: Bug Prio: Medium labels Jun 3, 2024
@ZuikovAV
Copy link
Author

ZuikovAV commented Jun 3, 2024

@bbortt hello! Is this really a bug or maybe i've done something not so correct?

@bbortt
Copy link
Collaborator

bbortt commented Jun 4, 2024

needs investigation for sure. but I'll have a look if I find some time 😉

@christophd
Copy link
Member

@ZuikovAV yes, this seems to be a regression introduced in Citrus 4.x. Thanks for reporting!

As a workaround you can use:

TestAction executeSqlScript = sql()
            .dataSource(dataSource())
                .sqlResource(Resources.fromFileSystem("C:\\Users\\Admin\\Desktop\\sqlScripts\\sqlScript1.sql"))
            .build();

Uses org.citrusframework.spi.Resources utility class

@ZuikovAV
Copy link
Author

@christophd @bbortt ths for the response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Prio: Medium State: To discuss In case there are open questions concerning the issue Type: Bug
Projects
None yet
Development

No branches or pull requests

3 participants