Polishing
This commit is contained in:
		
							parent
							
								
									d5cabca2f7
								
							
						
					
					
						commit
						b089ded5b0
					
				| 
						 | 
					@ -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");
 | 
					 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
 * you may not use this file except in compliance with 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 CollectingReaderEventListener eventListener = new CollectingReaderEventListener();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private XmlBeanDefinitionReader reader;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	private DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
 | 
						private DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private XmlBeanDefinitionReader reader;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Before
 | 
						@Before
 | 
				
			||||||
	public void setUp() throws Exception {
 | 
						public void setup() {
 | 
				
			||||||
		this.reader = new XmlBeanDefinitionReader(this.beanFactory);
 | 
							this.reader = new XmlBeanDefinitionReader(this.beanFactory);
 | 
				
			||||||
		this.reader.setEventListener(this.eventListener);
 | 
							this.reader.setEventListener(this.eventListener);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void testPointcutEvents() throws Exception {
 | 
						public void testPointcutEvents() {
 | 
				
			||||||
		this.reader.loadBeanDefinitions(POINTCUT_EVENTS_CONTEXT);
 | 
							this.reader.loadBeanDefinitions(POINTCUT_EVENTS_CONTEXT);
 | 
				
			||||||
		ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
 | 
							ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
 | 
				
			||||||
		assertEquals("Incorrect number of events fired", 1, componentDefinitions.length);
 | 
							assertEquals("Incorrect number of events fired", 1, componentDefinitions.length);
 | 
				
			||||||
| 
						 | 
					@ -76,8 +76,7 @@ public class AopNamespaceHandlerEventTests {
 | 
				
			||||||
		ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents();
 | 
							ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents();
 | 
				
			||||||
		assertEquals("Incorrect number of inner components", 2, nestedComponentDefs.length);
 | 
							assertEquals("Incorrect number of inner components", 2, nestedComponentDefs.length);
 | 
				
			||||||
		PointcutComponentDefinition pcd = null;
 | 
							PointcutComponentDefinition pcd = null;
 | 
				
			||||||
		for (int i = 0; i < nestedComponentDefs.length; i++) {
 | 
							for (ComponentDefinition componentDefinition : nestedComponentDefs) {
 | 
				
			||||||
			ComponentDefinition componentDefinition = nestedComponentDefs[i];
 | 
					 | 
				
			||||||
			if (componentDefinition instanceof PointcutComponentDefinition) {
 | 
								if (componentDefinition instanceof PointcutComponentDefinition) {
 | 
				
			||||||
				pcd = (PointcutComponentDefinition) componentDefinition;
 | 
									pcd = (PointcutComponentDefinition) componentDefinition;
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
| 
						 | 
					@ -88,7 +87,7 @@ public class AopNamespaceHandlerEventTests {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void testAdvisorEventsWithPointcutRef() throws Exception {
 | 
						public void testAdvisorEventsWithPointcutRef() {
 | 
				
			||||||
		this.reader.loadBeanDefinitions(POINTCUT_REF_CONTEXT);
 | 
							this.reader.loadBeanDefinitions(POINTCUT_REF_CONTEXT);
 | 
				
			||||||
		ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
 | 
							ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
 | 
				
			||||||
		assertEquals("Incorrect number of events fired", 2, componentDefinitions.length);
 | 
							assertEquals("Incorrect number of events fired", 2, componentDefinitions.length);
 | 
				
			||||||
| 
						 | 
					@ -117,7 +116,7 @@ public class AopNamespaceHandlerEventTests {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void testAdvisorEventsWithDirectPointcut() throws Exception {
 | 
						public void testAdvisorEventsWithDirectPointcut() {
 | 
				
			||||||
		this.reader.loadBeanDefinitions(DIRECT_POINTCUT_EVENTS_CONTEXT);
 | 
							this.reader.loadBeanDefinitions(DIRECT_POINTCUT_EVENTS_CONTEXT);
 | 
				
			||||||
		ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
 | 
							ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
 | 
				
			||||||
		assertEquals("Incorrect number of events fired", 2, componentDefinitions.length);
 | 
							assertEquals("Incorrect number of events fired", 2, componentDefinitions.length);
 | 
				
			||||||
| 
						 | 
					@ -146,7 +145,7 @@ public class AopNamespaceHandlerEventTests {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void testAspectEvent() throws Exception {
 | 
						public void testAspectEvent() {
 | 
				
			||||||
		this.reader.loadBeanDefinitions(CONTEXT);
 | 
							this.reader.loadBeanDefinitions(CONTEXT);
 | 
				
			||||||
		ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
 | 
							ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
 | 
				
			||||||
		assertEquals("Incorrect number of events fired", 5, componentDefinitions.length);
 | 
							assertEquals("Incorrect number of events fired", 5, componentDefinitions.length);
 | 
				
			||||||
| 
						 | 
					@ -158,8 +157,7 @@ public class AopNamespaceHandlerEventTests {
 | 
				
			||||||
		ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents();
 | 
							ComponentDefinition[] nestedComponentDefs = compositeDef.getNestedComponents();
 | 
				
			||||||
		assertEquals("Incorrect number of inner components", 2, nestedComponentDefs.length);
 | 
							assertEquals("Incorrect number of inner components", 2, nestedComponentDefs.length);
 | 
				
			||||||
		AspectComponentDefinition acd = null;
 | 
							AspectComponentDefinition acd = null;
 | 
				
			||||||
		for (int i = 0; i < nestedComponentDefs.length; i++) {
 | 
							for (ComponentDefinition componentDefinition : nestedComponentDefs) {
 | 
				
			||||||
			ComponentDefinition componentDefinition = nestedComponentDefs[i];
 | 
					 | 
				
			||||||
			if (componentDefinition instanceof AspectComponentDefinition) {
 | 
								if (componentDefinition instanceof AspectComponentDefinition) {
 | 
				
			||||||
				acd = (AspectComponentDefinition) componentDefinition;
 | 
									acd = (AspectComponentDefinition) componentDefinition;
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
| 
						 | 
					@ -175,8 +173,7 @@ public class AopNamespaceHandlerEventTests {
 | 
				
			||||||
		Set<String> expectedReferences = new HashSet<>();
 | 
							Set<String> expectedReferences = new HashSet<>();
 | 
				
			||||||
		expectedReferences.add("pc");
 | 
							expectedReferences.add("pc");
 | 
				
			||||||
		expectedReferences.add("countingAdvice");
 | 
							expectedReferences.add("countingAdvice");
 | 
				
			||||||
		for (int i = 0; i < beanReferences.length; i++) {
 | 
							for (BeanReference beanReference : beanReferences) {
 | 
				
			||||||
			BeanReference beanReference = beanReferences[i];
 | 
					 | 
				
			||||||
			expectedReferences.remove(beanReference.getBeanName());
 | 
								expectedReferences.remove(beanReference.getBeanName());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		assertEquals("Incorrect references found", 0, expectedReferences.size());
 | 
							assertEquals("Incorrect references found", 0, expectedReferences.size());
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -310,7 +310,7 @@ public class MimeType implements Comparable<MimeType>, Serializable {
 | 
				
			||||||
		if (other == null) {
 | 
							if (other == null) {
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (this.isWildcardType()) {
 | 
							if (isWildcardType()) {
 | 
				
			||||||
			// */* includes anything
 | 
								// */* includes anything
 | 
				
			||||||
			return true;
 | 
								return true;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -318,7 +318,7 @@ public class MimeType implements Comparable<MimeType>, Serializable {
 | 
				
			||||||
			if (getSubtype().equals(other.getSubtype())) {
 | 
								if (getSubtype().equals(other.getSubtype())) {
 | 
				
			||||||
				return true;
 | 
									return true;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if (this.isWildcardSubtype()) {
 | 
								if (isWildcardSubtype()) {
 | 
				
			||||||
				// Wildcard with suffix, e.g. application/*+xml
 | 
									// Wildcard with suffix, e.g. application/*+xml
 | 
				
			||||||
				int thisPlusIdx = getSubtype().lastIndexOf('+');
 | 
									int thisPlusIdx = getSubtype().lastIndexOf('+');
 | 
				
			||||||
				if (thisPlusIdx == -1) {
 | 
									if (thisPlusIdx == -1) {
 | 
				
			||||||
| 
						 | 
					@ -362,7 +362,7 @@ public class MimeType implements Comparable<MimeType>, Serializable {
 | 
				
			||||||
				return true;
 | 
									return true;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			// Wildcard with suffix? e.g. application/*+xml
 | 
								// Wildcard with suffix? e.g. application/*+xml
 | 
				
			||||||
			if (this.isWildcardSubtype() || other.isWildcardSubtype()) {
 | 
								if (isWildcardSubtype() || other.isWildcardSubtype()) {
 | 
				
			||||||
				int thisPlusIdx = getSubtype().lastIndexOf('+');
 | 
									int thisPlusIdx = getSubtype().lastIndexOf('+');
 | 
				
			||||||
				int otherPlusIdx = other.getSubtype().lastIndexOf('+');
 | 
									int otherPlusIdx = other.getSubtype().lastIndexOf('+');
 | 
				
			||||||
				if (thisPlusIdx == -1 && otherPlusIdx == -1) {
 | 
									if (thisPlusIdx == -1 && otherPlusIdx == -1) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -70,7 +70,7 @@ public class MimeTypeTests {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void parseCharset() throws Exception {
 | 
						public void parseCharset() {
 | 
				
			||||||
		String s = "text/html; charset=iso-8859-1";
 | 
							String s = "text/html; charset=iso-8859-1";
 | 
				
			||||||
		MimeType mimeType = MimeType.valueOf(s);
 | 
							MimeType mimeType = MimeType.valueOf(s);
 | 
				
			||||||
		assertEquals("Invalid type", "text", mimeType.getType());
 | 
							assertEquals("Invalid type", "text", mimeType.getType());
 | 
				
			||||||
| 
						 | 
					@ -106,7 +106,7 @@ public class MimeTypeTests {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void includes() throws Exception {
 | 
						public void includes() {
 | 
				
			||||||
		MimeType textPlain = MimeTypeUtils.TEXT_PLAIN;
 | 
							MimeType textPlain = MimeTypeUtils.TEXT_PLAIN;
 | 
				
			||||||
		assertTrue("Equal types is not inclusive", textPlain.includes(textPlain));
 | 
							assertTrue("Equal types is not inclusive", textPlain.includes(textPlain));
 | 
				
			||||||
		MimeType allText = new MimeType("text");
 | 
							MimeType allText = new MimeType("text");
 | 
				
			||||||
| 
						 | 
					@ -136,7 +136,7 @@ public class MimeTypeTests {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void isCompatible() throws Exception {
 | 
						public void isCompatible() {
 | 
				
			||||||
		MimeType textPlain = MimeTypeUtils.TEXT_PLAIN;
 | 
							MimeType textPlain = MimeTypeUtils.TEXT_PLAIN;
 | 
				
			||||||
		assertTrue("Equal types is not compatible", textPlain.isCompatibleWith(textPlain));
 | 
							assertTrue("Equal types is not compatible", textPlain.isCompatibleWith(textPlain));
 | 
				
			||||||
		MimeType allText = new MimeType("text");
 | 
							MimeType allText = new MimeType("text");
 | 
				
			||||||
| 
						 | 
					@ -166,14 +166,14 @@ public class MimeTypeTests {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void testToString() throws Exception {
 | 
						public void testToString() {
 | 
				
			||||||
		MimeType mimeType = new MimeType("text", "plain");
 | 
							MimeType mimeType = new MimeType("text", "plain");
 | 
				
			||||||
		String result = mimeType.toString();
 | 
							String result = mimeType.toString();
 | 
				
			||||||
		assertEquals("Invalid toString() returned", "text/plain", result);
 | 
							assertEquals("Invalid toString() returned", "text/plain", result);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void parseMimeType() throws Exception {
 | 
						public void parseMimeType() {
 | 
				
			||||||
		String s = "audio/*";
 | 
							String s = "audio/*";
 | 
				
			||||||
		MimeType mimeType = MimeTypeUtils.parseMimeType(s);
 | 
							MimeType mimeType = MimeTypeUtils.parseMimeType(s);
 | 
				
			||||||
		assertEquals("Invalid type", "audio", mimeType.getType());
 | 
							assertEquals("Invalid type", "audio", mimeType.getType());
 | 
				
			||||||
| 
						 | 
					@ -206,7 +206,7 @@ public class MimeTypeTests {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test(expected = InvalidMimeTypeException.class)
 | 
						@Test(expected = InvalidMimeTypeException.class)
 | 
				
			||||||
	public void parseMimeTypeMissingTypeAndSubtype() throws Exception {
 | 
						public void parseMimeTypeMissingTypeAndSubtype() {
 | 
				
			||||||
		MimeTypeUtils.parseMimeType("     ;a=b");
 | 
							MimeTypeUtils.parseMimeType("     ;a=b");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -235,19 +235,13 @@ public class MimeTypeTests {
 | 
				
			||||||
		MimeTypeUtils.parseMimeType("text/html; charset=foo-bar");
 | 
							MimeTypeUtils.parseMimeType("text/html; charset=foo-bar");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						@Test  // SPR-8917
 | 
				
			||||||
	 * SPR-8917
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	@Test
 | 
					 | 
				
			||||||
	public void parseMimeTypeQuotedParameterValue() {
 | 
						public void parseMimeTypeQuotedParameterValue() {
 | 
				
			||||||
		MimeType mimeType = MimeTypeUtils.parseMimeType("audio/*;attr=\"v>alue\"");
 | 
							MimeType mimeType = MimeTypeUtils.parseMimeType("audio/*;attr=\"v>alue\"");
 | 
				
			||||||
		assertEquals("\"v>alue\"", mimeType.getParameter("attr"));
 | 
							assertEquals("\"v>alue\"", mimeType.getParameter("attr"));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						@Test  // SPR-8917
 | 
				
			||||||
	 * SPR-8917
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	@Test
 | 
					 | 
				
			||||||
	public void parseMimeTypeSingleQuotedParameterValue() {
 | 
						public void parseMimeTypeSingleQuotedParameterValue() {
 | 
				
			||||||
		MimeType mimeType = MimeTypeUtils.parseMimeType("audio/*;attr='v>alue'");
 | 
							MimeType mimeType = MimeTypeUtils.parseMimeType("audio/*;attr='v>alue'");
 | 
				
			||||||
		assertEquals("'v>alue'", mimeType.getParameter("attr"));
 | 
							assertEquals("'v>alue'", mimeType.getParameter("attr"));
 | 
				
			||||||
| 
						 | 
					@ -259,7 +253,7 @@ public class MimeTypeTests {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
	public void parseMimeTypes() throws Exception {
 | 
						public void parseMimeTypes() {
 | 
				
			||||||
		String s = "text/plain, text/html, text/x-dvi, text/x-c";
 | 
							String s = "text/plain, text/html, text/x-dvi, text/x-c";
 | 
				
			||||||
		List<MimeType> mimeTypes = MimeTypeUtils.parseMimeTypes(s);
 | 
							List<MimeType> mimeTypes = MimeTypeUtils.parseMimeTypes(s);
 | 
				
			||||||
		assertNotNull("No mime types returned", mimeTypes);
 | 
							assertNotNull("No mime types returned", mimeTypes);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue