11package com .github .scribejava .core .extractors ;
22
33import static org .junit .Assert .assertEquals ;
4+ import static org .junit .Assert .assertTrue ;
45import org .junit .Before ;
56import org .junit .Test ;
67import com .github .scribejava .core .exceptions .OAuthParametersMissingException ;
@@ -24,16 +25,24 @@ public void setUp() {
2425 @ Test
2526 public void shouldExtractStandardHeader () {
2627 final String header = extractor .extract (request );
27- try {
28- assertEquals ("OAuth oauth_callback=\" http%3A%2F%2Fexample%2Fcallback\" , "
29- + "oauth_signature=\" OAuth-Signature\" , oauth_consumer_key=\" AS%23%24%5E%2A%40%26\" , "
30- + "oauth_timestamp=\" 123456\" " , header );
31- } catch (AssertionError ae ) {
32- //maybe this is OpenJDK 8? Different order of elements in HashMap while iterating'em.
33- assertEquals ("OAuth oauth_signature=\" OAuth-Signature\" , "
34- + "oauth_callback=\" http%3A%2F%2Fexample%2Fcallback\" , "
35- + "oauth_consumer_key=\" AS%23%24%5E%2A%40%26\" , oauth_timestamp=\" 123456\" " , header );
36- }
28+ final String oauth = "OAuth " ;
29+ final String callback = "oauth_callback=\" http%3A%2F%2Fexample%2Fcallback\" " ;
30+ final String signature = "oauth_signature=\" OAuth-Signature\" " ;
31+ final String key = "oauth_consumer_key=\" AS%23%24%5E%2A%40%26\" " ;
32+ final String timestamp = "oauth_timestamp=\" 123456\" " ;
33+
34+ assertTrue (header .contains (oauth ));
35+ assertTrue (header .contains (callback ));
36+ assertTrue (header .contains (signature ));
37+ assertTrue (header .contains (key ));
38+ assertTrue (header .contains (timestamp ));
39+ // Assert that header only contains the checked elements above and nothing else
40+ assertEquals (", , , " ,
41+ header .replaceFirst (oauth , "" )
42+ .replaceFirst (callback , "" )
43+ .replaceFirst (signature , "" )
44+ .replaceFirst (key , "" )
45+ .replaceFirst (timestamp , "" ));
3746 }
3847
3948 @ Test (expected = IllegalArgumentException .class )
0 commit comments