Re: Problem with maven and deleting files in a test case
Am 15.07.2012 01:19, schrieb Wayne Fay: >> 1. What does the maven-surefire-plugin exactly do? It still fails, but >> not so much like without it. > You were already using Surefire, you just had not declared a specific > version of the plugin to use, so you were probably using an earlier > version that might have had a bug which is resolved in 2.12, or > something along those lines. Ok, I checked this with some more tests playing around with versions. During these test I fall back in a state where the count of occurrence of errors differs again. Well, after digging some more, I think, I know now whats going wrong. Looks like I was trapped because of an old doctrine: Never use space charaters in paths! Maven do everthing well, don't care if I added the surefire snipplet or not. But eclipse don't do. So further discussions goes to another list. ;) If someone else is interested, I posted a bug-report at eclipse bugzilla (ID 385223). It can be found here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=385223 >> 2. Is there a way to avoid running tests with maven depends on the OS if >> I reach a level where >> no independent solution exists like loading a C-lib for example, don't >> care if it is a good idea? > Stephen already answered this one. Add code which tests for the OS and > bails (with a warning) if this test cannot be executed in the current > OS. Checked this too. That's what I am looking for and it works perfect after a little tweaking and customizing. And for those guys, that reached this thread to get a solution for the I/O problem, which wasn't part of this thread, should take a look at package java.nio.file. It is available since 1.7. Thanks guys! - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Problem with maven and deleting files in a test case
> 1. What does the maven-surefire-plugin exactly do? It still fails, but > not so much like without it. You were already using Surefire, you just had not declared a specific version of the plugin to use, so you were probably using an earlier version that might have had a bug which is resolved in 2.12, or something along those lines. > 2. Is there a way to avoid running tests with maven depends on the OS if > I reach a level where > no independent solution exists like loading a C-lib for example, don't > care if it is a good idea? Stephen already answered this one. Add code which tests for the OS and bails (with a warning) if this test cannot be executed in the current OS. Wayne - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Problem with maven and deleting files in a test case
The solution is to use a junit assumption to skip the test, e.g. Assume.assumeThat("Test fails on windows", System.getProperty("file.seperator.char"), is("/")); Added to the start of each test method will cause them to be skipped on windows but run elsewhere... Note I am on my phone and memory is imperfect so the syntax will need tweaking Sent from my iPhone On 14 Jul 2012, at 03:42, "esyimn...@gmx.de" wrote: > Am 12.07.2012 23:19, schrieb Wayne Fay: >>> With JUnit everthing is perfekt on Linux and Windows. With Maven it >> What version of JUnit and how are you calling it? >> >> >>> works perfekt under Linux, but fails sometimes under Windows 7 64. >> What is the failure under Windows? Can you add code to trap that error >> and report the details? Do you have any idea why it fails sometimes >> but not always? >> >> >>> I know there is an issue with file handling on Windows that does not >>> exists on Linux, but wondering that JUnit do the trick and Maven don't >>> do it (sometimes). >>> Does anyone knows a solution, if it is a Maven problem? >> For good measure, I'd suggest adding config to your pom to specify the >> Surefire version: >> >> >> >>org.apache.maven.plugins >>maven-surefire-plugin >>2.12 >> >> >>org.apache.maven.surefire >>surefire-junit47 >>2.12 >> >> >> >> >> >> >> Windows is annoying for reasons like this so I try to stay on OSX and >> Linux whenever possible. >> >> Wayne >> >> - >> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org >> For additional commands, e-mail: users-h...@maven.apache.org >> >> > > Damn, you made my day! > Now everything works like I expected. > > Yes, I understand if you don't want to download and execute code like > this. It was just a try to bring this thread fast forward. The > maven-surefire-plugin-hint above was all I needed. > > I did the JUnit tests with version 4.8.1 using eclipse and just hit the > run button some times with no error. If I > do it with "mvn clean install" using the command prompt with the > following pom, I got an error after a few hits on enter. > >4.0.0 >test >maven-file-test >0.0.1-SNAPSHOT >jar >maven-file-test > >UTF-8 > > > >junit >junit >4.8.1 >test > > > > My code is quite simple. A method that writes a file and another one > that deletes a file. > The first test inside the test class writes the file, the second test > case delete it. > And I know that it may failed because of the underlying platform like > the javadoc told, for example, in FileOutputStream. > After I added a third test case with a loop around writing and deleting > - which is much as faster as I can do it by pressing the > run button inside an IDE ;) - and after I added maven-surefire-plugin to > my pom like you told, I saw that > both executions (IDE and command prompt) ends with an error. > With the IDE after a while also and with the command prompt not as often > as before. The different frequency of the error appearance made me mad. > > The next two questens I have to find out are: > 1. What does the maven-surefire-plugin exactly do? It still fails, but > not so much like without it. > 2. Is there a way to avoid running tests with maven depends on the OS if > I reach a level where > no independent solution exists like loading a C-lib for example, don't > care if it is a good idea? > > Your hint let my go in the right direction again. > Thanks! > > > > > > > > > > > - > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Problem with maven and deleting files in a test case
Am 12.07.2012 23:19, schrieb Wayne Fay: >> With JUnit everthing is perfekt on Linux and Windows. With Maven it > What version of JUnit and how are you calling it? > > >> works perfekt under Linux, but fails sometimes under Windows 7 64. > What is the failure under Windows? Can you add code to trap that error > and report the details? Do you have any idea why it fails sometimes > but not always? > > >> I know there is an issue with file handling on Windows that does not >> exists on Linux, but wondering that JUnit do the trick and Maven don't >> do it (sometimes). >> Does anyone knows a solution, if it is a Maven problem? > For good measure, I'd suggest adding config to your pom to specify the > Surefire version: > > > > org.apache.maven.plugins > maven-surefire-plugin > 2.12 > > > org.apache.maven.surefire > surefire-junit47 > 2.12 > > > > > > > Windows is annoying for reasons like this so I try to stay on OSX and > Linux whenever possible. > > Wayne > > - > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > > Damn, you made my day! Now everything works like I expected. Yes, I understand if you don't want to download and execute code like this. It was just a try to bring this thread fast forward. The maven-surefire-plugin-hint above was all I needed. I did the JUnit tests with version 4.8.1 using eclipse and just hit the run button some times with no error. If I do it with "mvn clean install" using the command prompt with the following pom, I got an error after a few hits on enter. 4.0.0 test maven-file-test 0.0.1-SNAPSHOT jar maven-file-test UTF-8 junit junit 4.8.1 test My code is quite simple. A method that writes a file and another one that deletes a file. The first test inside the test class writes the file, the second test case delete it. And I know that it may failed because of the underlying platform like the javadoc told, for example, in FileOutputStream. After I added a third test case with a loop around writing and deleting - which is much as faster as I can do it by pressing the run button inside an IDE ;) - and after I added maven-surefire-plugin to my pom like you told, I saw that both executions (IDE and command prompt) ends with an error. With the IDE after a while also and with the command prompt not as often as before. The different frequency of the error appearance made me mad. The next two questens I have to find out are: 1. What does the maven-surefire-plugin exactly do? It still fails, but not so much like without it. 2. Is there a way to avoid running tests with maven depends on the OS if I reach a level where no independent solution exists like loading a C-lib for example, don't care if it is a good idea? Your hint let my go in the right direction again. Thanks! - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Problem with maven and deleting files in a test case
> I see, I made it available on > http://novaexpress.dyndns.org:8181/maven/maven-file-test.zip for a few days. I hope you understand when I say that I'm not hugely interested in downloading and running code that I know 1) deletes stuff and 2) doesn't seem to work properly in all cases. But perhaps I will set up a sandbox to test it. Until then, I am just looking at the pom.xml and other files, and not running them. :) Wayne - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Problem with maven and deleting files in a test case
> With JUnit everthing is perfekt on Linux and Windows. With Maven it What version of JUnit and how are you calling it? > works perfekt under Linux, but fails sometimes under Windows 7 64. What is the failure under Windows? Can you add code to trap that error and report the details? Do you have any idea why it fails sometimes but not always? > I know there is an issue with file handling on Windows that does not > exists on Linux, but wondering that JUnit do the trick and Maven don't > do it (sometimes). > Does anyone knows a solution, if it is a Maven problem? For good measure, I'd suggest adding config to your pom to specify the Surefire version: org.apache.maven.plugins maven-surefire-plugin 2.12 org.apache.maven.surefire surefire-junit47 2.12 Windows is annoying for reasons like this so I try to stay on OSX and Linux whenever possible. Wayne - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Problem with maven and deleting files in a test case
>> For a better understanding I reduced my code to the problem parts and >> made a small project (maven-file-test, attached to the mail). In this > Just so you know, this mail list strips attachments. If you want to > share the project, you will need to post it somewhere like Gist. > > Wayne I see, I made it available on http://novaexpress.dyndns.org:8181/maven/maven-file-test.zip for a few days. Björn - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Problem with maven and deleting files in a test case
> For a better understanding I reduced my code to the problem parts and > made a small project (maven-file-test, attached to the mail). In this Just so you know, this mail list strips attachments. If you want to share the project, you will need to post it somewhere like Gist. Wayne - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org