Search in sources :

Example 1 with Order

use of org.junit.jupiter.api.Order in project dubbo by alibaba.

the class FailbackClusterInvokerTest method testInvokeRetryTimesWithIllegalValue.

@Test
@Order(8)
public void testInvokeRetryTimesWithIllegalValue() throws InterruptedException, NoSuchFieldException, IllegalAccessException {
    resetInvokerToException();
    given(dic.getConsumerUrl()).willReturn(url.addParameter(RETRIES_KEY, -100));
    FailbackClusterInvoker<FailbackClusterInvokerTest> invoker = new FailbackClusterInvoker<>(dic);
    LogUtil.start();
    DubboAppender.clear();
    invocation.setMethodName("testInvokeRetryTimesWithIllegalValue");
    invoker.invoke(invocation);
    CountDownLatch countDown = new CountDownLatch(1);
    countDown.await(getRetryFailedPeriod() * (CommonConstants.DEFAULT_FAILBACK_TIMES + 1), TimeUnit.SECONDS);
    LogUtil.stop();
    Assertions.assertEquals(3, LogUtil.findMessage(Level.INFO, "Attempt to retry to invoke method " + "testInvokeRetryTimesWithIllegalValue"), "Must have three error message ");
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Test(org.junit.jupiter.api.Test)

Example 2 with Order

use of org.junit.jupiter.api.Order in project dubbo by alibaba.

the class FailbackClusterInvokerTest method testInvokeRetryTimesWithTwoValue.

@Test
@Order(6)
public void testInvokeRetryTimesWithTwoValue() throws InterruptedException, NoSuchFieldException, IllegalAccessException {
    int retries = 2;
    resetInvokerToException();
    given(dic.getConsumerUrl()).willReturn(url.addParameter(RETRIES_KEY, retries));
    FailbackClusterInvoker<FailbackClusterInvokerTest> invoker = new FailbackClusterInvoker<>(dic);
    LogUtil.start();
    DubboAppender.clear();
    invocation.setMethodName("testInvokeRetryTimesWithTwoValue");
    invoker.invoke(invocation);
    CountDownLatch countDown = new CountDownLatch(1);
    countDown.await(getRetryFailedPeriod() * (retries + 1), TimeUnit.SECONDS);
    LogUtil.stop();
    Assertions.assertEquals(2, LogUtil.findMessage(Level.INFO, "Attempt to retry to invoke method " + "testInvokeRetryTimesWithTwoValue"), "Must have two error message ");
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Test(org.junit.jupiter.api.Test)

Example 3 with Order

use of org.junit.jupiter.api.Order in project dubbo by alibaba.

the class ApolloDynamicConfigurationTest method testAddListener.

/**
 * Test add listener.
 *
 * @throws Exception the exception
 */
@Test
@Order(3)
public void testAddListener() throws Exception {
    String mockKey = "mockKey3";
    String mockValue = String.valueOf(new Random().nextInt());
    final SettableFuture<org.apache.dubbo.common.config.configcenter.ConfigChangedEvent> future = SettableFuture.create();
    apolloDynamicConfiguration = new ApolloDynamicConfiguration(url);
    apolloDynamicConfiguration.addListener(mockKey, DEFAULT_NAMESPACE, new ConfigurationListener() {

        @Override
        public void process(org.apache.dubbo.common.config.configcenter.ConfigChangedEvent event) {
            future.set(event);
        }
    });
    putData(mockKey, mockValue);
    org.apache.dubbo.common.config.configcenter.ConfigChangedEvent result = future.get(3000, TimeUnit.MILLISECONDS);
    assertEquals(mockValue, result.getContent());
    assertEquals(mockKey, result.getKey());
    assertEquals(ConfigChangeType.MODIFIED, result.getChangeType());
}
Also used : ConfigurationListener(org.apache.dubbo.common.config.configcenter.ConfigurationListener) Random(java.util.Random) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 4 with Order

use of org.junit.jupiter.api.Order in project cas by apereo.

the class AdaptiveMultifactorAuthenticationTriggerTests method verifyNoProviders.

@Test
@Order(0)
@Tag("DisableProviderRegistration")
public void verifyNoProviders() {
    val props = new CasConfigurationProperties();
    props.getAuthn().getAdaptive().getPolicy().getRequireMultifactor().put("mfa-dummy", ".+London.+");
    val trigger = new AdaptiveMultifactorAuthenticationTrigger(null, props, this.applicationContext);
    assertThrows(AuthenticationException.class, () -> trigger.isActivated(authentication, registeredService, this.httpRequest, this.httpResponse, mock(Service.class)));
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag)

Example 5 with Order

use of org.junit.jupiter.api.Order in project cas by apereo.

the class AdaptiveMultifactorAuthenticationTriggerTests method verifyOperationByRequestGeoLocation.

@Test
@Order(3)
public void verifyOperationByRequestGeoLocation() {
    val props = new CasConfigurationProperties();
    props.getAuthn().getAdaptive().getPolicy().getRequireMultifactor().put("mfa-dummy", ".+London.+");
    val geoResponse = new GeoLocationResponse();
    geoResponse.addAddress("123 Main St London UK");
    when(this.geoLocationService.locate(anyString(), any(GeoLocationRequest.class))).thenReturn(geoResponse);
    val trigger = new AdaptiveMultifactorAuthenticationTrigger(this.geoLocationService, props, this.applicationContext);
    val result = trigger.isActivated(authentication, registeredService, this.httpRequest, this.httpResponse, mock(Service.class));
    assertTrue(result.isPresent());
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) GeoLocationResponse(org.apereo.cas.authentication.adaptive.geo.GeoLocationResponse) Service(org.apereo.cas.authentication.principal.Service) GeoLocationRequest(org.apereo.cas.authentication.adaptive.geo.GeoLocationRequest) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Aggregations

Order (org.junit.jupiter.api.Order)76 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)76 Test (org.junit.jupiter.api.Test)74 lombok.val (lombok.val)67 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)30 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)24 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)24 Service (org.apereo.cas.authentication.principal.Service)23 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 DefaultMultifactorAuthenticationProviderResolver (org.apereo.cas.authentication.DefaultMultifactorAuthenticationProviderResolver)7 Tag (org.junit.jupiter.api.Tag)6 CountDownLatch (java.util.concurrent.CountDownLatch)5 RepeatedTest (org.junit.jupiter.api.RepeatedTest)5 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)4 TicketGrantingTicketFactory (org.apereo.cas.ticket.TicketGrantingTicketFactory)4 MessageContext (org.opensaml.messaging.context.MessageContext)4 JEEContext (org.pac4j.core.context.JEEContext)4 ClassPathResource (org.springframework.core.io.ClassPathResource)4 URLBuilder (net.shibboleth.utilities.java.support.net.URLBuilder)3