forked from citrusframework/citrus
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(deps): upgrade to spring v6.2.0
this change is breaking, because Spring v6.2.0 is not compatible with releases prior to it. see the [Spring Release Notes](https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-6.2-Release-Notes) for more information.
- Loading branch information
Showing
8 changed files
with
279 additions
and
30 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
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
72 changes: 72 additions & 0 deletions
72
tools/restdocs/src/test/java/org/citrusframework/restdocs/http/AbstractHttpRequestTest.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,72 @@ | ||
/* | ||
* Copyright the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.citrusframework.restdocs.http; | ||
|
||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.http.HttpRequest; | ||
import org.testng.annotations.Test; | ||
|
||
import java.net.URI; | ||
import java.util.HashMap; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.doReturn; | ||
import static org.mockito.Mockito.mock; | ||
|
||
public abstract class AbstractHttpRequestTest<F extends HttpRequest> { | ||
|
||
protected F fixture; | ||
|
||
protected abstract HttpRequest getDelegate(); | ||
|
||
@Test | ||
public void getHeadersReturnsHeaders() { | ||
var httpHeaders = mock(HttpHeaders.class); | ||
doReturn(httpHeaders).when(getDelegate()).getHeaders(); | ||
|
||
assertThat(fixture.getHeaders()) | ||
.isEqualTo(httpHeaders); | ||
} | ||
|
||
@Test | ||
public void getMethodReturnsMethod() { | ||
var httpMethod = mock(HttpMethod.class); | ||
doReturn(httpMethod).when(getDelegate()).getMethod(); | ||
|
||
assertThat(fixture.getMethod()) | ||
.isEqualTo(httpMethod); | ||
} | ||
|
||
@Test | ||
public void getURIReturnsURI() { | ||
var uri = mock(URI.class); | ||
doReturn(uri).when(getDelegate()).getURI(); | ||
|
||
assertThat(fixture.getURI()) | ||
.isEqualTo(uri); | ||
} | ||
|
||
@Test | ||
public void getAttributesReturnsAttributes() { | ||
var attributes = new HashMap<String, Object>(); | ||
doReturn(attributes).when(getDelegate()).getAttributes(); | ||
|
||
assertThat(fixture.getAttributes()) | ||
.isEqualTo(attributes); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...s/restdocs/src/test/java/org/citrusframework/restdocs/http/CachedBodyHttpRequestTest.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,59 @@ | ||
/* | ||
* Copyright the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.citrusframework.restdocs.http; | ||
|
||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
import org.springframework.http.HttpRequest; | ||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class CachedBodyHttpRequestTest extends AbstractHttpRequestTest<CachedBodyHttpRequest> { | ||
|
||
private static final byte[] BODY = "foo".getBytes(); | ||
|
||
@Mock | ||
private HttpRequest delegate; | ||
|
||
private AutoCloseable openedMocks; | ||
|
||
@Override | ||
protected HttpRequest getDelegate() { | ||
return delegate; | ||
} | ||
|
||
@BeforeMethod | ||
public void beforeMethodSetup() { | ||
openedMocks = MockitoAnnotations.openMocks(this); | ||
|
||
fixture = new CachedBodyHttpRequest(delegate, BODY); | ||
} | ||
|
||
@AfterMethod | ||
public void afterMethodTeardown() throws Exception { | ||
openedMocks.close(); | ||
} | ||
|
||
@Test | ||
public void getBodyReturnsBody() { | ||
assertThat(fixture.getBody()) | ||
.isEqualTo(BODY); | ||
} | ||
} |
Oops, something went wrong.