[ 
https://issues.apache.org/jira/browse/KARAF-6877?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17331286#comment-17331286
 ] 

Vassil Zorev edited comment on KARAF-6877 at 4/24/21, 5:44 PM:
---------------------------------------------------------------

Sorry, didn't get it :(

{{That's what i got so far:}}

{{KarafTestSupport#private void executeInitScript(Session session) {}}
 {{        // possibly all scripts in karaf.shell.init.script}}
 {{        final Path initScript = Paths.get(System.getProperty("karaf.etc") + 
"/shell.init.script");}}
 {{        try {}}
 {{            String script = String.join("\n",}}
 {{                    Files.readAllLines(initScript));}}
 {{            session.execute(script);}}
 {{        } catch (Exception e) {}}
 {{            System.err.println("Error in initialization script: " + 
e.getMessage());}}
 {{            e.printStackTrace();}}

                }

}

{{KarafTestSupport#public String executeAlias(String alias, final Long timeout, 
final Boolean silent, final Principal ... principals) (or adjust the 
executeCommand() method itself...)}}
 {
 {{        String response;}}
 {{        final ByteArrayOutputStream byteArrayOutputStream = new 
ByteArrayOutputStream();}}
 {{        final PrintStream printStream = new 
PrintStream(byteArrayOutputStream);}}
 {{        final SessionFactory sessionFactory = 
getOsgiService(SessionFactory.class);}}
 {{        final Session session = sessionFactory.create(System.in, 
printStream, System.err);}}

{{        executeInitScript(session);}}

{{        String targetCommand = alias => cmd; // that's the part i don't get, 
how can this happen ?}}
 {{        waitForCommandService(targetCommand); // is this needed here at all 
? otherwise there's no need to try to get the target command above}}

{{        final Callable<String> commandCallable = () -> {}}
 {{        ...}}
 {{}}}

Regards,

Vassil


was (Author: vassilz):
Sorry, didn't get it :(

{{That's what i got so far:}}

{{KarafTestSupport#private void executeInitScript(Session session) {}}
{{        // possibly all scripts in karaf.shell.init.script}}
{{        final Path initScript = Paths.get(System.getProperty("karaf.etc") + 
"/shell.init.script");}}
{{        try {}}
{{            String script = String.join("\n",}}
{{                    Files.readAllLines(initScript));}}
{{            session.execute(script);}}
{{        } catch (Exception e) {}}
{{            System.err.println("Error in initialization script: " + 
e.getMessage());}}
{{            e.printStackTrace();}}
{{        }}}
{{    }}}

{{KarafTestSupport#public String executeAlias(String alias, final Long timeout, 
final Boolean silent, final Principal ... principals) (or adjust the 
executeCommand() method itself...)}}
{{{}}
{{        String response;}}
{{        final ByteArrayOutputStream byteArrayOutputStream = new 
ByteArrayOutputStream();}}
{{        final PrintStream printStream = new 
PrintStream(byteArrayOutputStream);}}
{{        final SessionFactory sessionFactory = 
getOsgiService(SessionFactory.class);}}
{{        final Session session = sessionFactory.create(System.in, printStream, 
System.err);}}

{{        executeInitScript(session);}}

{{        String targetCommand = alias => cmd; // that's the part i don't get, 
how can this happen ?}}
{{        waitForCommandService(targetCommand); // is this needed here at all ? 
otherwise there's no need to try to get the target command above}}

{{        final Callable<String> commandCallable = () -> {}}
{{        ...}}
{{}}}

Regards,

Vassil

> Itest doesn't see alias command
> -------------------------------
>
>                 Key: KARAF-6877
>                 URL: https://issues.apache.org/jira/browse/KARAF-6877
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf
>            Reporter: Jean-Baptiste Onofré
>            Priority: Major
>
> When executing an alias (defined in {{etc/shell.init.script}}) in an itest 
> (using {{executeCommand()}} for instance), the command is not found.
> The alias should be loaded.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to