Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Jubula » executable jar with datafiles for Jubula(executable jar with datafiles for Jubula)
executable jar with datafiles for Jubula [message #890057] Wed, 20 June 2012 21:11 Go to next message
Samantha Guillot is currently offline Samantha GuillotFriend
Messages: 4
Registered: April 2012
Junior Member
Hello,
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?
Re: executable jar with datafiles for Jubula [message #890360 is a reply to message #890057] Fri, 22 June 2012 06:36 Go to previous messageGo to next message
Alexandra Schladebeck is currently offline Alexandra SchladebeckFriend
Messages: 1613
Registered: July 2009
Senior Member
Hi,

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
Re: executable jar with datafiles for Jubula [message #891976 is a reply to message #890360] Tue, 26 June 2012 18:03 Go to previous messageGo to next message
Samantha Guillot is currently offline Samantha GuillotFriend
Messages: 4
Registered: April 2012
Junior Member
I've tried running the AUT from the command line. All it does tell me is that it cannot find the file because it's not looking inside the jar file. It needs to read entire files not just arguments.

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.

Re: executable jar with datafiles for Jubula [message #892409 is a reply to message #891976] Thu, 28 June 2012 07:22 Go to previous messageGo to next message
Alexandra Schladebeck is currently offline Alexandra SchladebeckFriend
Messages: 1613
Registered: July 2009
Senior Member
Hi,

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
Re: executable jar with datafiles for Jubula [message #903088 is a reply to message #892409] Tue, 21 August 2012 21:33 Go to previous messageGo to next message
Samantha Guillot is currently offline Samantha GuillotFriend
Messages: 4
Registered: April 2012
Junior Member
Okay I found the solution. Apparently it's not a Jubula issue. 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.

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 ) ) ;
Re: executable jar with datafiles for Jubula [message #903992 is a reply to message #903088] Mon, 27 August 2012 14:06 Go to previous messageGo to next message
Alexandra Schladebeck is currently offline Alexandra SchladebeckFriend
Messages: 1613
Registered: July 2009
Senior Member
Hi Samantha,

Thanks for posting the solution!

Best regards,
Alex
Re: executable jar with datafiles for Jubula [message #1203106 is a reply to message #903088] Fri, 22 November 2013 13:31 Go to previous message
John Smither is currently offline John SmitherFriend
Messages: 2
Registered: January 2013
Junior Member
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. Sad How can I fake it?

[Updated on: Fri, 22 November 2013 13:33]

Report message to a moderator

Previous Topic:How to link JaCoCo eclipse plugin with Jubula eclipse plugin
Next Topic:Standalone 7.2 incompatibility with Eclipse plugin
Goto Forum:
  


Current Time: Tue Apr 16 05:49:47 GMT 2024

Powered by FUDForum. Page generated in 0.44464 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top