Spring-boot Test to load external jars (equivalent of loader.path)










5















We have an application which has runtime dependencies on external jars (e.g Talend jobs running within Spring-boot). Now we're able to get this launched from Spring-Boot using the -Dloader.path argument. However, we're unable to run integration-test using the external lib folder (i.e launch Talend jobs from Spring-Boot Test). Is it possible to have a similar option to load external jobs for integration-tests using SpringBoot test?










share|improve this question






















  • Did you try @SpringBootTest(value="loader.path=/your/path"). or adding loader.path=/your/path in different spring profile for testing i.e. different application-profile.yml, or adding -Dloader.path=/your/path in VM arguments when you launch your test ?

    – rdj7
    Nov 15 '18 at 10:38












  • No. both of them don't work. It seems to do with the launcher - we need a test launcher which is similar to the PropertyLauncher.

    – Jebuselwyn Martin
    Nov 19 '18 at 7:40











  • How are you running the unit tests? JUnit? Also is there a valid reason not to include this external Jar file in your Maven/Gradle file?

    – Shankar P S
    Nov 20 '18 at 18:53















5















We have an application which has runtime dependencies on external jars (e.g Talend jobs running within Spring-boot). Now we're able to get this launched from Spring-Boot using the -Dloader.path argument. However, we're unable to run integration-test using the external lib folder (i.e launch Talend jobs from Spring-Boot Test). Is it possible to have a similar option to load external jobs for integration-tests using SpringBoot test?










share|improve this question






















  • Did you try @SpringBootTest(value="loader.path=/your/path"). or adding loader.path=/your/path in different spring profile for testing i.e. different application-profile.yml, or adding -Dloader.path=/your/path in VM arguments when you launch your test ?

    – rdj7
    Nov 15 '18 at 10:38












  • No. both of them don't work. It seems to do with the launcher - we need a test launcher which is similar to the PropertyLauncher.

    – Jebuselwyn Martin
    Nov 19 '18 at 7:40











  • How are you running the unit tests? JUnit? Also is there a valid reason not to include this external Jar file in your Maven/Gradle file?

    – Shankar P S
    Nov 20 '18 at 18:53













5












5








5








We have an application which has runtime dependencies on external jars (e.g Talend jobs running within Spring-boot). Now we're able to get this launched from Spring-Boot using the -Dloader.path argument. However, we're unable to run integration-test using the external lib folder (i.e launch Talend jobs from Spring-Boot Test). Is it possible to have a similar option to load external jobs for integration-tests using SpringBoot test?










share|improve this question














We have an application which has runtime dependencies on external jars (e.g Talend jobs running within Spring-boot). Now we're able to get this launched from Spring-Boot using the -Dloader.path argument. However, we're unable to run integration-test using the external lib folder (i.e launch Talend jobs from Spring-Boot Test). Is it possible to have a similar option to load external jobs for integration-tests using SpringBoot test?







spring-boot talend spring-boot-test






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 '18 at 6:25









Jebuselwyn MartinJebuselwyn Martin

299313




299313












  • Did you try @SpringBootTest(value="loader.path=/your/path"). or adding loader.path=/your/path in different spring profile for testing i.e. different application-profile.yml, or adding -Dloader.path=/your/path in VM arguments when you launch your test ?

    – rdj7
    Nov 15 '18 at 10:38












  • No. both of them don't work. It seems to do with the launcher - we need a test launcher which is similar to the PropertyLauncher.

    – Jebuselwyn Martin
    Nov 19 '18 at 7:40











  • How are you running the unit tests? JUnit? Also is there a valid reason not to include this external Jar file in your Maven/Gradle file?

    – Shankar P S
    Nov 20 '18 at 18:53

















  • Did you try @SpringBootTest(value="loader.path=/your/path"). or adding loader.path=/your/path in different spring profile for testing i.e. different application-profile.yml, or adding -Dloader.path=/your/path in VM arguments when you launch your test ?

    – rdj7
    Nov 15 '18 at 10:38












  • No. both of them don't work. It seems to do with the launcher - we need a test launcher which is similar to the PropertyLauncher.

    – Jebuselwyn Martin
    Nov 19 '18 at 7:40











  • How are you running the unit tests? JUnit? Also is there a valid reason not to include this external Jar file in your Maven/Gradle file?

    – Shankar P S
    Nov 20 '18 at 18:53
















Did you try @SpringBootTest(value="loader.path=/your/path"). or adding loader.path=/your/path in different spring profile for testing i.e. different application-profile.yml, or adding -Dloader.path=/your/path in VM arguments when you launch your test ?

– rdj7
Nov 15 '18 at 10:38






Did you try @SpringBootTest(value="loader.path=/your/path"). or adding loader.path=/your/path in different spring profile for testing i.e. different application-profile.yml, or adding -Dloader.path=/your/path in VM arguments when you launch your test ?

– rdj7
Nov 15 '18 at 10:38














No. both of them don't work. It seems to do with the launcher - we need a test launcher which is similar to the PropertyLauncher.

– Jebuselwyn Martin
Nov 19 '18 at 7:40





No. both of them don't work. It seems to do with the launcher - we need a test launcher which is similar to the PropertyLauncher.

– Jebuselwyn Martin
Nov 19 '18 at 7:40













How are you running the unit tests? JUnit? Also is there a valid reason not to include this external Jar file in your Maven/Gradle file?

– Shankar P S
Nov 20 '18 at 18:53





How are you running the unit tests? JUnit? Also is there a valid reason not to include this external Jar file in your Maven/Gradle file?

– Shankar P S
Nov 20 '18 at 18:53












1 Answer
1






active

oldest

votes


















0














I got this sorted.



Intellij -> Select Module -> Open Module Setting -> Dependency -> Add Dependency -> select the external jar -> Scope to be test only.



This way it is working fine for test case and at the same time not being used in actual main code.



Where to keep the jar ?



Given its going to be used in test cases, I would suggest commit the jar in src/test/lib and select this path while adding dependency.



Intellij generate the .iml file(which has a list of dependency) if you commit the same in your repo then other team member can easily use without any further setup.



Now question remains for linux env or CIT environment. I think we could add this jar via CLASSPATH env variable and then starting any CIT jobs.



Mix of solution but then its working as expected for me.



One more solution :
Install the external jar in local repo and add dependency in pom.xml with test scope. Easy option it is.



Installing jar on local repo :



<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>3.0.0-M1</version>
<executions>
<execution>
<id>install-jar</id>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>$project.basedir/src/test/lib/somejar-1.0.jar</file>
<groupId>com.beta.gamma</groupId>
<artifactId>somejar</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
</configuration>
</execution>
<executions>
</plugin>


Now same can be added as dependency as other dependency. This will work on environments.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256883%2fspring-boot-test-to-load-external-jars-equivalent-of-loader-path%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I got this sorted.



    Intellij -> Select Module -> Open Module Setting -> Dependency -> Add Dependency -> select the external jar -> Scope to be test only.



    This way it is working fine for test case and at the same time not being used in actual main code.



    Where to keep the jar ?



    Given its going to be used in test cases, I would suggest commit the jar in src/test/lib and select this path while adding dependency.



    Intellij generate the .iml file(which has a list of dependency) if you commit the same in your repo then other team member can easily use without any further setup.



    Now question remains for linux env or CIT environment. I think we could add this jar via CLASSPATH env variable and then starting any CIT jobs.



    Mix of solution but then its working as expected for me.



    One more solution :
    Install the external jar in local repo and add dependency in pom.xml with test scope. Easy option it is.



    Installing jar on local repo :



    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-install-plugin</artifactId>
    <version>3.0.0-M1</version>
    <executions>
    <execution>
    <id>install-jar</id>
    <phase>initialize</phase>
    <goals>
    <goal>install-file</goal>
    </goals>
    <configuration>
    <file>$project.basedir/src/test/lib/somejar-1.0.jar</file>
    <groupId>com.beta.gamma</groupId>
    <artifactId>somejar</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    </configuration>
    </execution>
    <executions>
    </plugin>


    Now same can be added as dependency as other dependency. This will work on environments.






    share|improve this answer





























      0














      I got this sorted.



      Intellij -> Select Module -> Open Module Setting -> Dependency -> Add Dependency -> select the external jar -> Scope to be test only.



      This way it is working fine for test case and at the same time not being used in actual main code.



      Where to keep the jar ?



      Given its going to be used in test cases, I would suggest commit the jar in src/test/lib and select this path while adding dependency.



      Intellij generate the .iml file(which has a list of dependency) if you commit the same in your repo then other team member can easily use without any further setup.



      Now question remains for linux env or CIT environment. I think we could add this jar via CLASSPATH env variable and then starting any CIT jobs.



      Mix of solution but then its working as expected for me.



      One more solution :
      Install the external jar in local repo and add dependency in pom.xml with test scope. Easy option it is.



      Installing jar on local repo :



      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-install-plugin</artifactId>
      <version>3.0.0-M1</version>
      <executions>
      <execution>
      <id>install-jar</id>
      <phase>initialize</phase>
      <goals>
      <goal>install-file</goal>
      </goals>
      <configuration>
      <file>$project.basedir/src/test/lib/somejar-1.0.jar</file>
      <groupId>com.beta.gamma</groupId>
      <artifactId>somejar</artifactId>
      <version>1.0</version>
      <packaging>jar</packaging>
      </configuration>
      </execution>
      <executions>
      </plugin>


      Now same can be added as dependency as other dependency. This will work on environments.






      share|improve this answer



























        0












        0








        0







        I got this sorted.



        Intellij -> Select Module -> Open Module Setting -> Dependency -> Add Dependency -> select the external jar -> Scope to be test only.



        This way it is working fine for test case and at the same time not being used in actual main code.



        Where to keep the jar ?



        Given its going to be used in test cases, I would suggest commit the jar in src/test/lib and select this path while adding dependency.



        Intellij generate the .iml file(which has a list of dependency) if you commit the same in your repo then other team member can easily use without any further setup.



        Now question remains for linux env or CIT environment. I think we could add this jar via CLASSPATH env variable and then starting any CIT jobs.



        Mix of solution but then its working as expected for me.



        One more solution :
        Install the external jar in local repo and add dependency in pom.xml with test scope. Easy option it is.



        Installing jar on local repo :



        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-install-plugin</artifactId>
        <version>3.0.0-M1</version>
        <executions>
        <execution>
        <id>install-jar</id>
        <phase>initialize</phase>
        <goals>
        <goal>install-file</goal>
        </goals>
        <configuration>
        <file>$project.basedir/src/test/lib/somejar-1.0.jar</file>
        <groupId>com.beta.gamma</groupId>
        <artifactId>somejar</artifactId>
        <version>1.0</version>
        <packaging>jar</packaging>
        </configuration>
        </execution>
        <executions>
        </plugin>


        Now same can be added as dependency as other dependency. This will work on environments.






        share|improve this answer















        I got this sorted.



        Intellij -> Select Module -> Open Module Setting -> Dependency -> Add Dependency -> select the external jar -> Scope to be test only.



        This way it is working fine for test case and at the same time not being used in actual main code.



        Where to keep the jar ?



        Given its going to be used in test cases, I would suggest commit the jar in src/test/lib and select this path while adding dependency.



        Intellij generate the .iml file(which has a list of dependency) if you commit the same in your repo then other team member can easily use without any further setup.



        Now question remains for linux env or CIT environment. I think we could add this jar via CLASSPATH env variable and then starting any CIT jobs.



        Mix of solution but then its working as expected for me.



        One more solution :
        Install the external jar in local repo and add dependency in pom.xml with test scope. Easy option it is.



        Installing jar on local repo :



        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-install-plugin</artifactId>
        <version>3.0.0-M1</version>
        <executions>
        <execution>
        <id>install-jar</id>
        <phase>initialize</phase>
        <goals>
        <goal>install-file</goal>
        </goals>
        <configuration>
        <file>$project.basedir/src/test/lib/somejar-1.0.jar</file>
        <groupId>com.beta.gamma</groupId>
        <artifactId>somejar</artifactId>
        <version>1.0</version>
        <packaging>jar</packaging>
        </configuration>
        </execution>
        <executions>
        </plugin>


        Now same can be added as dependency as other dependency. This will work on environments.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 22 '18 at 6:01

























        answered Nov 21 '18 at 20:54









        bittubittu

        367110




        367110





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256883%2fspring-boot-test-to-load-external-jars-equivalent-of-loader-path%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            政党

            天津地下鉄3号線