44
44
import org .springframework .http .converter .HttpMessageConverter ;
45
45
import org .springframework .web .util .DefaultUriTemplateHandler ;
46
46
47
- import static org .junit .Assert .*;
48
- import static org .mockito .BDDMockito .*;
47
+ import static org .junit .Assert .assertEquals ;
48
+ import static org .junit .Assert .assertFalse ;
49
+ import static org .junit .Assert .assertNull ;
50
+ import static org .junit .Assert .assertSame ;
51
+ import static org .junit .Assert .fail ;
52
+ import static org .mockito .BDDMockito .any ;
53
+ import static org .mockito .BDDMockito .eq ;
54
+ import static org .mockito .BDDMockito .given ;
55
+ import static org .mockito .BDDMockito .mock ;
56
+ import static org .mockito .BDDMockito .verify ;
57
+ import static org .mockito .BDDMockito .willThrow ;
58
+ import static org .springframework .http .MediaType .parseMediaType ;
49
59
50
60
/**
51
61
* @author Arjen Poutsma
@@ -701,9 +711,7 @@ public void optionsForAllow() throws Exception {
701
711
verify (response ).close ();
702
712
}
703
713
704
- // Issue: SPR-9325, SPR-13860
705
-
706
- @ Test
714
+ @ Test // Issue: SPR-9325, SPR-13860
707
715
public void ioException () throws Exception {
708
716
String url = "http://example.com/resource?access_token=123" ;
709
717
@@ -725,6 +733,29 @@ public void ioException() throws Exception {
725
733
}
726
734
}
727
735
736
+ @ Test // SPR-15900
737
+ public void ioExceptionWithEmptyQueryString () throws Exception {
738
+
739
+ // http://example.com/resource?
740
+ URI uri = new URI ("http" , "example.com" , "/resource" , "" , null );
741
+
742
+ given (converter .canRead (String .class , null )).willReturn (true );
743
+ given (converter .getSupportedMediaTypes ()).willReturn (Collections .singletonList (parseMediaType ("foo/bar" )));
744
+ given (requestFactory .createRequest (uri , HttpMethod .GET )).willReturn (request );
745
+ given (request .getHeaders ()).willReturn (new HttpHeaders ());
746
+ given (request .execute ()).willThrow (new IOException ("Socket failure" ));
747
+
748
+ try {
749
+ template .getForObject (uri , String .class );
750
+ fail ("RestClientException expected" );
751
+ }
752
+ catch (ResourceAccessException ex ) {
753
+ assertEquals ("I/O error on GET request for \" http://example.com/resource\" : " +
754
+ "Socket failure; nested exception is java.io.IOException: Socket failure" ,
755
+ ex .getMessage ());
756
+ }
757
+ }
758
+
728
759
@ Test
729
760
public void exchange () throws Exception {
730
761
given (converter .canRead (Integer .class , null )).willReturn (true );
0 commit comments