Search in sources :

Example 1 with AScriptTaskMatlab

use of de.invesdwin.context.matlab.runtime.contract.AScriptTaskMatlab in project invesdwin-context-matlab by subes.

the class HelloWorldScript method testHelloWorld.

public void testHelloWorld() {
    final AScriptTaskMatlab<String> script = new AScriptTaskMatlab<String>() {

        @Override
        public void populateInputs(final IScriptTaskInputs inputs) {
            inputs.putString("hello", "World");
        }

        @Override
        public void executeScript(final IScriptTaskEngine engine) {
            // execute this script inline:
            // engine.eval("world = strcat({'Hello '}, hello, '!')");
            // or run it from a file:
            engine.eval(new ClassPathResource(HelloWorldScript.class.getSimpleName() + ".m", getClass()));
        }

        @Override
        public String extractResults(final IScriptTaskResults results) {
            return results.getString("world");
        }
    };
    final String result = script.run(runner);
    Assertions.assertThat(result).isEqualTo("Hello World!");
}
Also used : AScriptTaskMatlab(de.invesdwin.context.matlab.runtime.contract.AScriptTaskMatlab) IScriptTaskEngine(de.invesdwin.context.integration.script.IScriptTaskEngine) ClassPathResource(org.springframework.core.io.ClassPathResource) IScriptTaskInputs(de.invesdwin.context.integration.script.IScriptTaskInputs) IScriptTaskResults(de.invesdwin.context.integration.script.IScriptTaskResults)

Example 2 with AScriptTaskMatlab

use of de.invesdwin.context.matlab.runtime.contract.AScriptTaskMatlab in project invesdwin-context-matlab by subes.

the class HelloWorldScript method testHelloWorld.

public void testHelloWorld() {
    final AScriptTaskMatlab<String> script = new AScriptTaskMatlab<String>() {

        @Override
        public void populateInputs(final IScriptTaskInputs inputs) {
            inputs.putString("hello", "World");
        }

        @Override
        public void executeScript(final IScriptTaskEngine engine) {
            // execute this script inline:
            // engine.eval("world = strcat('Hello ', hello, '!')");
            // or run it from a file:
            engine.eval(new ClassPathResource(HelloWorldScript.class.getSimpleName() + ".sce", getClass()));
        }

        @Override
        public String extractResults(final IScriptTaskResults results) {
            return results.getString("world");
        }
    };
    final String result = script.run(runner);
    Assertions.assertThat(result).isEqualTo("Hello World!");
}
Also used : AScriptTaskMatlab(de.invesdwin.context.matlab.runtime.contract.AScriptTaskMatlab) IScriptTaskEngine(de.invesdwin.context.integration.script.IScriptTaskEngine) ClassPathResource(org.springframework.core.io.ClassPathResource) IScriptTaskInputs(de.invesdwin.context.integration.script.IScriptTaskInputs) IScriptTaskResults(de.invesdwin.context.integration.script.IScriptTaskResults)

Aggregations

IScriptTaskEngine (de.invesdwin.context.integration.script.IScriptTaskEngine)2 IScriptTaskInputs (de.invesdwin.context.integration.script.IScriptTaskInputs)2 IScriptTaskResults (de.invesdwin.context.integration.script.IScriptTaskResults)2 AScriptTaskMatlab (de.invesdwin.context.matlab.runtime.contract.AScriptTaskMatlab)2 ClassPathResource (org.springframework.core.io.ClassPathResource)2