Search in sources :

Example 21 with EnabledForTestGroups

use of org.springframework.core.testfixture.EnabledForTestGroups in project spring-framework by spring-projects.

the class EnableSchedulingTests method withTriggerTask.

@Test
@EnabledForTestGroups(LONG_RUNNING)
public void withTriggerTask() throws InterruptedException {
    ctx = new AnnotationConfigApplicationContext(TriggerTaskConfig.class);
    Thread.sleep(100);
    assertThat(ctx.getBean(AtomicInteger.class).get()).isGreaterThan(1);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Test(org.junit.jupiter.api.Test) EnabledForTestGroups(org.springframework.core.testfixture.EnabledForTestGroups)

Example 22 with EnabledForTestGroups

use of org.springframework.core.testfixture.EnabledForTestGroups in project spring-framework by spring-projects.

the class BeanFactoryGenericsTests method testSetBean.

@Test
@EnabledForTestGroups(LONG_RUNNING)
void testSetBean() throws Exception {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource("genericBeanTests.xml", getClass()));
    UrlSet us = (UrlSet) bf.getBean("setBean");
    assertThat(us.size()).isEqualTo(1);
    assertThat(us.iterator().next()).isEqualTo(new URL("https://www.springframework.org"));
}
Also used : XmlBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader) ClassPathResource(org.springframework.core.io.ClassPathResource) URL(java.net.URL) Test(org.junit.jupiter.api.Test) EnabledForTestGroups(org.springframework.core.testfixture.EnabledForTestGroups)

Example 23 with EnabledForTestGroups

use of org.springframework.core.testfixture.EnabledForTestGroups in project spring-framework by spring-projects.

the class QuartzSupportTests method twoAnonymousMethodInvokingJobDetailFactoryBeans.

@Test
@EnabledForTestGroups(LONG_RUNNING)
void twoAnonymousMethodInvokingJobDetailFactoryBeans() throws Exception {
    try (ClassPathXmlApplicationContext ctx = context("multipleAnonymousMethodInvokingJobDetailFB.xml")) {
        QuartzTestBean exportService = (QuartzTestBean) ctx.getBean("exportService");
        QuartzTestBean importService = (QuartzTestBean) ctx.getBean("importService");
        Thread.sleep(400);
        assertThat(exportService.getImportCount()).as("doImport called exportService").isEqualTo(0);
        assertThat(exportService.getExportCount()).as("doExport not called on exportService").isEqualTo(2);
        assertThat(importService.getImportCount()).as("doImport not called on importService").isEqualTo(2);
        assertThat(importService.getExportCount()).as("doExport called on importService").isEqualTo(0);
    }
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Test(org.junit.jupiter.api.Test) EnabledForTestGroups(org.springframework.core.testfixture.EnabledForTestGroups)

Example 24 with EnabledForTestGroups

use of org.springframework.core.testfixture.EnabledForTestGroups in project spring-framework by spring-projects.

the class QuartzSupportTests method schedulerWithSpringBeanJobFactoryAndParamMismatchNotIgnored.

@Test
@EnabledForTestGroups(LONG_RUNNING)
void schedulerWithSpringBeanJobFactoryAndParamMismatchNotIgnored() throws Exception {
    DummyJob.param = 0;
    DummyJob.count = 0;
    JobDetailImpl jobDetail = new JobDetailImpl();
    jobDetail.setDurability(true);
    jobDetail.setJobClass(DummyJob.class);
    jobDetail.setName("myJob");
    jobDetail.getJobDataMap().put("para", "10");
    jobDetail.getJobDataMap().put("ignoredParam", "10");
    SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean();
    trigger.setName("myTrigger");
    trigger.setJobDetail(jobDetail);
    trigger.setStartDelay(1);
    trigger.setRepeatInterval(500);
    trigger.setRepeatCount(1);
    trigger.afterPropertiesSet();
    SchedulerFactoryBean bean = new SchedulerFactoryBean();
    SpringBeanJobFactory jobFactory = new SpringBeanJobFactory();
    jobFactory.setIgnoredUnknownProperties("ignoredParam");
    bean.setJobFactory(jobFactory);
    bean.setTriggers(trigger.getObject());
    bean.setJobDetails(jobDetail);
    bean.afterPropertiesSet();
    Thread.sleep(500);
    assertThat(DummyJob.param).isEqualTo(0);
    assertThat(DummyJob.count == 0).isTrue();
    bean.destroy();
}
Also used : JobDetailImpl(org.quartz.impl.JobDetailImpl) Test(org.junit.jupiter.api.Test) EnabledForTestGroups(org.springframework.core.testfixture.EnabledForTestGroups)

Example 25 with EnabledForTestGroups

use of org.springframework.core.testfixture.EnabledForTestGroups in project spring-framework by spring-projects.

the class DelegatingWebConnectionTests method verifyExampleInClassLevelJavadoc.

@Test
@EnabledForTestGroups(LONG_RUNNING)
public void verifyExampleInClassLevelJavadoc() throws Exception {
    WebClient webClient = new WebClient();
    MockMvc mockMvc = MockMvcBuilders.standaloneSetup().build();
    MockMvcWebConnection mockConnection = new MockMvcWebConnection(mockMvc, webClient);
    WebRequestMatcher cdnMatcher = new UrlRegexRequestMatcher(".*?//code.jquery.com/.*");
    WebConnection httpConnection = new HttpWebConnection(webClient);
    webClient.setWebConnection(new DelegatingWebConnection(mockConnection, new DelegateWebConnection(cdnMatcher, httpConnection)));
    Page page = webClient.getPage("https://code.jquery.com/jquery-1.11.0.min.js");
    assertThat(page.getWebResponse().getStatusCode()).isEqualTo(200);
    assertThat(page.getWebResponse().getContentAsString()).isNotEmpty();
}
Also used : HttpWebConnection(com.gargoylesoftware.htmlunit.HttpWebConnection) WebConnection(com.gargoylesoftware.htmlunit.WebConnection) DelegateWebConnection(org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection.DelegateWebConnection) HttpWebConnection(com.gargoylesoftware.htmlunit.HttpWebConnection) DelegateWebConnection(org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection.DelegateWebConnection) Page(com.gargoylesoftware.htmlunit.Page) WebClient(com.gargoylesoftware.htmlunit.WebClient) MockMvc(org.springframework.test.web.servlet.MockMvc) Test(org.junit.jupiter.api.Test) EnabledForTestGroups(org.springframework.core.testfixture.EnabledForTestGroups)

Aggregations

EnabledForTestGroups (org.springframework.core.testfixture.EnabledForTestGroups)25 Test (org.junit.jupiter.api.Test)23 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 JobDetailImpl (org.quartz.impl.JobDetailImpl)5 NoOpRunnable (org.springframework.core.task.NoOpRunnable)5 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 SQLException (java.sql.SQLException)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 ValueSource (org.junit.jupiter.params.provider.ValueSource)2 InOrder (org.mockito.InOrder)2 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)2 DataAccessResourceFailureException (org.springframework.dao.DataAccessResourceFailureException)2 UncategorizedSQLException (org.springframework.jdbc.UncategorizedSQLException)2 TransactionStatus (org.springframework.transaction.TransactionStatus)2 TransactionTimedOutException (org.springframework.transaction.TransactionTimedOutException)2 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)2 TransactionTemplate (org.springframework.transaction.support.TransactionTemplate)2 HttpWebConnection (com.gargoylesoftware.htmlunit.HttpWebConnection)1