videni / rest-client

Automatically exported from code.google.com/p/rest-client
Apache License 2.0
0 stars 0 forks source link

tests fails on windows #193

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Just tried it on windows to continue with some enhancements but the test are 
failing.
I think is probably something related with the line ending because on mac os x 
works without problem, but on windows there are some bytes of difference, i 
think the assert fails because of this, i will need to debug.

Just posting in case some one knows the correct answer

This is the configuration of my windows system:

Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 
17:22:22+0200)
Maven home: C:\apache-maven\bin\..
Java version: 1.7.0_40, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_40\jre
Default locale: es_ES, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

Attached is the full output using -X 

Original issue reported on code.google.com by yera...@gmail.com on 2 Dec 2013 at 8:42

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for reporting. This is happening due to a recent fix for Issue 191. 
Looking into this.

Original comment by subwiz on 4 Dec 2013 at 11:17

GoogleCodeExporter commented 8 years ago
Fixed. Please verify (I don't have Windows)!

Original comment by subwiz on 4 Dec 2013 at 11:52

GoogleCodeExporter commented 8 years ago
Hi @subwiz still failing, but i dont think is a JSON stuff, because the test 
fails with XML thing:

       at org.junit.Assert.assertEquals(Assert.java:115)                                                                
       at org.junit.Assert.assertEquals(Assert.java:144)                                                                
       at org.wiztools.restclient.util.XMLIndentUtilTest.testGetIndentedNONE(XMLIndentUtilTest.java:53)                 
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)                                                   
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)                                 
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)                         
       at java.lang.reflect.Method.invoke(Method.java:606)                                                              
       at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)                          
       at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)                           
       at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)                            
       at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)                             
       at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)                                                 
       at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)                             
       at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)                             
       at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)                                                   
       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)                                               
       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)                                             
       at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)                                               
       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)                                              
       at org.junit.runners.ParentRunner.run(ParentRunner.java:309)                                                     
       at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)                              
       at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)                       
       at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)                               
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)                                                   
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)                                 
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)                         
       at java.lang.reflect.Method.invoke(Method.java:606)                                                              
       at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)                
       at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)               
       at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)                      
       at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)                       
       at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)                                      

Same as before

What i dont like is this:

Running org.wiztools.restclient.util.XMLIndentUtilTest                          

Read 492 bytes from input_NONE.xml                                              

Read 509 bytes from input_UTF.xml                                               

Expected bytes: 509 content:                                                    

<?xml version="1.0" encoding="UTF-8"?>                                          

<zp:webspace xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"              

    xmlns:zp="http://zp.mnet.de/types" xsi:schemaLocation="http://zp.mnet.de/types http://zp-rest-test.m-online.net/types/staticwebspace.xsd"> 
    <quota unit="MB">10</quota>                                                                                                                
    <owner>71714</owner>                                                                                                                       
    <ftpuser>someuser</ftpuser>                                                                                                                
    <ftppassword>somepassword</ftppassword>                                                                                                    
    <createdate>2012-04-19T11:15:43</createdate>                                                                                               
    <url>someurl.com</url>                                                                                                                     
    <webid>12892</webid>                                                                                                                       
</zp:webspace>                                                                  

Is bytes: 498 content:                                                          

<?xml version="1.0" encoding="UTF-8"?>                                          

<zp:webspace xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"              

    xmlns:zp="http://zp.mnet.de/types" xsi:schemaLocation="http://zp.mnet.de/types http://zp-rest-test.m-online.net/types/staticwebspace.xsd"> 
    <quota unit="MB">10</quota>                                                                                                                
    <owner>71714</owner>                                                                                                                       
    <ftpuser>someuser</ftpuser>                                                                                                                
    <ftppassword>somepassword</ftppassword>                                                                                                    
    <createdate>2012-04-19T11:15:43</createdate>                                                                                               
    <url>someurl.com</url>                                                                                                                     
    <webid>12892</webid>                                                                                                                       
</zp:webspace>         

I just added the bytes thing. Using a text comparer tool says the those xml are 
equal, but assert is failing, even equalsignorecase says are not equals and 
there is some bytes of difference                                               

Original comment by yera...@gmail.com on 4 Dec 2013 at 12:31

GoogleCodeExporter commented 8 years ago
Ah, ok! I will try to work on this later in the day.

Original comment by subwiz on 4 Dec 2013 at 3:47

GoogleCodeExporter commented 8 years ago

Original comment by subwiz on 4 Dec 2013 at 3:47

GoogleCodeExporter commented 8 years ago
Can you please verify with the latest checkin? I  think this should fix it.

Original comment by subwiz on 7 Dec 2013 at 1:54

GoogleCodeExporter commented 8 years ago
Hi and thanks for your support

The problem is still present, as i mentioned earlier, is a problem with the end 
of files, the file used in the test has a unix eol style.

but when pass the XMLIndentUtil.getIndented , as i'm on windows , uses the 
windows eol style

So this is my solution for this problem: 

assertEquals(expectedResult.replaceAll("\\r\\n?", "\n"), 
result.replaceAll("\\r\\n?", "\n"));

Just normalized the eol to one style because when comparing strings the eol is 
compared too.

Attached is a patch with my changes.

Now works, just failing the Mac OS X package creation on windows.

Regards

Original comment by yera...@gmail.com on 9 Dec 2013 at 12:36

Attachments:

GoogleCodeExporter commented 8 years ago
I added a patch inspired by your patch--please let me know if this works. The 
only problem with your patch seemed to be defensive in nature, while I wanted 
to fix the root cause.

Thanks for supporting the project.

Original comment by subwiz on 11 Dec 2013 at 3:06

GoogleCodeExporter commented 8 years ago
Marking as Fixed due to time lapse. Please reopen if not.

Original comment by subwiz on 16 Dec 2013 at 7:21