-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from zhurpavel/issue_12_fix
Fix for OpenFeign/feign-form#12
- Loading branch information
Showing
3 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package feign.form; | ||
|
||
import static feign.Logger.Level.FULL; | ||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT; | ||
|
||
import feign.*; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
@RunWith(SpringRunner.class) | ||
@SpringBootTest(webEnvironment = DEFINED_PORT, classes = Server.class) | ||
public class WildCardMapTest { | ||
|
||
private static FormUrlEncodedApi API; | ||
|
||
@BeforeClass | ||
public static void configureClient() { | ||
API = | ||
Feign.builder() | ||
.encoder(new FormEncoder()) | ||
.logger(new Logger.JavaLogger().appendToFile("log.txt")) | ||
.logLevel(FULL) | ||
.target(FormUrlEncodedApi.class, "http://localhost:8080"); | ||
} | ||
|
||
@Test | ||
public void testOk() { | ||
Map<String, Object> param = | ||
new HashMap<String, Object>() { | ||
{ | ||
put("key1", "1"); | ||
put("key2", "1"); | ||
} | ||
}; | ||
Response response = API.wildCardMap(param); | ||
Assert.assertEquals(200, response.status()); | ||
} | ||
|
||
@Test | ||
public void testBadRequest() { | ||
Map<String, Object> param = | ||
new HashMap<String, Object>() { | ||
{ | ||
put("key1", "1"); | ||
put("key2", "2"); | ||
} | ||
}; | ||
Response response = API.wildCardMap(param); | ||
Assert.assertEquals(400, response.status()); | ||
} | ||
|
||
interface FormUrlEncodedApi { | ||
|
||
@RequestLine("POST /wild-card-map") | ||
@Headers("Content-Type: application/x-www-form-urlencoded") | ||
Response wildCardMap(Map<String, ?> param); | ||
} | ||
} |