How can I launch a javaws application with FEST?

444 views
Skip to first unread message

Eva

unread,
Jun 27, 2013, 2:05:10 PM6/27/13
to easyt...@googlegroups.com
I am trying to test an application that is launched via a jnlp file.
How can I start this application with FEST?

Eva

unread,
Jun 28, 2013, 12:16:13 PM6/28/13
to easyt...@googlegroups.com
I was trying the following, after downloading the file locally:
 
public class JnlpStart {

    public static void main(String[] s) throws IOException, ParseException {
        //Desktop launcher
        Desktop desktop = Desktop.getDesktop();

        try {
            desktop.open(new File("C:/Users/username/Downloads/clcmainwbDev.jnlp"));
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
}

This class will be invoked from: 

public class MainFrameTest {

    private FrameFixture window;
    private Robot robot;

    @BeforeClass
    public static void setUpOnce() {
        FailOnThreadViolationRepaintManager.install();
    }

    @Before
    public void setUp() throws Exception{
        ApplicationLauncher.application(JnlpStart.class).start();
        robot = BasicRobot.robotWithCurrentAwtHierarchy();
        robot.settings().delayBetweenEvents(50);
        robot.waitForIdle();

        window = findFrame(new GenericTypeMatcher<Frame>(Frame.class) {
            protected boolean isMatching(Frame frame) {
                return frame.getTitle().contains("CLC Main Workbench") && frame.isShowing();
            }
        }).using(robot);
}

The problem is that the hierarchy of the robot is empty and therefore, nothing is found as the FrameFixture from which to further test.

Also, I tried:
public class JnlpStart {

    public static void main(String[] s){
        Process startApplication = Runtime.getRuntime().exec("javaws -Xnosplash \"http:\\myjnlpfilepath.jnlp\"");
    }
}
But I encountered the same problem, empty hierarchy!

Martin Ginkel

unread,
Jul 9, 2013, 3:51:54 AM7/9/13
to easyt...@googlegroups.com
Hi Eva,

the approach you mentioned will not work because you are launching a
new JVM with your JNLP-file.
But the FEST controller for working with the GUI needs to run in the
same JVM as the production code.

We are running our applications with JNLP in production mode, but we
can launch the very same Main classes for testing
purposes in normal Java As one would normally do from the IDE, java
-cp ... the.package.MainClass .
Then we can test the applications with FEST running in the same VM. I
think this is the simplest approach.

Launching with JNLP (and all classloaders and restrictions) could
work, if you use a JNLP-trampoline class:
You write a java main class and run
com.sun.javaws.Main.main("/path/to/file.jnlp")
But I'm not quite sure, whether the JNLP-Launcher does not fire up yet
another JVM, because it allows to define the
JVM version in the JNLP-File.

Martin

Martin Ginkel

unread,
Jul 9, 2013, 4:03:41 AM7/9/13
to easyt...@googlegroups.com
After reading the whole thread:
You have to disect the JNLP a bit and download all the necessary
JAR-files to your workspace and define a class path with the jars in
the same order.
Within the JNLP you will find a section like this, this is what you
need to translate:
<resources>
<jar href="dom4j.jar"/>
<jar href="jython.jar"/>
<jar href="jhall.jar"/>
</resources>

The next section defines your main class:

<application-desc main-class="package.name.MainClass">
<argument>command_line_argument1=bla</argument>
<argument>command_line_argument2=blu</argument>
</application-desc>

In your test you should reference the same MainClass and call the
MainClass.main(new String[]{"command_line_argument1=bla",
"command_line_argument2=blu"}).
This should fire up your main class inside your JVM.

Martin

Eva

unread,
Jul 9, 2013, 2:32:38 PM7/9/13
to easyt...@googlegroups.com, martin...@web.de, martin...@googlemail.com
Thank you Martin,

the dissection/reconstruction of the jnlp file and including the classes in the path is what we are trying to do.
The main issue with this approach is that we do not have direct access to the main program production code, only to the production plugins code.

I was also exploring using the netx library solution (and accompanying patch) proposed somewhere in the FEST site a long time ago. However, the latest version of this library does not support jnlp 1.5 only 1.0.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages