Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forumsexecutable jar with datafiles for Jubula
https://www.eclipse.org/forums/index.php/mv/msg/365187/890057/#msg_890057
I've got a project that reads files to plot some data. I've exported an executable jar from eclipse and included the files in my ANT build script. I check the jar when it's complete, and there is a "DataFiles" folder in my jar file containing my data just like in my project on eclipse.
I setup a test suite in Jubula to run my program but it's blank. It plots the background my my data is not there. The AUT says it cannot find my datafiles. The error message makes it look like it's looking for the files in the folder where I put my *.cmd and *.jar file. Jubula is not looking inside the jar file itself for the files.
Are there some special instructions I need to give Jubula to tell it where my files are located inside the jar file? How do I point Jubula to the right place to look?
]]>Samantha Guillot2012-06-20T21:11:27-00:00Re: executable jar with datafiles for Jubula
https://www.eclipse.org/forums/index.php/mv/msg/365187/890360/#msg_890360
Without knowing more details, my suggestion would be to configure the AUT so that it starts the application as you would via the command line (i.e. if you have to enter parameters for the AUT, then these would go in the AUT arguments. If your working directory is set to the wrong place for your setup, this could also explain the looking in the wrong place.
Alternatively, you can create a cmd file that does everything it needs and use this in the Executable field (not he Jar field) in the AUT configuration.
HTH,
Alex]]>Alexandra Schladebeck2012-06-22T06:36:17-00:00Re: executable jar with datafiles for Jubula
https://www.eclipse.org/forums/index.php/mv/msg/365187/891976/#msg_891976
Is there a java argument flag to tell it read that particular directory? The ant build script is including the the data that I need.
Here's what the JAR file contents look like:
com
DataFiles
META-INF
org
So all the source code is buried down under the "com" folder. My information is stored under the "DataFiles" folder. I've tried hard-coding into the read statements in java to go up the appropriate number of levels and down the the folder I want like this ../.././DataFiles but that does not work.
I looked at examples and folks are using getInputStreamAsResource to read data files that are under their "src" folder. However my DataFiles are not under my /src folder. My DataFiles are their own folder that's a part of the project but not below src.
So maybe it's not a jubula issue and more a java issue, but I still don't know what to do.
]]>Samantha Guillot2012-06-26T18:03:20-00:00Re: executable jar with datafiles for Jubula
https://www.eclipse.org/forums/index.php/mv/msg/365187/892409/#msg_892409
This isn't something I've come across before I'm afraid. Maybe someone else in the community knows a bit (a lot!) more about Java than I do and can help more. The only thing I can reiterate here is that if you can start your own AUT (separately from Jubula) from the command line, then there should be a 1:1 mapping between the arguments you enter there, and the things you enter into the AUT configuration dialog. Often it really is easier to (get someone to) write a small .cmd or .sh that you can just double click to start your AUT. If you have something like that, then you can just enter it into the "executable" field in the AUT config.
HTH,
Alex]]>Alexandra Schladebeck2012-06-28T07:22:30-00:00Re: executable jar with datafiles for Jubula
https://www.eclipse.org/forums/index.php/mv/msg/365187/903088/#msg_903088
Even if you are running from the executable jar, you have to open a connection to the jar file like it's a database.
For a given File f, you use the code to find the full path to your jar file and then opens a connection to the jar file. You can then use this connection to create a BufferedReader to read it like any ordinary file. This was not at all intuitive a solution.
final String fName = getPackageStringAsFilePath( "???" ) + File.separator + f.getName() ;
final URL jarUrl = getJarFileUrl( fName ) ;
final JarURLConnection conn = (JarURLConnection)jarUrl.openConnection() ;
final JarFile jarFile = conn.getJarFile() ;
final JarEntry jarEntry = conn.getJarEntry() ;
final InputStream input = jarFile.getInputStream( jarEntry ) ;
return new BufferedReader( new InputStreamReader( input ) ) ;
]]>Samantha Guillot2012-08-21T21:33:47-00:00Re: executable jar with datafiles for Jubula
https://www.eclipse.org/forums/index.php/mv/msg/365187/903992/#msg_903992
Thanks for posting the solution!
Best regards,
Alex]]>Alexandra Schladebeck2012-08-27T14:06:02-00:00Re: executable jar with datafiles for Jubula
https://www.eclipse.org/forums/index.php/mv/msg/365187/1203106/#msg_1203106
Samantha Guillot wrote on Tue, 21 August 2012 17:33
It's a java thing.
Even if you are running from the executable jar, you have to open a connection to the jar file like it's a database.
Before I tried to bundle my program into a jar file, it was using a technique to reap all the filenames in a directory.
File gpacks= new File("dataDir");
File[] fileList= gpacks.listFiles();
Using the solution you propose above, I end up with a JarFile, not a File. I don't see a method anywhere that will let me do what listFiles() does. How can I fake it?
]]>John Smither2013-11-22T13:31:06-00:00