Java Code Examples for org.springframework.test.annotation.DirtiesContext

The following examples show how to use org.springframework.test.annotation.DirtiesContext. These examples are extracted from open source projects. 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 Project: spring-boot-rest-api-helpers   Source File: filterByTests.java    License: MIT License 6 votes vote down vote up
@Test
@DirtiesContext(methodMode = DirtiesContext.MethodMode.BEFORE_METHOD)
public void search_text_on_primitive__fetch_movie_by_not_oontaining_name_infix() {
    Movie matrix = new Movie();
    matrix.setName("The Matrix");
    movieRepository.save(matrix);

    Movie constantine = new Movie();
    constantine.setName("The Matrix: Reloaded");
    movieRepository.save(constantine);

    Movie it = new Movie();
    it.setName("IT");
    movieRepository.save(it);

    Iterable<Movie> movieByName = movieController.filterBy(UrlUtils.encodeURIComponent("{nameNot: %atri%}"), null, null);
    Assert.assertEquals(1, IterableUtil.sizeOf(movieByName));
}
 
Example 2
@Test
@DirtiesContext
public void testRefresh() throws Exception {
	then(this.service.getMessage()).isEqualTo("Hello scope!");
	String id1 = this.service.toString();
	// Change the dynamic property source...
	this.properties.setMessage("Foo");
	// ...and then refresh, so the bean is re-initialized:
	this.scope.refreshAll();
	String id2 = this.service.toString();
	then(this.service.getMessage()).isEqualTo("Foo");
	then(ExampleService.getInitCount()).isEqualTo(1);
	then(ExampleService.getDestroyCount()).isEqualTo(1);
	then(id2).isNotSameAs(id1);
	then(ExampleService.event).isNotNull();
	then(ExampleService.event.getName())
			.isEqualTo(RefreshScopeRefreshedEvent.DEFAULT_NAME);
}
 
Example 3
@Test
@DirtiesContext
public void jdbcMapPipelineTest() {
    jobLauncher.launchJob();

    try {
        testUtils.waitForEsReady(30000);
    } catch (RuntimeException e) {
        e.printStackTrace();
    }
    Map<String, Object> row = dbmsTestUtils.getRowInOutputTable(1);
    String stringContent = (String) row.getOrDefault("output", "");
    assertTrue(stringContent.contains("Disproportionate dwarfism"));
    assertEquals(65, dbmsTestUtils.countRowsInOutputTable());
    assertEquals(65, testUtils.countOutputDocsInES());
}
 
Example 4
@Test
@DirtiesContext
public void verifyComposedTaskFlag() {
	String composedTaskDsl = "<AAA || BBB>";
	assertTrue("Expected true for composed task", TaskServiceUtils.isComposedTaskDefinition(composedTaskDsl));
	composedTaskDsl = "AAA 'FAILED' -> BBB '*' -> CCC";
	assertTrue("Expected true for composed task", TaskServiceUtils.isComposedTaskDefinition(composedTaskDsl));
	composedTaskDsl = "AAA && BBB && CCC";
	assertTrue("Expected true for composed task", TaskServiceUtils.isComposedTaskDefinition(composedTaskDsl));
	String nonComposedTaskDsl = "AAA";
	assertFalse("Expected false for non-composed task",
			TaskServiceUtils.isComposedTaskDefinition(nonComposedTaskDsl));
	nonComposedTaskDsl = "AAA --foo=bar";
	assertFalse("Expected false for non-composed task",
			TaskServiceUtils.isComposedTaskDefinition(nonComposedTaskDsl));
}
 
Example 5
@Test
@DirtiesContext
public void shouldAddNewSymbol() throws Exception {

    gatewayTestClient.addAsset(new RestApiAdminAsset("XBTC", 9123, 8));
    gatewayTestClient.addAsset(new RestApiAdminAsset("USDT", 3412, 2));

    gatewayTestClient.addSymbol(new RestApiAddSymbol(
            "XBTC_USDT",
            3199,
            SymbolType.CURRENCY_EXCHANGE_PAIR,
            "XBTC",
            "USDT",
            new BigDecimal("1000"),
            new BigDecimal("1"),
            new BigDecimal("0.08"),
            new BigDecimal("0.03"),
            BigDecimal.ZERO,
            BigDecimal.ZERO,
            new BigDecimal("50000"),
            new BigDecimal("1000")));
}
 
Example 6
@Test(expected = DocumentCryptException.class)
@DirtiesContext
public void checkWrongKeyCustomId() {
    // save to db, version = 0
    MyBean bean = new MyBean();
    bean.id = "customId";
    bean.secretString = "secret";
    bean.nonSensitiveData = getClass().getSimpleName();
    mongoTemplate.insert(bean);

    // override version 0's key
    ReflectionTestUtils.setField(cryptVault, "cryptVersions", new CryptVersion[256]);
    cryptVault.with256BitAesCbcPkcs5PaddingAnd128BitSaltKey(0, Base64.getDecoder().decode("aic7QGYCCSHyy7gYRCyNTpPThbomw1/dtWl4bocyTnU="));

    try {
        mongoTemplate.find(query(where(MONGO_NONSENSITIVEDATA).is(getClass().getSimpleName())), MyBean.class);
    } catch (DocumentCryptException e) {
        assertCryptException(e, "mybean", null, "secretString");
        throw e;
    }
}
 
Example 7
@Test
@DirtiesContext
public void getCFTaskLog() {
	String platformName = "cf-test-platform";
	String taskDefinitionName = "test";
	String taskDeploymentId = "12345";
	TaskDeployment taskDeployment = new TaskDeployment();
	taskDeployment.setPlatformName(platformName);
	taskDeployment.setTaskDefinitionName(taskDefinitionName);
	taskDeployment.setTaskDeploymentId(taskDeploymentId);
	this.taskDeploymentRepository.save(taskDeployment);
	this.launcherRepository.save(new Launcher(platformName,
			TaskPlatformFactory.CLOUDFOUNDRY_PLATFORM_TYPE, taskLauncher));
	when(taskLauncher.getLog(taskDefinitionName)).thenReturn("Logs");
	assertEquals("Logs", this.taskExecutionService.getLog(taskDeployment.getPlatformName(), taskDeploymentId));
}
 
Example 8
@Test
@DirtiesContext
public void startTaskExecutionWithParent() {
	TaskExecution expectedTaskExecution = TaskExecutionCreator
			.createAndStoreEmptyTaskExecution(this.taskRepository);

	expectedTaskExecution.setStartTime(new Date());
	expectedTaskExecution.setTaskName(UUID.randomUUID().toString());
	expectedTaskExecution.setParentExecutionId(12345L);

	TaskExecution actualTaskExecution = this.taskRepository.startTaskExecution(
			expectedTaskExecution.getExecutionId(),
			expectedTaskExecution.getTaskName(), expectedTaskExecution.getStartTime(),
			expectedTaskExecution.getArguments(),
			expectedTaskExecution.getExternalExecutionId(),
			expectedTaskExecution.getParentExecutionId());

	TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, actualTaskExecution);
}
 
Example 9
/**
 * This test is a special use-case. While not common, it is theoretically possible,
 * that a task may have executed with the exact same start time multiple times. In
 * that case we should still only get 1 returned {@link TaskExecution}.
 */
@Test
@DirtiesContext
public void getLatestTaskExecutionsByTaskNamesWithIdenticalTaskExecutions() {
	long executionIdOffset = initializeRepositoryNotInOrderWithMultipleTaskExecutions();
	final List<TaskExecution> latestTaskExecutions = this.dao
			.getLatestTaskExecutionsByTaskNames("FOO5");
	assertThat(latestTaskExecutions.size() == 1).as(
			"Expected only 1 taskExecution but got " + latestTaskExecutions.size())
			.isTrue();

	final Calendar dateTime = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
	dateTime.setTime(latestTaskExecutions.get(0).getStartTime());

	assertThat(dateTime.get(Calendar.YEAR)).isEqualTo(2015);
	assertThat(dateTime.get(Calendar.MONTH) + 1).isEqualTo(2);
	assertThat(dateTime.get(Calendar.DAY_OF_MONTH)).isEqualTo(22);
	assertThat(dateTime.get(Calendar.HOUR_OF_DAY)).isEqualTo(23);
	assertThat(dateTime.get(Calendar.MINUTE)).isEqualTo(59);
	assertThat(dateTime.get(Calendar.SECOND)).isEqualTo(0);
	assertThat(latestTaskExecutions.get(0).getExecutionId())
			.isEqualTo(9 + executionIdOffset);
}
 
Example 10
Source Project: spring-boot-rest-api-helpers   Source File: filterByTests.java    License: MIT License 6 votes vote down vote up
@Test
@DirtiesContext(methodMode = DirtiesContext.MethodMode.BEFORE_METHOD)
public void fetch_by_multiple_ids__fetch_movies_by_ids() {
    Movie matrix = new Movie();
    matrix.setName("The Matrix");
    movieRepository.save(matrix);

    Movie constantine = new Movie();
    constantine.setName("Constantine");
    movieRepository.save(constantine);

    Movie it = new Movie();
    it.setName("IT");
    movieRepository.save(it);

    Iterable<Movie> moviesById = movieController.filterBy("{ id: ["+matrix.getId()+","+constantine.getId()+"]}", null, null);
    Assert.assertEquals(2, IterableUtil.sizeOf(moviesById));
}
 
Example 11
@Test
@DirtiesContext
public void whenConfigurationChangedThenMemcachedClientReinitialized() {
    Object beforeRefresh = ReflectionTestUtils.getField(cacheManager, "memcachedClient");
    assertMemcachedClient((IMemcachedClient) beforeRefresh);

    TestPropertyValues.of(
        "memcached.cache.prefix:test-prefix",
        "memcached.cache.protocol:binary"
    ).applyTo(environment);

    refresher.refresh();

    Object expiration = ReflectionTestUtils.getField(cacheManager, "expiration");
    Object prefix = ReflectionTestUtils.getField(cacheManager, "prefix");
    Object afterRefresh = ReflectionTestUtils.getField(cacheManager, "memcachedClient");

    assertThat(expiration).isNotNull();
    assertThat(expiration).isEqualTo(Default.EXPIRATION);
    assertThat(prefix).isNotNull();
    assertThat(prefix).isEqualTo("test-prefix");
    assertMemcachedClient((IMemcachedClient) afterRefresh,
            MemcachedCacheProperties.Protocol.BINARY, Default.OPERATION_TIMEOUT);
}
 
Example 12
@Test
@DirtiesContext
public void testStartTaskExecution() {
	TaskExecution expectedTaskExecution = this.dao.createTaskExecution(null, null,
			new ArrayList<>(0), null);

	expectedTaskExecution.setArguments(
			Collections.singletonList("foo=" + UUID.randomUUID().toString()));
	expectedTaskExecution.setStartTime(new Date());
	expectedTaskExecution.setTaskName(UUID.randomUUID().toString());

	this.dao.startTaskExecution(expectedTaskExecution.getExecutionId(),
			expectedTaskExecution.getTaskName(), expectedTaskExecution.getStartTime(),
			expectedTaskExecution.getArguments(),
			expectedTaskExecution.getExternalExecutionId());

	TestVerifierUtils.verifyTaskExecution(expectedTaskExecution,
			TestDBUtils.getTaskExecutionFromDB(this.dataSource,
					expectedTaskExecution.getExecutionId()));
}
 
Example 13
Source Project: score   Source File: PartitionTemplateWithEmfTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@DirtiesContext
public void updatePartitionGroup() {
    service.createPartitionGroup(tableName, Integer.MAX_VALUE, Long.MAX_VALUE, Long.MAX_VALUE);

    final String newGroupName = "newName";
    final int newGroupSize = 10;
    final int newTimeThreshold = 20;
    final int newSizeThreshold = 30;

    service.updatePartitionGroup(newGroupName, newGroupSize, newTimeThreshold, newSizeThreshold);

    applicationContext.getBean(tableName, PartitionTemplate.class);
    PartitionGroup partitionGroup = service.readPartitionGroup(tableName);
    assertThat(partitionGroup.getName().equals(newGroupName));
    assertThat(partitionGroup.getGroupSize() == newGroupSize);
    assertThat(partitionGroup.getSizeThreshold() == newTimeThreshold);
    assertThat(partitionGroup.getSizeThreshold() == newSizeThreshold);
}
 
Example 14
Source Project: difido-reports   Source File: CreateElementsIT.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@DirtiesContext(classMode = ClassMode.BEFORE_EACH_TEST_METHOD)
public void testAddReportElement() throws Exception {
	ReportElement element = new ReportElement(details);
	element.setType(ElementType.regular);
	element.setTime("00:00");
	final String title = "My report element";
	element.setTitle(title);
	final String message = "My report element message";
	element.setMessage(message);
	details.addReportElement(element);
	client.addTestDetails(executionId, details);

	waitForTasksToFinish();
	final TestDetails testDetails = assertExecution();
	element = testDetails.getReportElements().get(0);
	Assert.assertEquals(ElementType.regular, element.getType());
	Assert.assertEquals(title, element.getTitle());
	Assert.assertEquals(message, element.getMessage());

}
 
Example 15
@DirtiesContext
@Test
public void retryFailedExecutionOnNonRestartableJob() throws Exception {
	this.job = this.jobs.get("job").preventRestart()
			.start(this.steps.get("step").tasklet(throwingTasklet()).build())
			.incrementer(new RunIdIncrementer()).build();
	runFailedJob(new JobParameters());
	runFailedJob(new JobParameters());
	// A failed job that is not restartable does not re-use the job params of
	// the last execution, but creates a new job instance when running it again.
	assertThat(this.jobExplorer.getJobInstances("job", 0, 100)).hasSize(2);

	// try to re-run a failed execution
	Executable executable = () -> this.runner.execute(this.job,
			new JobParametersBuilder().addLong("run.id", 1L).toJobParameters());
	assertThatExceptionOfType(JobRestartException.class)
			.isThrownBy(executable::execute)
			.withMessage("JobInstance already exists and is not restartable");
}
 
Example 16
@Test
@DirtiesContext
public void startTaskExecutionWithNoParam() {
	TaskExecution expectedTaskExecution = TaskExecutionCreator
			.createAndStoreEmptyTaskExecution(this.taskRepository);

	expectedTaskExecution.setStartTime(new Date());
	expectedTaskExecution.setTaskName(UUID.randomUUID().toString());

	TaskExecution actualTaskExecution = this.taskRepository.startTaskExecution(
			expectedTaskExecution.getExecutionId(),
			expectedTaskExecution.getTaskName(), expectedTaskExecution.getStartTime(),
			expectedTaskExecution.getArguments(),
			expectedTaskExecution.getExternalExecutionId());

	TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, actualTaskExecution);
}
 
Example 17
Source Project: difido-reports   Source File: CreateElementsIT.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@DirtiesContext(classMode = ClassMode.BEFORE_EACH_TEST_METHOD)
public void measureAddReportElements() throws Exception {
	ReportElement element = null;
	for (int i = 0; i < NUM_OF_REPORTS_ELEMENTS; i++) {
		element = new ReportElement(details);
		element.setType(ElementType.regular);
		element.setTime("00:" + i);
		element.setTitle("My report element " + i);
		details.addReportElement(element);
		long start = System.currentTimeMillis();
		client.addTestDetails(executionId, details);
		System.out.println("Element was added in " + (System.currentTimeMillis() - start) + " millis");
	}
	waitForTasksToFinish();
	assertExecution();
	System.out.println("End");

}
 
Example 18
@Test
@DirtiesContext
public void executeSingleTaskDefaultsToExistingSinglePlatformTest() {
	initializeSuccessfulRegistry(appRegistry);
	when(taskLauncher.launch(any())).thenReturn("0");
	assertEquals(1L, this.taskExecutionService.executeTask(TASK_NAME_ORIG, new HashMap<>(), new LinkedList<>()));

	TaskDeployment taskDeployment = taskDeploymentRepository.findByTaskDeploymentId("0");
	assertNotNull("TaskDeployment should not be null", taskDeployment);
	assertEquals("0", taskDeployment.getTaskDeploymentId());
	assertEquals(TASK_NAME_ORIG, taskDeployment.getTaskDefinitionName());
	assertEquals("fakeplatformname", taskDeployment.getPlatformName());
	assertNotNull("TaskDeployment createdOn field should not be null", taskDeployment.getCreatedOn());
}
 
Example 19
@Test
@DirtiesContext
public void testSaveOrUpdateAttributeWritable() throws Exception {
	Filter filter;
	List<InternalFeature> oldFeatures;
	List<InternalFeature> newFeatures;
	InternalFeature feature;
	CoordinateReferenceSystem crs = beanLayer.getCrs();

	login("marino");
	filter = filterService.createFidFilter(new String[]{"1"});
	oldFeatures = layerService.getFeatures(LAYER_ID, crs, filter, null,
			VectorLayerService.FEATURE_INCLUDE_ATTRIBUTES);
	Assert.assertEquals(1, oldFeatures.size());
	feature = oldFeatures.get(0);
	newFeatures = new ArrayList<InternalFeature>();
	feature = feature.clone();
	newFeatures.add(feature);
	feature.getAttributes().put(STRING_ATTR, new StringAttribute("changed"));
	feature.getAttributes().put(INTEGER_ATTR, new IntegerAttribute(12345));
	layerService.saveOrUpdate(LAYER_ID, crs, oldFeatures, newFeatures);
	// check changes
	filter = filterService.createFidFilter(new String[]{"1"});
	oldFeatures = layerService.getFeatures(LAYER_ID, crs, filter, null,
			VectorLayerService.FEATURE_INCLUDE_ATTRIBUTES);
	Assert.assertEquals(1, oldFeatures.size());
	feature = oldFeatures.get(0);
	Assert.assertEquals("bean1", feature.getAttributes().get(STRING_ATTR).getValue()); // org value, not updated		
	Assert.assertEquals(12345, feature.getAttributes().get(INTEGER_ATTR).getValue()); // updated
}
 
Example 20
Source Project: spring-boot-rest-api-helpers   Source File: filterByTests.java    License: MIT License 5 votes vote down vote up
@Test
@DirtiesContext(methodMode = DirtiesContext.MethodMode.BEFORE_METHOD)
public void filter_by_primary_key_that_is_native_uuid() {
    UUIDEntity entity1 = new UUIDEntity();
    uuidEntityRepository.save(entity1);

    UUIDEntity entity2 = new UUIDEntity();
    uuidEntityRepository.save(entity2);

    Iterable<UUIDEntity> entitiesByUuid = uuidEntityController.filterBy("{uuid: "+entity1.getUuid()+"}", null, null);
    Assert.assertEquals(1, IterableUtil.sizeOf(entitiesByUuid));
}
 
Example 21
@DirtiesContext
@Test
public void _0_givenNumber_whenAddAndAccumulate_thenSummedUp() {
    adderSteps.givenBaseAndAdder(randomInt(), randomInt());
    adderSteps.whenAccumulate();
    adderSteps.summedUp();

    adderSteps.whenAdd();
    adderSteps.sumWrong();
}
 
Example 22
@Test
@DirtiesContext
public void executeMultipleTasksTest() {
	initializeSuccessfulRegistry(appRegistry);
	when(taskLauncher.launch(any())).thenReturn("0");
	assertEquals(1L, this.taskExecutionService.executeTask(TASK_NAME_ORIG, new HashMap<>(), new LinkedList<>()));
	assertEquals(2L, this.taskExecutionService.executeTask(TASK_NAME_ORIG, new HashMap<>(), new LinkedList<>()));
}
 
Example 23
Source Project: spring-boot-rest-api-helpers   Source File: filterByTests.java    License: MIT License 5 votes vote down vote up
@Test
@DirtiesContext(methodMode = DirtiesContext.MethodMode.BEFORE_METHOD)
public void string_range_queries() {

    Movie constantine = new Movie();
    constantine.setName("Constantine");
    constantine.setYearReleased(2005);
    movieRepository.save(constantine);

    Movie it = new Movie();
    it.setName("IT");
    it.setYearReleased(2017);
    movieRepository.save(it);


    Movie matrix = new Movie();
    matrix.setName("The Matrix");
    matrix.setYearReleased(1999);
    movieRepository.save(matrix);


    Iterable<Movie> moviesAfterA = movieController.filterBy("{nameGt: A }", null, null);
    Assert.assertEquals(3, IterableUtil.sizeOf(moviesAfterA));

    Iterable<Movie> moviesBeforeD = movieController.filterBy("{nameLt: D }", null, null);
    Assert.assertEquals(1, IterableUtil.sizeOf(moviesBeforeD));

    Iterable<Movie> moviesAfterDBeforeM = movieController.filterBy("{nameGt: D, nameLt:M }", null, null);
    Assert.assertEquals(1, IterableUtil.sizeOf(moviesAfterDBeforeM));

}
 
Example 24
@Test
@DirtiesContext
public void getLatestTaskExecutionsByTaskNamesWithArrayParametersContainingNullAndEmptyValues() {
	try {
		this.dao.getLatestTaskExecutionsByTaskNames("foo", null, "bar", " ");
	}
	catch (IllegalArgumentException e) {
		assertThat(e.getMessage()).isEqualTo(
				"Task names must not contain any empty elements but 2 of 4 were empty or null.");
		return;
	}
	fail("Expected an IllegalArgumentException to be thrown.");
}
 
Example 25
@Test
@DirtiesContext
public void lineFixerTest() {
    jobLauncher.launchJob();
    try {
        testUtils.waitForEsReady(30000);
    } catch (RuntimeException e) {
        e.printStackTrace();
    }

    assertEquals(75,testUtils.countOutputDocsInES());
    assertEquals(75,dbmsTestUtils.countRowsInOutputTable());

}
 
Example 26
@Test
@DirtiesContext
public void basicConfigurerdStartPkPartitionWithSchedulingTest() {
    testUtils.insertFreshDataIntoBasicTableAfterDelay(env.getProperty("tblInputDocs"),15000,76,150,false);
    try {
        testUtils.waitForEsReady(30000);
    } catch (RuntimeException e) {
        e.printStackTrace();
    }
    //note, in this test, we upsert documents, overriding existng ones. hence why ther ate 75 in the index and 150
    //in the db
    assertEquals(150,testUtils.countOutputDocsInES());
    assertEquals(150,dbmsTestUtils.countRowsInOutputTable());

}
 
Example 27
Source Project: grpc-spring-boot-starter   Source File: GrpcRequestScopeTest.java    License: MIT License 5 votes vote down vote up
@Test
@DirtiesContext
public void testScope() throws InterruptedException {
    // Prepare
    ScopedStreamObserverChecker scope1 = new ScopedStreamObserverChecker();
    StreamObserver<SomeType> request1 = this.testServiceStub.secureBidi(scope1);
    ScopedStreamObserverChecker scope2 = new ScopedStreamObserverChecker();
    StreamObserver<SomeType> request2 = this.testServiceStub.secureBidi(scope2);

    // Run
    request1.onNext(SomeType.getDefaultInstance());
    request1.onNext(SomeType.getDefaultInstance());
    Thread.sleep(100);

    request2.onNext(SomeType.getDefaultInstance());
    request2.onNext(SomeType.getDefaultInstance());
    Thread.sleep(100);

    request1.onNext(SomeType.getDefaultInstance());
    request2.onNext(SomeType.getDefaultInstance());
    Thread.sleep(100);

    request2.onNext(SomeType.getDefaultInstance());
    request1.onNext(SomeType.getDefaultInstance());
    Thread.sleep(100);

    request1.onCompleted();
    request2.onCompleted();
    Thread.sleep(100);

    // Assert
    assertTrue(scope1.isCompleted());
    assertTrue(scope2.isCompleted());
    assertNull(scope1.getError());
    assertNull(scope2.getError());
    assertNotNull(scope1.getText());
    assertNotNull(scope2.getText());
    assertNotEquals(scope1.getText(), scope2.getText());
    log.debug("A: {} - B: {}", scope1.getText(), scope2.getText());
}
 
Example 28
@Test
@DirtiesContext // because we can't authenticate twice on same DB
public void newUserCreatedSuccessfully() throws MongoServiceException {
	service.createDatabase(DB_NAME);
	service.createUser(DB_NAME, "user", "password");
	
	BasicDBObject userInfoCmd = new BasicDBObject("usersInfo", "user");
	Document result = client.getDatabase(DB_NAME).runCommand(userInfoCmd);
	List users = (List) result.get("users");
	assertFalse("create should succeed", users.isEmpty());
	
	Document userDoc = (Document) users.get(0);
	
	assertEquals("user list should contain the 'user' user", "user", userDoc.get("user"));
}
 
Example 29
@Test
@DirtiesContext
public void testSimpleProperties() throws Exception {
	then(this.properties.getMessage()).isEqualTo("Hello scope!");
	// Change the dynamic property source...
	TestPropertyValues.of("message:Foo").applyTo(this.environment);
	// ...but don't refresh, so the bean stays the same:
	then(this.properties.getMessage()).isEqualTo("Hello scope!");
	then(this.properties.getCount()).isEqualTo(1);
}
 
Example 30
Source Project: grpc-spring-boot-starter   Source File: OnlyInProcessServerTest.java    License: MIT License 5 votes vote down vote up
/**
 * Test failing call for inter-process server.
 */
@Test
@DirtiesContext
public void testFailingInterProcessCall() {
    log.info("--- Starting tests with failing inter-process call ---");
    assertThrowsStatus(UNAVAILABLE, () -> newBlockingStub(this.interProcessChannel).unimplemented(EMPTY));

    final StreamRecorder<SomeType> streamRecorder = StreamRecorder.create();
    this.interProcessServiceStub.unimplemented(EMPTY, streamRecorder);
    assertFutureThrowsStatus(UNAVAILABLE, streamRecorder.firstValue(), 5, TimeUnit.SECONDS);
    assertThrowsStatus(UNAVAILABLE, () -> this.interProcessServiceBlockingStub.unimplemented(EMPTY));
    assertFutureThrowsStatus(UNAVAILABLE, this.interProcessServiceFutureStub.unimplemented(EMPTY),
            5, TimeUnit.SECONDS);
    log.info("--- Test completed ---");
}