org.springframework.test.annotation.Repeat Java Examples

The following examples show how to use org.springframework.test.annotation.Repeat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestStandardBullhornApiRestFile.java    From sdk-rest with MIT License 6 votes vote down vote up
@Repeat(1)
@Test
public void testAddFileUsingMultipartFile() throws UnsupportedEncodingException, IOException {
	MultipartFile file = getResume();
	FileParams params = ParamFactory.fileParams();
	try {
		FileWrapper fileWrapper = bullhornData.addFile(Candidate.class, testEntities.getCandidateId(), file, "portfolio", params);
		assertFileWrapperIncludingFileName(fileWrapper);

		FileApiResponse fileApiResponse = bullhornData.deleteFile(Candidate.class, testEntities.getCandidateId(),
				fileWrapper.getId());

		assertFileApiResponse(fileApiResponse, fileWrapper.getId());
	} catch (HttpStatusCodeException error) {
		assertTrue(StringUtils.equals("" + error.getStatusCode().value(), "500"));
	}

}
 
Example #2
Source File: TestStandardBullhornApiRestFile.java    From sdk-rest with MIT License 6 votes vote down vote up
@Repeat(1)
@Test
public void testAddFileUsingFile() throws UnsupportedEncodingException, IOException {
	File file = getFile();
	FileParams params = ParamFactory.fileParams();
	try {
		FileWrapper fileWrapper = bullhornData.addFile(Candidate.class, testEntities.getCandidateId(), file, "portfolio", params);
		assertFileWrapperIncludingFileName(fileWrapper);

		FileApiResponse fileApiResponse = bullhornData.deleteFile(Candidate.class, testEntities.getCandidateId(),
				fileWrapper.getId());

		assertFileApiResponse(fileApiResponse, fileWrapper.getId());
	} catch (HttpStatusCodeException error) {
		assertTrue(StringUtils.equals("" + error.getStatusCode().value(), "500"));
	}

}
 
Example #3
Source File: TestStandardBullhornApiRestFile.java    From sdk-rest with MIT License 6 votes vote down vote up
@Repeat(1)
@Test
public void testDeleteFile() throws UnsupportedEncodingException, IOException {
	MultipartFile file = getResume();
	FileParams params = ParamFactory.fileParams();
	try {
		FileWrapper fileWrapper = bullhornData.addFile(Candidate.class, testEntities.getCandidateId(), file, "portfolio", params);

		assertFileWrapper(fileWrapper);

		FileApiResponse fileApiResponse = bullhornData.deleteFile(Candidate.class, testEntities.getCandidateId(),
				fileWrapper.getId());

		assertFileApiResponse(fileApiResponse, fileWrapper.getId());
	} catch (HttpStatusCodeException error) {
		assertTrue(StringUtils.equals("" + error.getStatusCode().value(), "500"));
	}

}
 
Example #4
Source File: RefreshScopeConcurrencyTests.java    From spring-cloud-commons with Apache License 2.0 5 votes vote down vote up
@Test
@Repeat(10)
@DirtiesContext
public void testConcurrentRefresh() throws Exception {

	then(this.service.getMessage()).isEqualTo("Hello scope!");
	this.properties.setMessage("Foo");
	this.properties.setDelay(500);
	final CountDownLatch latch = new CountDownLatch(1);
	Future<String> result = this.executor.submit(new Callable<String>() {
		@Override
		public String call() throws Exception {
			logger.debug("Background started.");
			try {
				return RefreshScopeConcurrencyTests.this.service.getMessage();
			}
			finally {
				latch.countDown();
				logger.debug("Background done.");
			}
		}
	});
	then(latch.await(15000, TimeUnit.MILLISECONDS)).isTrue();
	logger.info("Refreshing");
	this.scope.refreshAll();
	then(this.service.getMessage()).isEqualTo("Foo");
	/*
	 * This is the most important assertion: we don't want a null value because that
	 * means the bean was destroyed and not re-initialized before we accessed it.
	 */
	then(result.get()).isNotNull();
	then(result.get()).isEqualTo("Hello scope!");
}
 
Example #5
Source File: TestStandardBullhornApiRestResumeParse.java    From sdk-rest with MIT License 5 votes vote down vote up
@Repeat(1)
@Test
public void testSaveParseResume() {

	MultipartFile resume = getResume();
	ParsedResume parsedResume = bullhornData.parseResumeFile(resume, ParamFactory.resumeFileParseParams());
	assertParsedResume(parsedResume);

	ParsedResume savedParsedResume = bullhornData.saveParsedResumeDataToBullhorn(parsedResume);
	assertNotNull("ParsedResume.candidate.id is null", savedParsedResume.getCandidate().getId());
	this.parsedResume = savedParsedResume;

}
 
Example #6
Source File: Issue16DbUnitTestExecutionListenerDbUnitTest.java    From flyway-test-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Made a clean init migrate with inserts from flyway and store it
 * afterwards
 */
@Test
@Repeat(10) // 10 executions are enough
@FlywayTest(locationsForMigrate = { "loadMultibleSQLs" })
@DBUnitSupport(saveTableAfterRun = { "CUSTOMER", "select * from CUSTOMER" }, saveFileAfterRun = "target/dbunitresult/Issue16DbCustomer.xml")
public void storeRepeat() throws Exception {
    int res = countCustomer();

    Assert.assertEquals("Count of customer", 2, res);
}
 
Example #7
Source File: Issue16DbUnitTestExecutionListenerDbUnitTest.java    From flyway-test-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Normal test method nothing done per startup
 */
@Test
@Repeat(10) // 10 executions are enough
@FlywayTest
@DBUnitSupport(loadFilesForRun = { "INSERT", "/dbunit/dbunit.cus1.xml" })
public void repeatLoad() throws Exception {
    int res = countCustomer();

    Assert.assertEquals("Count of customer", 2, res);
}
 
Example #8
Source File: RefreshScopeScaleTests.java    From spring-cloud-commons with Apache License 2.0 5 votes vote down vote up
@Test
@Repeat(10)
@DirtiesContext
public void testConcurrentRefresh() throws Exception {

	// overload the thread pool and try to force Spring to create too many instances
	int n = 80;
	ExampleService.count = 0;
	this.properties.setMessage("Foo");
	this.properties.setDelay(500);
	this.scope.refreshAll();
	final CountDownLatch latch = new CountDownLatch(n);
	Future<String> result = null;
	for (int i = 0; i < n; i++) {
		result = this.executor.submit(new Callable<String>() {
			@Override
			public String call() throws Exception {
				logger.debug("Background started.");
				try {
					return RefreshScopeScaleTests.this.service.getMessage();
				}
				finally {
					latch.countDown();
					logger.debug("Background done.");
				}
			}
		});
	}
	then(latch.await(15000, TimeUnit.MILLISECONDS)).isTrue();
	then(this.service.getMessage()).isEqualTo("Foo");
	then(result.get()).isNotNull();
	then(result.get()).isEqualTo("Foo");
	then(ExampleService.count).isEqualTo(1);
}
 
Example #9
Source File: RefreshScopePureScaleTests.java    From spring-cloud-commons with Apache License 2.0 5 votes vote down vote up
@Test
@Repeat(10)
@DirtiesContext
public void testConcurrentRefresh() throws Exception {

	// overload the thread pool and try to force Spring to create too many instances
	int n = 80;
	this.scope.refreshAll();
	final CountDownLatch latch = new CountDownLatch(n);
	List<Future<String>> results = new ArrayList<>();
	for (int i = 0; i < n; i++) {
		results.add(this.executor.submit(new Callable<String>() {
			@Override
			public String call() throws Exception {
				logger.debug("Background started.");
				try {
					return RefreshScopePureScaleTests.this.service.getMessage();
				}
				finally {
					latch.countDown();
					logger.debug("Background done.");
				}
			}
		}));
		this.executor.submit(new Runnable() {
			@Override
			public void run() {
				logger.debug("Refreshing.");
				RefreshScopePureScaleTests.this.scope.refreshAll();
			}
		});
	}
	then(latch.await(15000, TimeUnit.MILLISECONDS)).isTrue();
	then(this.service.getMessage()).isEqualTo("Foo");
	for (Future<String> result : results) {
		then(result.get()).isEqualTo("Foo");
	}
}
 
Example #10
Source File: RepeatedSpringRunnerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
@Timed(millis = 100)
@Repeat(10)
public void collectiveRepetitionsExceedTimeout() throws Exception {
	incrementInvocationCount();
	Thread.sleep(11);
}
 
Example #11
Source File: TestStandardBullhornApiRestResumeParse.java    From sdk-rest with MIT License 5 votes vote down vote up
@Repeat(1)
@Test
public void testAddFileThenParseResumeFile() {

	MultipartFile resume = getResume();
	ParsedResume parsedResume = bullhornData.parseResumeThenAddfile(Candidate.class, testEntities.getCandidateId(), resume,
			"portfolio", ParamFactory.fileParams(), ParamFactory.resumeFileParseParams());
	assertParsedResume(parsedResume);
	assertFileWrapperIncludingFileName(parsedResume.getFileWrapper());

}
 
Example #12
Source File: TestStandardBullhornApiRestFile.java    From sdk-rest with MIT License 5 votes vote down vote up
@Repeat(1)
@Test
public void testAddResumeFileAndPopulateCandidateDescription() throws UnsupportedEncodingException, IOException {
	File file = getFile();
	FileParams params = ParamFactory.fileParams();
	try {

		Candidate testCandidate = new Candidate();
		testCandidate.setId(testEntities.getCandidateId());
		testCandidate.setDescription("");
		bullhornData.updateEntity(testCandidate);

		Set<String> fields = new HashSet<String>(Arrays.asList(new String[] { "id", "description" }));

		Candidate shouldHaveNoDescription = bullhornData.findEntity(Candidate.class, testEntities.getCandidateId(), fields);
		assertTrue("The test candidate should have a blank description. But it is not.",
				StringUtils.isBlank(shouldHaveNoDescription.getDescription()));

		String candidateDescription = "new description";
		FileWrapper fileWrapper = bullhornData.addResumeFileAndPopulateCandidateDescription(testEntities.getCandidateId(), file,
				candidateDescription, "portfolio", params);
		assertFileWrapperIncludingFileName(fileWrapper);

		Candidate shouldHaveDescription = bullhornData.findEntity(Candidate.class, testEntities.getCandidateId(), fields);

		assertTrue("Error with addResumeFileAndPopulateCandidateDescription. Description not populated",
				StringUtils.equalsIgnoreCase(candidateDescription, shouldHaveDescription.getDescription()));

		FileApiResponse fileApiResponse = bullhornData.deleteFile(Candidate.class, testEntities.getCandidateId(),
				fileWrapper.getId());

		assertFileApiResponse(fileApiResponse, fileWrapper.getId());
	} catch (HttpStatusCodeException error) {
		assertTrue(StringUtils.equals("" + error.getStatusCode().value(), "500"));
	}

}
 
Example #13
Source File: TestStandardBullhornApiRestFile.java    From sdk-rest with MIT License 5 votes vote down vote up
@Repeat(1)
@Test
public void testGetEntityMetaFiles() throws UnsupportedEncodingException, IOException {
	try {
		List<FileMeta> entityMetaFiles = bullhornData.getFileMetaData(Candidate.class, testEntities.getCandidateId());
		assertEntityMetaFiles(entityMetaFiles);
	} catch (HttpStatusCodeException error) {
		assertTrue(StringUtils.equals("" + error.getStatusCode().value(), "500"));
	}
}
 
Example #14
Source File: ConnectionLeakIntegrationTest.java    From embedded-database-spring-test with Apache License 2.0 5 votes vote down vote up
@Test
@Repeat(30)
@Timed(millis = 30000)
@FlywayTest(locationsForMigrate = "db/test_migration/appendable")
public void testEmbeddedDatabase() {
    List<Map<String, Object>> persons = jdbcTemplate.queryForList(SQL_SELECT_PERSONS);
    assertThat(persons).isNotNull().hasSize(2);
}
 
Example #15
Source File: TestStandardBullhornApiRestFile.java    From sdk-rest with MIT License 5 votes vote down vote up
@Repeat(1)
@Test
public void testGetAllFileContentWithMetaData() throws UnsupportedEncodingException, IOException {
	try {
		List<FileWrapper> fileWrapperList = bullhornData.getAllFiles(Candidate.class, testEntities.getCandidateId());

		for (FileWrapper fileWrapper : fileWrapperList) {
			assertFileWrapper(fileWrapper);
		}
	} catch (HttpStatusCodeException error) {
		assertTrue(StringUtils.equals("" + error.getStatusCode().value(), "500"));
	}
}
 
Example #16
Source File: TestStandardBullhornApiRestFile.java    From sdk-rest with MIT License 5 votes vote down vote up
@Repeat(1)
@Test
public void testGetFileContent() throws UnsupportedEncodingException, IOException {
	try {
		FileContent fileContent = bullhornData.getFileContent(Candidate.class, testEntities.getCandidateId(), getFileId());
		assertNotNull("FileContent is null", fileContent);
		assertNotNull("FileContent is null", fileContent.getContentType());
		assertNotNull("FileContent is null", fileContent.getName());
		assertNotNull("FileContent is null", fileContent.getFileContent());
	} catch (HttpStatusCodeException error) {
		assertTrue(StringUtils.equals("" + error.getStatusCode().value(), "500"));
	}
}
 
Example #17
Source File: TestStandardBullhornApiRestResumeParse.java    From sdk-rest with MIT License 5 votes vote down vote up
@Repeat(1)
@Test
public void testParseResumeFile() {

	MultipartFile resume = getResume();
	ParsedResume parsedResume = bullhornData.parseResumeFile(resume, ParamFactory.resumeFileParseParams());
	assertParsedResume(parsedResume);

}
 
Example #18
Source File: CompoundLogReaderTest.java    From logsniffer with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Composes 45 million entries.
 * 
 * @throws FormatException
 * @throws IOException
 */
@Test(timeout = 1000 * 100 * 100)
@Repeat(1)
public void testLongComposition() throws FormatException, IOException {
	final long start = System.currentTimeMillis();
	final List<LogInstance> subLogs = new ArrayList<>();
	final CompoundLogReader r = new CompoundLogReader(subLogs);
	final Log log1 = new ByteArrayLog("log1", new byte[0]);
	final Log log2 = new ByteArrayLog("log2", new byte[0]);
	subLogs.add(new LogInstance(1, log1, Mockito.mock(LogRawAccess.class), new DummySubReader(20000000, 2, 0)));
	subLogs.add(new LogInstance(2, log2, Mockito.mock(LogRawAccess.class), new DummySubReader(25000000, 2, 1)));
	final AtomicInteger count = new AtomicInteger();
	r.readEntries(Mockito.mock(Log.class), new CompoundLogAccess(Mockito.mock(Log.class), subLogs), null,
			new LogEntryConsumer() {
				@Override
				public boolean consume(final Log log, final LogPointerFactory pointerFactory, final LogEntry entry)
						throws IOException {
					count.incrementAndGet();
					return true;
				}
			});
	final long end = System.currentTimeMillis() - start;
	logger.info("Read composed {} entries in {}ms, throughput: {} entries/s", count.get(), end,
			Math.round((double) count.get() / (end / 1000)));
	Assert.assertEquals(45000000, count.get());

}
 
Example #19
Source File: TestStandardBullhornApiRestFile.java    From sdk-rest with MIT License 5 votes vote down vote up
@Repeat(1)
@Test
public void testGetFileContentWithMetaData() throws UnsupportedEncodingException, IOException {
	try {
		FileWrapper fileWrapper = bullhornData.getFile(Candidate.class, testEntities.getCandidateId(), getFileId());
		assertFileWrapper(fileWrapper);
	} catch (HttpStatusCodeException error) {
		assertTrue(StringUtils.equals("" + error.getStatusCode().value(), "500"));
	}
}
 
Example #20
Source File: RepeatedSpringRunnerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
@Timed(millis = 20)
@Repeat(4)
public void firstRepetitionOfManyExceedsTimeout() throws Exception {
	incrementInvocationCount();
	Thread.sleep(25);
}
 
Example #21
Source File: RepeatedSpringRunnerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
@Timed(millis = 10)
@Repeat(1)
public void singleRepetitionExceedsTimeout() throws Exception {
	incrementInvocationCount();
	Thread.sleep(15);
}
 
Example #22
Source File: TimedTransactionalSpringRuleTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Overridden since Spring's Rule-based JUnit support cannot properly
 * integrate with timed execution that is controlled by a third-party runner.
 */
@Test(timeout = 10000)
@Repeat(5)
@Override
public void transactionalWithJUnitTimeout() {
	assertInTransaction(false);
}
 
Example #23
Source File: RepeatedSpringRuleTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
@Timed(millis = 100)
@Repeat(10)
public void collectiveRepetitionsExceedTimeout() throws Exception {
	incrementInvocationCount();
	Thread.sleep(11);
}
 
Example #24
Source File: RepeatedSpringRuleTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
@Timed(millis = 20)
@Repeat(4)
public void firstRepetitionOfManyExceedsTimeout() throws Exception {
	incrementInvocationCount();
	Thread.sleep(25);
}
 
Example #25
Source File: RepeatedSpringRuleTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
@Timed(millis = 10)
@Repeat(1)
public void singleRepetitionExceedsTimeout() throws Exception {
	incrementInvocationCount();
	Thread.sleep(15);
}
 
Example #26
Source File: TimedTransactionalSpringRunnerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
@Transactional(propagation = Propagation.NOT_SUPPORTED)
@Timed(millis = 10000)
@Repeat(5)
public void notTransactionalWithSpringTimeout() {
	assertInTransaction(false);
}
 
Example #27
Source File: RepeatedSpringRunnerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
@Timed(millis = 100)
@Repeat(10)
public void collectiveRepetitionsExceedTimeout() throws Exception {
	incrementInvocationCount();
	Thread.sleep(11);
}
 
Example #28
Source File: RepeatedSpringRunnerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
@Timed(millis = 20)
@Repeat(4)
public void firstRepetitionOfManyExceedsTimeout() throws Exception {
	incrementInvocationCount();
	Thread.sleep(25);
}
 
Example #29
Source File: RepeatedSpringRunnerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
@Timed(millis = 10)
@Repeat(1)
public void singleRepetitionExceedsTimeout() throws Exception {
	incrementInvocationCount();
	Thread.sleep(15);
}
 
Example #30
Source File: TimedTransactionalSpringRuleTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Overridden since Spring's Rule-based JUnit support cannot properly
 * integrate with timed execution that is controlled by a third-party runner.
 */
@Test(timeout = 10000)
@Repeat(5)
@Override
public void transactionalWithJUnitTimeout() {
	assertInTransaction(false);
}