类org.springframework.core.annotation.AnnotationConfigurationException源码实例Demo

下面列出了怎么用org.springframework.core.annotation.AnnotationConfigurationException的API类实例代码及写法,或者点击链接到github查看源代码。

@Test
public void valueAndScriptsDeclared() throws Exception {
	Class<?> clazz = ValueAndScriptsDeclared.class;
	BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz);
	given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("foo"));

	assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
			listener.beforeTestMethod(testContext))
		.withMessageContaining("Different @AliasFor mirror values")
		.withMessageContaining("attribute 'scripts' and its alias 'value'")
		.withMessageContaining("values of [{bar}] and [{foo}]");
}
 
@Test
public void resolveConfigAttributesWithConflictingLocations() {
	assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
			resolveContextConfigurationAttributes(ConflictingLocations.class))
		.withMessageStartingWith("Different @AliasFor mirror values")
		.withMessageContaining(ConflictingLocations.class.getName())
		.withMessageContaining("attribute 'locations' and its alias 'value'")
		.withMessageContaining("values of [{y}] and [{x}]");
}
 
@Test
public void valueAndScriptsDeclared() throws Exception {
	Class<?> clazz = ValueAndScriptsDeclared.class;
	BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz);
	given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("foo"));

	exception.expect(AnnotationConfigurationException.class);
	exception.expectMessage(either(
			containsString("attribute 'value' and its alias 'scripts'")).or(
			containsString("attribute 'scripts' and its alias 'value'")));
	exception.expectMessage(either(containsString("values of [{foo}] and [{bar}]")).or(
			containsString("values of [{bar}] and [{foo}]")));
	exception.expectMessage(containsString("but only one is permitted"));
	listener.beforeTestMethod(testContext);
}
 
@Test
public void resolveConfigAttributesWithConflictingLocations() {
	exception.expect(AnnotationConfigurationException.class);
	exception.expectMessage(containsString(ConflictingLocations.class.getName()));
	exception.expectMessage(either(
			containsString("attribute 'value' and its alias 'locations'")).or(
			containsString("attribute 'locations' and its alias 'value'")));
	exception.expectMessage(either(
			containsString("values of [{x}] and [{y}]")).or(
			containsString("values of [{y}] and [{x}]")));
	exception.expectMessage(containsString("but only one is permitted"));
	resolveContextConfigurationAttributes(ConflictingLocations.class);
}
 
@Test
public void valueAndScriptsDeclared() throws Exception {
	Class<?> clazz = ValueAndScriptsDeclared.class;
	BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz);
	given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("foo"));

	exception.expect(AnnotationConfigurationException.class);
	exception.expectMessage(either(
			containsString("attribute 'value' and its alias 'scripts'")).or(
			containsString("attribute 'scripts' and its alias 'value'")));
	exception.expectMessage(either(containsString("values of [{foo}] and [{bar}]")).or(
			containsString("values of [{bar}] and [{foo}]")));
	exception.expectMessage(containsString("but only one is permitted"));
	listener.beforeTestMethod(testContext);
}
 
@Test
public void resolveConfigAttributesWithConflictingLocations() {
	exception.expect(AnnotationConfigurationException.class);
	exception.expectMessage(containsString(ConflictingLocations.class.getName()));
	exception.expectMessage(either(
			containsString("attribute 'value' and its alias 'locations'")).or(
			containsString("attribute 'locations' and its alias 'value'")));
	exception.expectMessage(either(
			containsString("values of [{x}] and [{y}]")).or(
			containsString("values of [{y}] and [{x}]")));
	exception.expectMessage(containsString("but only one is permitted"));
	resolveContextConfigurationAttributes(ConflictingLocations.class);
}
 
@Test(expected = AnnotationConfigurationException.class)
public void listenersAndValueAttributesDeclared() {
	new TestContextManager(DuplicateListenersConfigTestCase.class);
}
 
/**
 * @since 4.0
 */
@Test(expected = AnnotationConfigurationException.class)
public void resolveActiveProfilesWithConflictingProfilesAndValue() {
	resolveActiveProfiles(ConflictingProfilesAndValueTestCase.class);
}
 
@Test
public void locationsAndValueAttributes() {
	assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
			buildMergedTestPropertySources(LocationsAndValuePropertySources.class));
}
 
@Test(expected = AnnotationConfigurationException.class)
public void listenersAndValueAttributesDeclared() {
	new TestContextManager(DuplicateListenersConfigTestCase.class);
}
 
/**
 * @since 4.0
 */
@Test(expected = AnnotationConfigurationException.class)
public void resolveActiveProfilesWithConflictingProfilesAndValue() {
	resolveActiveProfiles(ConflictingProfilesAndValueTestCase.class);
}
 
@Test
public void locationsAndValueAttributes() {
	expectedException.expect(AnnotationConfigurationException.class);
	buildMergedTestPropertySources(LocationsAndValuePropertySources.class);
}
 
@Test(expected = AnnotationConfigurationException.class)
public void listenersAndValueAttributesDeclared() {
	new TestContextManager(DuplicateListenersConfigTestCase.class);
}
 
/**
 * @since 4.0
 */
@Test(expected = AnnotationConfigurationException.class)
public void resolveActiveProfilesWithConflictingProfilesAndValue() {
	resolveActiveProfiles(ConflictingProfilesAndValueTestCase.class);
}
 
@Test
public void locationsAndValueAttributes() {
	expectedException.expect(AnnotationConfigurationException.class);
	buildMergedTestPropertySources(LocationsAndValuePropertySources.class);
}
 
 类所在包
 类方法
 同包方法