Polishing

This commit is contained in:
Juergen Hoeller 2018-02-12 15:55:18 +01:00
parent d5cabca2f7
commit b089ded5b0
3 changed files with 23 additions and 32 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -51,20 +51,20 @@ public class AopNamespaceHandlerEventTests {
private CollectingReaderEventListener eventListener = new CollectingReaderEventListener();
private XmlBeanDefinitionReader reader;
private DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
private XmlBeanDefinitionReader reader;
@Before
public void setUp() throws Exception {
public void setup() {
this.reader = new XmlBeanDefinitionReader(this.beanFactory);
this.reader.setEventListener(this.eventListener);
}
@Test
public void testPointcutEvents() throws Exception {
public void testPointcutEvents() {
this.reader.loadBeanDefinitions(POINTCUT_EVENTS_CONTEXT);
ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
assertEquals("Incorrect number of events fired", 1, componentDefinitions.length);
@ -76,8 +76,7 @@ public class AopNamespaceHandlerEventTests {
ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents();
assertEquals("Incorrect number of inner components", 2, nestedComponentDefs.length);
PointcutComponentDefinition pcd = null;
for (int i = 0; i < nestedComponentDefs.length; i++) {
ComponentDefinition componentDefinition = nestedComponentDefs[i];
for (ComponentDefinition componentDefinition : nestedComponentDefs) {
if (componentDefinition instanceof PointcutComponentDefinition) {
pcd = (PointcutComponentDefinition) componentDefinition;
break;
@ -88,7 +87,7 @@ public class AopNamespaceHandlerEventTests {
}
@Test
public void testAdvisorEventsWithPointcutRef() throws Exception {
public void testAdvisorEventsWithPointcutRef() {
this.reader.loadBeanDefinitions(POINTCUT_REF_CONTEXT);
ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
assertEquals("Incorrect number of events fired", 2, componentDefinitions.length);
@ -117,7 +116,7 @@ public class AopNamespaceHandlerEventTests {
}
@Test
public void testAdvisorEventsWithDirectPointcut() throws Exception {
public void testAdvisorEventsWithDirectPointcut() {
this.reader.loadBeanDefinitions(DIRECT_POINTCUT_EVENTS_CONTEXT);
ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
assertEquals("Incorrect number of events fired", 2, componentDefinitions.length);
@ -146,7 +145,7 @@ public class AopNamespaceHandlerEventTests {
}
@Test
public void testAspectEvent() throws Exception {
public void testAspectEvent() {
this.reader.loadBeanDefinitions(CONTEXT);
ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
assertEquals("Incorrect number of events fired", 5, componentDefinitions.length);
@ -158,8 +157,7 @@ public class AopNamespaceHandlerEventTests {
ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents();
assertEquals("Incorrect number of inner components", 2, nestedComponentDefs.length);
AspectComponentDefinition acd = null;
for (int i = 0; i < nestedComponentDefs.length; i++) {
ComponentDefinition componentDefinition = nestedComponentDefs[i];
for (ComponentDefinition componentDefinition : nestedComponentDefs) {
if (componentDefinition instanceof AspectComponentDefinition) {
acd = (AspectComponentDefinition) componentDefinition;
break;
@ -175,8 +173,7 @@ public class AopNamespaceHandlerEventTests {
Set<String> expectedReferences = new HashSet<>();
expectedReferences.add("pc");
expectedReferences.add("countingAdvice");
for (int i = 0; i < beanReferences.length; i++) {
BeanReference beanReference = beanReferences[i];
for (BeanReference beanReference : beanReferences) {
expectedReferences.remove(beanReference.getBeanName());
}
assertEquals("Incorrect references found", 0, expectedReferences.size());

View File

@ -310,7 +310,7 @@ public class MimeType implements Comparable<MimeType>, Serializable {
if (other == null) {
return false;
}
if (this.isWildcardType()) {
if (isWildcardType()) {
// */* includes anything
return true;
}
@ -318,7 +318,7 @@ public class MimeType implements Comparable<MimeType>, Serializable {
if (getSubtype().equals(other.getSubtype())) {
return true;
}
if (this.isWildcardSubtype()) {
if (isWildcardSubtype()) {
// Wildcard with suffix, e.g. application/*+xml
int thisPlusIdx = getSubtype().lastIndexOf('+');
if (thisPlusIdx == -1) {
@ -362,7 +362,7 @@ public class MimeType implements Comparable<MimeType>, Serializable {
return true;
}
// Wildcard with suffix? e.g. application/*+xml
if (this.isWildcardSubtype() || other.isWildcardSubtype()) {
if (isWildcardSubtype() || other.isWildcardSubtype()) {
int thisPlusIdx = getSubtype().lastIndexOf('+');
int otherPlusIdx = other.getSubtype().lastIndexOf('+');
if (thisPlusIdx == -1 && otherPlusIdx == -1) {

View File

@ -70,7 +70,7 @@ public class MimeTypeTests {
}
@Test
public void parseCharset() throws Exception {
public void parseCharset() {
String s = "text/html; charset=iso-8859-1";
MimeType mimeType = MimeType.valueOf(s);
assertEquals("Invalid type", "text", mimeType.getType());
@ -106,7 +106,7 @@ public class MimeTypeTests {
}
@Test
public void includes() throws Exception {
public void includes() {
MimeType textPlain = MimeTypeUtils.TEXT_PLAIN;
assertTrue("Equal types is not inclusive", textPlain.includes(textPlain));
MimeType allText = new MimeType("text");
@ -136,7 +136,7 @@ public class MimeTypeTests {
}
@Test
public void isCompatible() throws Exception {
public void isCompatible() {
MimeType textPlain = MimeTypeUtils.TEXT_PLAIN;
assertTrue("Equal types is not compatible", textPlain.isCompatibleWith(textPlain));
MimeType allText = new MimeType("text");
@ -166,14 +166,14 @@ public class MimeTypeTests {
}
@Test
public void testToString() throws Exception {
public void testToString() {
MimeType mimeType = new MimeType("text", "plain");
String result = mimeType.toString();
assertEquals("Invalid toString() returned", "text/plain", result);
}
@Test
public void parseMimeType() throws Exception {
public void parseMimeType() {
String s = "audio/*";
MimeType mimeType = MimeTypeUtils.parseMimeType(s);
assertEquals("Invalid type", "audio", mimeType.getType());
@ -206,7 +206,7 @@ public class MimeTypeTests {
}
@Test(expected = InvalidMimeTypeException.class)
public void parseMimeTypeMissingTypeAndSubtype() throws Exception {
public void parseMimeTypeMissingTypeAndSubtype() {
MimeTypeUtils.parseMimeType(" ;a=b");
}
@ -235,19 +235,13 @@ public class MimeTypeTests {
MimeTypeUtils.parseMimeType("text/html; charset=foo-bar");
}
/**
* SPR-8917
*/
@Test
@Test // SPR-8917
public void parseMimeTypeQuotedParameterValue() {
MimeType mimeType = MimeTypeUtils.parseMimeType("audio/*;attr=\"v>alue\"");
assertEquals("\"v>alue\"", mimeType.getParameter("attr"));
}
/**
* SPR-8917
*/
@Test
@Test // SPR-8917
public void parseMimeTypeSingleQuotedParameterValue() {
MimeType mimeType = MimeTypeUtils.parseMimeType("audio/*;attr='v>alue'");
assertEquals("'v>alue'", mimeType.getParameter("attr"));
@ -259,7 +253,7 @@ public class MimeTypeTests {
}
@Test
public void parseMimeTypes() throws Exception {
public void parseMimeTypes() {
String s = "text/plain, text/html, text/x-dvi, text/x-c";
List<MimeType> mimeTypes = MimeTypeUtils.parseMimeTypes(s);
assertNotNull("No mime types returned", mimeTypes);