Merge pull request #12027 from hkhan/JAVA-10446-investigate-openfeign-failure

[JAVA-10446] Convert Feign-OAuth2 unit test to manual test
This commit is contained in:
kwoyke 2022-04-11 09:16:33 +02:00 committed by GitHub
commit 813b27588e
4 changed files with 46 additions and 32 deletions

View File

@ -45,7 +45,7 @@
<module>spring-cloud-ribbon-retry</module>
<module>spring-cloud-circuit-breaker</module>
<module>spring-cloud-eureka-self-preservation</module>
<!-- <module>spring-cloud-openfeign</module> --> <!-- Fixing under JAVA-10446 -->
<module>spring-cloud-openfeign</module>
<module>spring-cloud-netflix-feign</module>
<module>spring-cloud-sentinel</module>
<module>spring-cloud-dapr</module>

View File

@ -15,7 +15,7 @@ import static org.junit.Assert.assertNotNull;
@RunWith(SpringRunner.class)
@SpringBootTest
public class OpenfeignManualTest {
public class OpenFeignManualTest {
@Autowired
private JSONPlaceHolderService jsonPlaceHolderService;

View File

@ -0,0 +1,44 @@
package com.baeldung.cloud.openfeign;
import com.baeldung.cloud.openfeign.client.PaymentClient;
import com.baeldung.cloud.openfeign.model.Payment;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
import static org.junit.Assert.assertFalse;
/**
* This test can be used to verify OAuth2 Token functionality with Feign client
* (https://www.baeldung.com/spring-cloud-feign-oauth-token).
*
* The following components should be setup and running, as described in the article, prior to running this test.
*
* Authorization Server - embedded Keycloak server with the correct client and client-secret defined in the master realm.
* This will issue the auth tokens used by Feign client.
* Further details are available at: https://www.baeldung.com/keycloak-embedded-in-spring-boot-app
*
* Resource Server - OAuth resource server requiring valid JWT token (issued by the Authorization Server).
* Further details are available at: https://www.baeldung.com/spring-security-oauth-resource-server
*
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class OpenFeignOAuth2ManualTest {
@Autowired
private PaymentClient paymentClient;
@Test
public void whenGetPayment_thenListPayments() {
List<Payment> payments = paymentClient.getPayments();
assertFalse(payments.isEmpty());
}
}

View File

@ -1,30 +0,0 @@
package com.baeldung.cloud.openfeign;
import com.baeldung.cloud.openfeign.client.PaymentClient;
import com.baeldung.cloud.openfeign.model.Payment;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
import static org.junit.Assert.assertFalse;
@RunWith(SpringRunner.class)
@SpringBootTest
public class PaymentClientUnitTest {
@Autowired
private PaymentClient paymentClient;
@Test
public void whenGetPayment_thenListPayments() {
List<Payment> payments = paymentClient.getPayments();
assertFalse(payments.isEmpty());
}
}