parent
9da15ee23a
commit
1a13700f8b
|
@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
|
||||||
import test.aop.PerTargetAspect;
|
import test.aop.PerTargetAspect;
|
||||||
|
|
||||||
import org.springframework.aop.Pointcut;
|
import org.springframework.aop.Pointcut;
|
||||||
|
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
|
||||||
import org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.ExceptionAspect;
|
import org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.ExceptionAspect;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
@ -30,36 +31,43 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
|
* @author Sam Brannen
|
||||||
*/
|
*/
|
||||||
public class AspectMetadataTests {
|
class AspectMetadataTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNotAnAspect() {
|
void notAnAspect() {
|
||||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
assertThatIllegalArgumentException().isThrownBy(() -> new AspectMetadata(String.class, "someBean"));
|
||||||
new AspectMetadata(String.class,"someBean"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSingletonAspect() {
|
void singletonAspect() {
|
||||||
AspectMetadata am = new AspectMetadata(ExceptionAspect.class,"someBean");
|
AspectMetadata am = new AspectMetadata(ExceptionAspect.class, "someBean");
|
||||||
assertThat(am.isPerThisOrPerTarget()).isFalse();
|
assertThat(am.isPerThisOrPerTarget()).isFalse();
|
||||||
assertThat(am.getPerClausePointcut()).isSameAs(Pointcut.TRUE);
|
assertThat(am.getPerClausePointcut()).isSameAs(Pointcut.TRUE);
|
||||||
assertThat(am.getAjType().getPerClause().getKind()).isEqualTo(PerClauseKind.SINGLETON);
|
assertThat(am.getAjType().getPerClause().getKind()).isEqualTo(PerClauseKind.SINGLETON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPerTargetAspect() {
|
void perTargetAspect() {
|
||||||
AspectMetadata am = new AspectMetadata(PerTargetAspect.class,"someBean");
|
AspectMetadata am = new AspectMetadata(PerTargetAspect.class, "someBean");
|
||||||
assertThat(am.isPerThisOrPerTarget()).isTrue();
|
assertThat(am.isPerThisOrPerTarget()).isTrue();
|
||||||
assertThat(am.getPerClausePointcut()).isNotSameAs(Pointcut.TRUE);
|
assertThat(am.getPerClausePointcut()).isNotSameAs(Pointcut.TRUE);
|
||||||
assertThat(am.getAjType().getPerClause().getKind()).isEqualTo(PerClauseKind.PERTARGET);
|
assertThat(am.getAjType().getPerClause().getKind()).isEqualTo(PerClauseKind.PERTARGET);
|
||||||
|
assertThat(am.getPerClausePointcut()).isInstanceOf(AspectJExpressionPointcut.class);
|
||||||
|
assertThat(((AspectJExpressionPointcut) am.getPerClausePointcut()).getExpression())
|
||||||
|
.isEqualTo("execution(* *.getSpouse())");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPerThisAspect() {
|
void perThisAspect() {
|
||||||
AspectMetadata am = new AspectMetadata(PerThisAspect.class,"someBean");
|
AspectMetadata am = new AspectMetadata(PerThisAspect.class, "someBean");
|
||||||
assertThat(am.isPerThisOrPerTarget()).isTrue();
|
assertThat(am.isPerThisOrPerTarget()).isTrue();
|
||||||
assertThat(am.getPerClausePointcut()).isNotSameAs(Pointcut.TRUE);
|
assertThat(am.getPerClausePointcut()).isNotSameAs(Pointcut.TRUE);
|
||||||
assertThat(am.getAjType().getPerClause().getKind()).isEqualTo(PerClauseKind.PERTHIS);
|
assertThat(am.getAjType().getPerClause().getKind()).isEqualTo(PerClauseKind.PERTHIS);
|
||||||
|
assertThat(am.getPerClausePointcut()).isInstanceOf(AspectJExpressionPointcut.class);
|
||||||
|
assertThat(((AspectJExpressionPointcut) am.getPerClausePointcut()).getExpression())
|
||||||
|
.isEqualTo("execution(* *.getSpouse())");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2019 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.
|
||||||
|
@ -190,7 +190,6 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
position = extractUnquotedLink(position, content, result);
|
position = extractUnquotedLink(position, content, result);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +202,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked after a keyword match, after whitespaces removed, and when
|
* Invoked after a keyword match, after whitespace has been removed, and when
|
||||||
* the next char is neither a single nor double quote.
|
* the next char is neither a single nor double quote.
|
||||||
*/
|
*/
|
||||||
protected abstract int extractUnquotedLink(int position, String content,
|
protected abstract int extractUnquotedLink(int position, String content,
|
||||||
|
@ -222,7 +221,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
||||||
@Override
|
@Override
|
||||||
protected int extractUnquotedLink(int position, String content, Set<ContentChunkInfo> result) {
|
protected int extractUnquotedLink(int position, String content, Set<ContentChunkInfo> result) {
|
||||||
if (content.startsWith("url(", position)) {
|
if (content.startsWith("url(", position)) {
|
||||||
// Ignore, UrlFunctionContentParser will take care
|
// Ignore: UrlFunctionLinkParser will handle it.
|
||||||
}
|
}
|
||||||
else if (logger.isTraceEnabled()) {
|
else if (logger.isTraceEnabled()) {
|
||||||
logger.trace("Unexpected syntax for @import link at index " + position);
|
logger.trace("Unexpected syntax for @import link at index " + position);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2019 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.
|
||||||
|
@ -153,7 +153,6 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
position = extractLink(position, content, result);
|
position = extractLink(position, content, result);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,7 +165,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked after a keyword match, after whitespaces removed, and when
|
* Invoked after a keyword match, after whitespace has been removed, and when
|
||||||
* the next char is neither a single nor double quote.
|
* the next char is neither a single nor double quote.
|
||||||
*/
|
*/
|
||||||
protected abstract int extractLink(int index, String content, SortedSet<ContentChunkInfo> linksToAdd);
|
protected abstract int extractLink(int index, String content, SortedSet<ContentChunkInfo> linksToAdd);
|
||||||
|
@ -183,7 +182,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
||||||
@Override
|
@Override
|
||||||
protected int extractLink(int index, String content, SortedSet<ContentChunkInfo> linksToAdd) {
|
protected int extractLink(int index, String content, SortedSet<ContentChunkInfo> linksToAdd) {
|
||||||
if (content.startsWith("url(", index)) {
|
if (content.startsWith("url(", index)) {
|
||||||
// Ignore, UrlLinkParser will take care
|
// Ignore: UrlFunctionLinkParser will handle it.
|
||||||
}
|
}
|
||||||
else if (logger.isTraceEnabled()) {
|
else if (logger.isTraceEnabled()) {
|
||||||
logger.trace("Unexpected syntax for @import link at index " + index);
|
logger.trace("Unexpected syntax for @import link at index " + index);
|
||||||
|
|
|
@ -472,7 +472,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
|
||||||
private boolean validatePath(ServerHttpRequest request) {
|
private boolean validatePath(ServerHttpRequest request) {
|
||||||
String path = request.getURI().getPath();
|
String path = request.getURI().getPath();
|
||||||
int index = path.lastIndexOf('/') + 1;
|
int index = path.lastIndexOf('/') + 1;
|
||||||
return path.indexOf(';', index) == -1;
|
return (path.indexOf(';', index) == -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean checkOrigin(ServerHttpRequest request, ServerHttpResponse response, HttpMethod... httpMethods)
|
protected boolean checkOrigin(ServerHttpRequest request, ServerHttpResponse response, HttpMethod... httpMethods)
|
||||||
|
|
Loading…
Reference in New Issue