-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor refactoring add empty response body test
- Loading branch information
1 parent
efae5f4
commit c5b5636
Showing
7 changed files
with
62 additions
and
5 deletions.
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
44 changes: 44 additions & 0 deletions
44
...fing/bucket4j/spring/boot/starter/general/tests/filter/servlet/EmptyHttpResponseTest.java
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,44 @@ | ||
package com.giffing.bucket4j.spring.boot.starter.general.tests.filter.servlet; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
|
||
import java.util.Collections; | ||
import java.util.stream.IntStream; | ||
|
||
import static com.giffing.bucket4j.spring.boot.starter.general.tests.filter.servlet.MockMvcHelper.*; | ||
|
||
|
||
@SpringBootTest(properties = { | ||
"bucket4j.filters[0].cache-name=buckets", | ||
"bucket4j.filters[0].url=^(/hello).*", | ||
"bucket4j.filters[0].http-response-body=null", | ||
"bucket4j.filters[0].rate-limits[0].bandwidths[0].capacity=5", | ||
"bucket4j.filters[0].rate-limits[0].bandwidths[0].time=10", | ||
"bucket4j.filters[0].rate-limits[0].bandwidths[0].unit=seconds", | ||
"bucket4j.filters[0].rate-limits[0].bandwidths[0].refill-speed=interval", | ||
}) | ||
@AutoConfigureMockMvc | ||
@DirtiesContext | ||
public class EmptyHttpResponseTest { | ||
|
||
@Autowired | ||
private MockMvc mockMvc; | ||
|
||
@Test | ||
void helloTest() throws Exception { | ||
String url = "/hello"; | ||
IntStream.rangeClosed(1, 5) | ||
.boxed() | ||
.sorted(Collections.reverseOrder()) | ||
.forEach(counter -> webRequestWithStatus(mockMvc, url, HttpStatus.OK, counter - 1)); | ||
blockedWebRequestDueToRateLimitWithEmptyBody(mockMvc, url); | ||
} | ||
|
||
|
||
} |
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
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