diff --git a/spring-aop/src/main/java/org/aopalliance/intercept/Interceptor.java b/spring-aop/src/main/java/org/aopalliance/intercept/Interceptor.java index eef409a74b..f974254729 100644 --- a/spring-aop/src/main/java/org/aopalliance/intercept/Interceptor.java +++ b/spring-aop/src/main/java/org/aopalliance/intercept/Interceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2019 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. @@ -24,7 +24,7 @@ import org.aopalliance.aop.Advice; *
A generic interceptor can intercept runtime events that occur * within a base program. Those events are materialized by (reified * in) joinpoints. Runtime joinpoints can be invocations, field - * access, exceptions... + * access, exceptions... * *
This interface is not used directly. Use the sub-interfaces * to intercept specific events. For instance, the following class @@ -32,8 +32,8 @@ import org.aopalliance.aop.Advice; * debugger: * *
- * class DebuggingInterceptor implements MethodInterceptor,
- * ConstructorInterceptor, FieldInterceptor {
+ * class DebuggingInterceptor implements MethodInterceptor,
+ * ConstructorInterceptor {
*
* Object invoke(MethodInvocation i) throws Throwable {
* debug(i.getMethod(), i.getThis(), i.getArgs());
@@ -44,16 +44,6 @@ import org.aopalliance.aop.Advice;
* debug(i.getConstructor(), i.getThis(), i.getArgs());
* return i.proceed();
* }
- *
- * Object get(FieldAccess fa) throws Throwable {
- * debug(fa.getField(), fa.getThis(), null);
- * return fa.proceed();
- * }
- *
- * Object set(FieldAccess fa) throws Throwable {
- * debug(fa.getField(), fa.getThis(), fa.getValueToSet());
- * return fa.proceed();
- * }
*
* void debug(AccessibleObject ao, Object this, Object value) {
* ...
diff --git a/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java b/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java
index a0c220d079..9c9552a298 100644
--- a/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java
+++ b/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -20,7 +20,6 @@ import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.core.io.Resource;
import static org.junit.Assert.*;
import static org.springframework.tests.TestResourceUtils.*;
@@ -33,13 +32,11 @@ import static org.springframework.tests.TestResourceUtils.*;
*/
public class TopLevelAopTagTests {
- private static final Resource CONTEXT = qualifiedResource(TopLevelAopTagTests.class, "context.xml");
-
@Test
- public void testParse() throws Exception {
+ public void testParse() {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
- XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
- reader.loadBeanDefinitions(CONTEXT);
+ new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(
+ qualifiedResource(TopLevelAopTagTests.class, "context.xml"));
assertTrue(beanFactory.containsBeanDefinition("testPointcut"));
}
diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java
index 455778c83e..c5de9deee2 100644
--- a/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java
+++ b/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -36,6 +36,7 @@ public class PrototypeTargetTests {
private static final Resource CONTEXT = qualifiedResource(PrototypeTargetTests.class, "context.xml");
+
@Test
public void testPrototypeProxyWithPrototypeTarget() {
TestBeanImpl.constructionCount = 0;
@@ -64,12 +65,15 @@ public class PrototypeTargetTests {
assertEquals(10, interceptor.invocationCount);
}
- public static interface TestBean {
- public void doSomething();
+
+ public interface TestBean {
+
+ void doSomething();
}
public static class TestBeanImpl implements TestBean {
+
private static int constructionCount = 0;
public TestBeanImpl() {
@@ -83,6 +87,7 @@ public class PrototypeTargetTests {
public static class TestInterceptor implements MethodInterceptor {
+
private int invocationCount = 0;
@Override
diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java
index 38f0bd9501..4c2735abf2 100644
--- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java
+++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -21,7 +21,6 @@ import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
@@ -36,13 +35,11 @@ import static org.springframework.tests.TestResourceUtils.*;
*/
public class ExposeInvocationInterceptorTests {
- private static final Resource CONTEXT =
- qualifiedResource(ExposeInvocationInterceptorTests.class, "context.xml");
-
@Test
public void testXmlConfig() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
- new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
+ new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
+ qualifiedResource(ExposeInvocationInterceptorTests.class, "context.xml"));
ITestBean tb = (ITestBean) bf.getBean("proxy");
String name = "tony";
tb.setName(name);
@@ -74,6 +71,7 @@ abstract class ExposedInvocationTestBean extends TestBean {
class InvocationCheckExposedInvocationTestBean extends ExposedInvocationTestBean {
+
@Override
protected void assertions(MethodInvocation invocation) {
assertTrue(invocation.getThis() == this);
diff --git a/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java b/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java
index 4b5634f2b0..67e1c30ddc 100644
--- a/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java
+++ b/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -22,7 +22,6 @@ import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.core.io.Resource;
import static org.junit.Assert.*;
import static org.springframework.tests.TestResourceUtils.*;
@@ -34,16 +33,12 @@ import static org.springframework.tests.TestResourceUtils.*;
*/
public class ScopedProxyAutowireTests {
- private static final Resource SCOPED_AUTOWIRE_FALSE_CONTEXT =
- qualifiedResource(ScopedProxyAutowireTests.class, "scopedAutowireFalse.xml");
- private static final Resource SCOPED_AUTOWIRE_TRUE_CONTEXT =
- qualifiedResource(ScopedProxyAutowireTests.class, "scopedAutowireTrue.xml");
-
-
@Test
public void testScopedProxyInheritsAutowireCandidateFalse() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
- new XmlBeanDefinitionReader(bf).loadBeanDefinitions(SCOPED_AUTOWIRE_FALSE_CONTEXT);
+ new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
+ qualifiedResource(ScopedProxyAutowireTests.class, "scopedAutowireFalse.xml"));
+
assertTrue(Arrays.asList(bf.getBeanNamesForType(TestBean.class, false, false)).contains("scoped"));
assertTrue(Arrays.asList(bf.getBeanNamesForType(TestBean.class, true, false)).contains("scoped"));
assertFalse(bf.containsSingleton("scoped"));
@@ -55,7 +50,9 @@ public class ScopedProxyAutowireTests {
@Test
public void testScopedProxyReplacesAutowireCandidateTrue() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
- new XmlBeanDefinitionReader(bf).loadBeanDefinitions(SCOPED_AUTOWIRE_TRUE_CONTEXT);
+ new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
+ qualifiedResource(ScopedProxyAutowireTests.class, "scopedAutowireTrue.xml"));
+
assertTrue(Arrays.asList(bf.getBeanNamesForType(TestBean.class, true, false)).contains("scoped"));
assertTrue(Arrays.asList(bf.getBeanNamesForType(TestBean.class, false, false)).contains("scoped"));
assertFalse(bf.containsSingleton("scoped"));
diff --git a/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java b/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java
index 68b9d26b9c..b1a5b478d5 100644
--- a/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java
+++ b/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -39,7 +39,8 @@ import static org.springframework.tests.TestResourceUtils.*;
public class RegexpMethodPointcutAdvisorIntegrationTests {
private static final Resource CONTEXT =
- qualifiedResource(RegexpMethodPointcutAdvisorIntegrationTests.class, "context.xml");
+ qualifiedResource(RegexpMethodPointcutAdvisorIntegrationTests.class, "context.xml");
+
@Test
public void testSinglePattern() throws Throwable {
diff --git a/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java
index d79ae01e8c..051340bed9 100644
--- a/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java
+++ b/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -25,7 +25,6 @@ import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.core.io.Resource;
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;
import org.springframework.tests.sample.beans.Person;
import org.springframework.tests.sample.beans.SerializablePerson;
@@ -41,31 +40,31 @@ import static org.springframework.tests.TestResourceUtils.*;
*/
public class HotSwappableTargetSourceTests {
- private static final Resource CONTEXT = qualifiedResource(HotSwappableTargetSourceTests.class, "context.xml");
-
/** Initial count value set in bean factory XML */
private static final int INITIAL_COUNT = 10;
private DefaultListableBeanFactory beanFactory;
+
@Before
- public void setUp() throws Exception {
+ public void setup() {
this.beanFactory = new DefaultListableBeanFactory();
- new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(CONTEXT);
+ new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
+ qualifiedResource(HotSwappableTargetSourceTests.class, "context.xml"));
}
/**
* We must simulate container shutdown, which should clear threads.
*/
@After
- public void tearDown() {
+ public void close() {
// Will call pool.close()
this.beanFactory.destroySingletons();
}
+
/**
* Check it works like a normal invoker
- *
*/
@Test
public void testBasicFunctionality() {
@@ -106,18 +105,13 @@ public class HotSwappableTargetSourceTests {
assertEquals(target1.getCount(), proxied.getCount());
}
-
- /**
- *
- * @param invalid
- * @return the message
- */
- private IllegalArgumentException testRejectsSwapToInvalidValue(Object invalid) {
+ @Test
+ public void testRejectsSwapToNull() {
HotSwappableTargetSource swapper = (HotSwappableTargetSource) beanFactory.getBean("swapper");
IllegalArgumentException aopex = null;
try {
- swapper.swap(invalid);
- fail("Shouldn't be able to swap to invalid value [" + invalid + "]");
+ swapper.swap(null);
+ fail("Shouldn't be able to swap to invalid value");
}
catch (IllegalArgumentException ex) {
// Ok
@@ -126,19 +120,9 @@ public class HotSwappableTargetSourceTests {
// It shouldn't be corrupted, it should still work
testBasicFunctionality();
- return aopex;
+ assertTrue(aopex.getMessage().contains("null"));
}
- @Test
- public void testRejectsSwapToNull() {
- IllegalArgumentException ex = testRejectsSwapToInvalidValue(null);
- assertTrue(ex.getMessage().indexOf("null") != -1);
- }
-
- // TODO test reject swap to wrong interface or class?
- // how to decide what's valid?
-
-
@Test
public void testSerialization() throws Exception {
SerializablePerson sp1 = new SerializablePerson();
@@ -165,4 +149,5 @@ public class HotSwappableTargetSourceTests {
assertEquals(sp1.getName(), p.getName());
}
+
}
diff --git a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java
index 995ee9f89a..528dce52aa 100644
--- a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java
+++ b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -19,11 +19,8 @@ package org.springframework.aop.target;
import org.junit.Before;
import org.junit.Test;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.SideEffectBean;
import static org.junit.Assert.*;
@@ -35,19 +32,20 @@ import static org.springframework.tests.TestResourceUtils.*;
*/
public class PrototypeTargetSourceTests {
- private static final Resource CONTEXT = qualifiedResource(PrototypeTargetSourceTests.class, "context.xml");
-
/** Initial count value set in bean factory XML */
private static final int INITIAL_COUNT = 10;
- private BeanFactory beanFactory;
+ private DefaultListableBeanFactory beanFactory;
+
@Before
- public void setUp() throws Exception {
+ public void setup() {
this.beanFactory = new DefaultListableBeanFactory();
- new XmlBeanDefinitionReader((BeanDefinitionRegistry) this.beanFactory).loadBeanDefinitions(CONTEXT);
+ new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
+ qualifiedResource(PrototypeTargetSourceTests.class, "context.xml"));
}
+
/**
* Test that multiple invocations of the prototype bean will result
* in no change to visible state, as a new instance is used.
@@ -66,5 +64,4 @@ public class PrototypeTargetSourceTests {
assertEquals(INITIAL_COUNT, prototype.getCount());
}
-
}
diff --git a/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java
index 0ff97aa8a9..baa6005d0f 100644
--- a/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java
+++ b/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -21,7 +21,6 @@ import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.SideEffectBean;
@@ -34,26 +33,27 @@ import static org.springframework.tests.TestResourceUtils.*;
*/
public class ThreadLocalTargetSourceTests {
- private static final Resource CONTEXT = qualifiedResource(ThreadLocalTargetSourceTests.class, "context.xml");
-
/** Initial count value set in bean factory XML */
private static final int INITIAL_COUNT = 10;
private DefaultListableBeanFactory beanFactory;
+
@Before
- public void setUp() throws Exception {
+ public void setup() {
this.beanFactory = new DefaultListableBeanFactory();
- new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(CONTEXT);
+ new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
+ qualifiedResource(ThreadLocalTargetSourceTests.class, "context.xml"));
}
/**
* We must simulate container shutdown, which should clear threads.
*/
- protected void tearDown() {
+ protected void close() {
this.beanFactory.destroySingletons();
}
+
/**
* Check we can use two different ThreadLocalTargetSources
* managing objects of different types without them interfering
@@ -141,7 +141,7 @@ public class ThreadLocalTargetSourceTests {
}
/**
- * Test for SPR-1442. Destroyed target should re-associated with thread and not throw NPE
+ * Test for SPR-1442. Destroyed target should re-associated with thread and not throw NPE.
*/
@Test
public void testReuseDestroyedTarget() {
diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java
index c21ab35c9f..a18f0a3266 100644
--- a/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java
+++ b/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -50,10 +50,8 @@ import static org.springframework.tests.TestResourceUtils.*;
*/
public class ConcurrentBeanFactoryTests {
- private static final Log logger = LogFactory.getLog(ConcurrentBeanFactoryTests.class);
- private static final Resource CONTEXT = qualifiedResource(ConcurrentBeanFactoryTests.class, "context.xml");
-
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd");
+
private static final Date DATE_1, DATE_2;
static {
@@ -66,27 +64,32 @@ public class ConcurrentBeanFactoryTests {
}
}
+
+ private static final Log logger = LogFactory.getLog(ConcurrentBeanFactoryTests.class);
+
private BeanFactory factory;
- private final Set set = Collections.synchronizedSet(new HashSet());
+ private final Set set = Collections.synchronizedSet(new HashSet<>());
+
+ private Throwable ex;
- private Throwable ex = null;
@Before
- public void setUp() throws Exception {
+ public void setup() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
- new XmlBeanDefinitionReader(factory).loadBeanDefinitions(CONTEXT);
- factory.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
- @Override
- public void registerCustomEditors(PropertyEditorRegistry registry) {
- registry.registerCustomEditor(Date.class, new CustomDateEditor((DateFormat) DATE_FORMAT.clone(), false));
- }
- });
+ new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
+ qualifiedResource(ConcurrentBeanFactoryTests.class, "context.xml"));
+
+ factory.addPropertyEditorRegistrar(
+ registry -> registry.registerCustomEditor(Date.class,
+ new CustomDateEditor((DateFormat) DATE_FORMAT.clone(), false)));
+
this.factory = factory;
}
+
@Test
public void testSingleThread() {
for (int i = 0; i < 100; i++) {
diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java
index 83dd5af5c5..027975beff 100644
--- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java
+++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -21,10 +21,8 @@ import org.junit.Test;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.config.DependencyDescriptor;
import org.springframework.beans.factory.support.AutowireCandidateResolver;
-import org.springframework.beans.factory.support.BeanDefinitionReader;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.core.io.Resource;
import static org.junit.Assert.*;
import static org.springframework.tests.TestResourceUtils.*;
@@ -38,13 +36,12 @@ import static org.springframework.tests.TestResourceUtils.*;
*/
public class CustomAutowireConfigurerTests {
- private static final Resource CONTEXT = qualifiedResource(CustomAutowireConfigurerTests.class, "context.xml");
-
@Test
public void testCustomResolver() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
- BeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
- reader.loadBeanDefinitions(CONTEXT);
+ new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
+ qualifiedResource(CustomAutowireConfigurerTests.class, "context.xml"));
+
CustomAutowireConfigurer cac = new CustomAutowireConfigurer();
CustomResolver customResolver = new CustomResolver();
bf.setAutowireCandidateResolver(customResolver);
diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java
index 2f432e33be..7c827c5b2a 100644
--- a/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java
+++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -22,7 +22,6 @@ import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.TestBean;
import static org.junit.Assert.*;
@@ -37,9 +36,6 @@ import static org.springframework.tests.TestResourceUtils.*;
*/
public class FieldRetrievingFactoryBeanTests {
- private static final Resource CONTEXT =
- qualifiedResource(FieldRetrievingFactoryBeanTests.class, "context.xml");
-
@Test
public void testStaticField() throws Exception {
FieldRetrievingFactoryBean fr = new FieldRetrievingFactoryBean();
@@ -127,7 +123,9 @@ public class FieldRetrievingFactoryBeanTests {
@Test
public void testBeanNameSyntaxWithBeanFactory() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
- new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
+ new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
+ qualifiedResource(FieldRetrievingFactoryBeanTests.class, "context.xml"));
+
TestBean testBean = (TestBean) bf.getBean("testBean");
assertEquals(new Integer(Connection.TRANSACTION_SERIALIZABLE), testBean.getSomeIntegerArray()[0]);
assertEquals(new Integer(Connection.TRANSACTION_SERIALIZABLE), testBean.getSomeIntegerArray()[1]);
diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java
index 5cc613d8cc..d3535164a7 100644
--- a/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java
+++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -27,7 +27,6 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.core.io.Resource;
import org.springframework.util.SerializationTestUtils;
import static org.junit.Assert.*;
@@ -42,25 +41,25 @@ import static org.springframework.tests.TestResourceUtils.*;
*/
public class ObjectFactoryCreatingFactoryBeanTests {
- private static final Resource CONTEXT =
- qualifiedResource(ObjectFactoryCreatingFactoryBeanTests.class, "context.xml");
-
private DefaultListableBeanFactory beanFactory;
+
@Before
- public void setUp() {
+ public void setup() {
this.beanFactory = new DefaultListableBeanFactory();
- new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(CONTEXT);
+ new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
+ qualifiedResource(ObjectFactoryCreatingFactoryBeanTests.class, "context.xml"));
this.beanFactory.setSerializationId("test");
}
@After
- public void tearDown() {
+ public void close() {
this.beanFactory.setSerializationId(null);
}
+
@Test
- public void testFactoryOperation() throws Exception {
+ public void testFactoryOperation() {
FactoryTestBean testBean = beanFactory.getBean("factoryTestBean", FactoryTestBean.class);
ObjectFactory> objectFactory = testBean.getObjectFactory();
@@ -82,7 +81,7 @@ public class ObjectFactoryCreatingFactoryBeanTests {
}
@Test
- public void testProviderOperation() throws Exception {
+ public void testProviderOperation() {
ProviderTestBean testBean = beanFactory.getBean("providerTestBean", ProviderTestBean.class);
Provider> provider = testBean.getProvider();
@@ -152,7 +151,7 @@ public class ObjectFactoryCreatingFactoryBeanTests {
}
@Test
- public void testEnsureOFBFBReportsThatItActuallyCreatesObjectFactoryInstances() throws Exception {
+ public void testEnsureOFBFBReportsThatItActuallyCreatesObjectFactoryInstances() {
assertEquals("Must be reporting that it creates ObjectFactory instances (as per class contract).",
ObjectFactory.class, new ObjectFactoryCreatingFactoryBean().getObjectType());
}
diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java
index 2a81acb06f..dcca770141 100644
--- a/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java
+++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -25,7 +25,6 @@ import org.junit.Test;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.TestBean;
import static org.junit.Assert.*;
@@ -40,12 +39,11 @@ import static org.springframework.tests.TestResourceUtils.*;
*/
public class SimpleScopeTests {
- private static final Resource CONTEXT = qualifiedResource(SimpleScopeTests.class, "context.xml");
-
private DefaultListableBeanFactory beanFactory;
+
@Before
- public void setUp() {
+ public void setup() {
beanFactory = new DefaultListableBeanFactory();
Scope scope = new NoOpScope() {
private int index;
@@ -69,10 +67,11 @@ public class SimpleScopeTests {
assertEquals("myScope", scopeNames[0]);
assertSame(scope, beanFactory.getRegisteredScope("myScope"));
- XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(beanFactory);
- xbdr.loadBeanDefinitions(CONTEXT);
+ new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(
+ qualifiedResource(SimpleScopeTests.class, "context.xml"));
}
+
@Test
public void testCanGetScopedObject() {
TestBean tb1 = (TestBean) beanFactory.getBean("usesScope");
diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java
index adfe6176cb..7345475d9b 100644
--- a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java
+++ b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java
@@ -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");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,6 @@ import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.TestBean;
import static org.junit.Assert.*;
@@ -37,8 +36,6 @@ import static org.springframework.tests.TestResourceUtils.*;
*/
public class CustomProblemReporterTests {
- private static final Resource CONTEXT = qualifiedResource(CustomProblemReporterTests.class, "context.xml");
-
private CollatingProblemReporter problemReporter;
private DefaultListableBeanFactory beanFactory;
@@ -47,16 +44,17 @@ public class CustomProblemReporterTests {
@Before
- public void setUp() {
+ public void setup() {
this.problemReporter = new CollatingProblemReporter();
this.beanFactory = new DefaultListableBeanFactory();
this.reader = new XmlBeanDefinitionReader(this.beanFactory);
this.reader.setProblemReporter(this.problemReporter);
}
+
@Test
public void testErrorsAreCollated() {
- this.reader.loadBeanDefinitions(CONTEXT);
+ this.reader.loadBeanDefinitions(qualifiedResource(CustomProblemReporterTests.class, "context.xml"));
assertEquals("Incorrect number of errors collated", 4, this.problemReporter.getErrors().length);
TestBean bean = (TestBean) this.beanFactory.getBean("validBean");
diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2CodecSupport.java b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2CodecSupport.java
index d732b9e185..280d6d1111 100644
--- a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2CodecSupport.java
+++ b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2CodecSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -114,7 +114,7 @@ public abstract class Jackson2CodecSupport {
@Nullable
protected MethodParameter getParameter(ResolvableType type) {
- return type.getSource() instanceof MethodParameter ? (MethodParameter) type.getSource() : null;
+ return (type.getSource() instanceof MethodParameter ? (MethodParameter) type.getSource() : null);
}
@Nullable
diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java
index efabe0317b..0089ad91e1 100644
--- a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java
+++ b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java
@@ -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");
* you may not use this file except in compliance with the License.
@@ -32,7 +32,6 @@ import reactor.core.publisher.Flux;
import org.springframework.core.codec.DecodingException;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferUtils;
-import org.springframework.util.Assert;
/**
* {@link Function} to transform a JSON stream of arbitrary size, byte array
@@ -40,6 +39,7 @@ import org.springframework.util.Assert;
* well-formed JSON object.
*
* @author Arjen Poutsma
+ * @author Rossen Stoyanchev
* @since 5.0
*/
class Jackson2Tokenizer {
@@ -55,39 +55,17 @@ class Jackson2Tokenizer {
private int arrayDepth;
// TODO: change to ByteBufferFeeder when supported by Jackson
+ // See https://github.com/FasterXML/jackson-core/issues/478
private final ByteArrayFeeder inputFeeder;
private Jackson2Tokenizer(JsonParser parser, boolean tokenizeArrayElements) {
- Assert.notNull(parser, "'parser' must not be null");
-
this.parser = parser;
this.tokenizeArrayElements = tokenizeArrayElements;
this.tokenBuffer = new TokenBuffer(parser);
this.inputFeeder = (ByteArrayFeeder) this.parser.getNonBlockingInputFeeder();
}
- /**
- * Tokenize the given {@code Flux} into {@code Flux}.
- * @param dataBuffers the source data buffers
- * @param jsonFactory the factory to use
- * @param tokenizeArrayElements if {@code true} and the "top level" JSON
- * object is an array, each element is returned individually, immediately
- * after it is received.
- * @return the result token buffers
- */
- public static Flux tokenize(Flux dataBuffers, JsonFactory jsonFactory,
- boolean tokenizeArrayElements) {
-
- try {
- JsonParser parser = jsonFactory.createNonBlockingByteArrayParser();
- Jackson2Tokenizer tokenizer = new Jackson2Tokenizer(parser, tokenizeArrayElements);
- return dataBuffers.flatMap(tokenizer::tokenize, Flux::error, tokenizer::endOfInput);
- }
- catch (IOException ex) {
- return Flux.error(ex);
- }
- }
private Flux tokenize(DataBuffer dataBuffer) {
byte[] bytes = new byte[dataBuffer.readableByteCount()];
@@ -99,8 +77,7 @@ class Jackson2Tokenizer {
return parseTokenBufferFlux();
}
catch (JsonProcessingException ex) {
- return Flux.error(new DecodingException(
- "JSON decoding error: " + ex.getOriginalMessage(), ex));
+ return Flux.error(new DecodingException("JSON decoding error: " + ex.getOriginalMessage(), ex));
}
catch (IOException ex) {
return Flux.error(ex);
@@ -113,8 +90,7 @@ class Jackson2Tokenizer {
return parseTokenBufferFlux();
}
catch (JsonProcessingException ex) {
- return Flux.error(new DecodingException(
- "JSON decoding error: " + ex.getOriginalMessage(), ex));
+ return Flux.error(new DecodingException("JSON decoding error: " + ex.getOriginalMessage(), ex));
}
catch (IOException ex) {
return Flux.error(ex);
@@ -127,12 +103,11 @@ class Jackson2Tokenizer {
while (true) {
JsonToken token = this.parser.nextToken();
// SPR-16151: Smile data format uses null to separate documents
- if ((token == JsonToken.NOT_AVAILABLE) ||
+ if (token == JsonToken.NOT_AVAILABLE ||
(token == null && (token = this.parser.nextToken()) == null)) {
break;
}
updateDepth(token);
-
if (!this.tokenizeArrayElements) {
processTokenNormal(token, result);
}
@@ -163,8 +138,7 @@ class Jackson2Tokenizer {
private void processTokenNormal(JsonToken token, List result) throws IOException {
this.tokenBuffer.copyCurrentEvent(this.parser);
- if ((token.isStructEnd() || token.isScalarValue()) &&
- this.objectDepth == 0 && this.arrayDepth == 0) {
+ if ((token.isStructEnd() || token.isScalarValue()) && this.objectDepth == 0 && this.arrayDepth == 0) {
result.add(this.tokenBuffer);
this.tokenBuffer = new TokenBuffer(this.parser);
}
@@ -176,8 +150,7 @@ class Jackson2Tokenizer {
this.tokenBuffer.copyCurrentEvent(this.parser);
}
- if (this.objectDepth == 0 &&
- (this.arrayDepth == 0 || this.arrayDepth == 1) &&
+ if (this.objectDepth == 0 && (this.arrayDepth == 0 || this.arrayDepth == 1) &&
(token == JsonToken.END_OBJECT || token.isScalarValue())) {
result.add(this.tokenBuffer);
this.tokenBuffer = new TokenBuffer(this.parser);
@@ -189,4 +162,26 @@ class Jackson2Tokenizer {
(token == JsonToken.END_ARRAY && this.arrayDepth == 0));
}
+
+ /**
+ * Tokenize the given {@code Flux} into {@code Flux}.
+ * @param dataBuffers the source data buffers
+ * @param jsonFactory the factory to use
+ * @param tokenizeArrayElements if {@code true} and the "top level" JSON object is
+ * an array, each element is returned individually immediately after it is received
+ * @return the resulting token buffers
+ */
+ public static Flux tokenize(
+ Flux dataBuffers, JsonFactory jsonFactory, boolean tokenizeArrayElements) {
+
+ try {
+ JsonParser parser = jsonFactory.createNonBlockingByteArrayParser();
+ Jackson2Tokenizer tokenizer = new Jackson2Tokenizer(parser, tokenizeArrayElements);
+ return dataBuffers.flatMap(tokenizer::tokenize, Flux::error, tokenizer::endOfInput);
+ }
+ catch (IOException ex) {
+ return Flux.error(ex);
+ }
+ }
+
}
diff --git a/spring-web/src/main/java/org/springframework/web/context/support/GenericWebApplicationContext.java b/spring-web/src/main/java/org/springframework/web/context/support/GenericWebApplicationContext.java
index ff16148474..1e8fba2055 100644
--- a/spring-web/src/main/java/org/springframework/web/context/support/GenericWebApplicationContext.java
+++ b/spring-web/src/main/java/org/springframework/web/context/support/GenericWebApplicationContext.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2019 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.
@@ -39,11 +39,10 @@ import org.springframework.web.context.ServletContextAware;
/**
* Subclass of {@link GenericApplicationContext}, suitable for web environments.
*
- * Implements the
- * {@link org.springframework.web.context.ConfigurableWebApplicationContext},
- * but is not intended for declarative setup in {@code web.xml}. Instead,
- * it is designed for programmatic setup, for example for building nested contexts or
- * for use within Spring 3.1 {@link org.springframework.web.WebApplicationInitializer}s.
+ *
Implements {@link org.springframework.web.context.ConfigurableWebApplicationContext},
+ * but is not intended for declarative setup in {@code web.xml}. Instead, it is designed
+ * for programmatic setup, for example for building nested contexts or for use within
+ * {@link org.springframework.web.WebApplicationInitializer WebApplicationInitializers}.
*
*
If you intend to implement a WebApplicationContext that reads bean definitions
* from configuration files, consider deriving from AbstractRefreshableWebApplicationContext,
diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java
index 8dc4fc70db..9c4bebd7f9 100644
--- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java
+++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java
@@ -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");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@ import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -43,21 +42,13 @@ import org.springframework.core.io.buffer.DefaultDataBufferFactory;
import org.springframework.http.codec.Pojo;
import org.springframework.util.MimeType;
-import static java.util.Arrays.asList;
-import static java.util.Collections.emptyMap;
-import static java.util.Collections.singletonMap;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.springframework.core.ResolvableType.forClass;
-import static org.springframework.http.MediaType.APPLICATION_JSON;
-import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8;
-import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON;
-import static org.springframework.http.MediaType.APPLICATION_XML;
-import static org.springframework.http.codec.json.Jackson2JsonDecoder.JSON_VIEW_HINT;
-import static org.springframework.http.codec.json.JacksonViewBean.MyJacksonView1;
-import static org.springframework.http.codec.json.JacksonViewBean.MyJacksonView3;
+import static java.util.Arrays.*;
+import static java.util.Collections.*;
+import static org.junit.Assert.*;
+import static org.springframework.core.ResolvableType.*;
+import static org.springframework.http.MediaType.*;
+import static org.springframework.http.codec.json.Jackson2JsonDecoder.*;
+import static org.springframework.http.codec.json.JacksonViewBean.*;
/**
* Unit tests for {@link Jackson2JsonDecoder}.
@@ -80,7 +71,7 @@ public class Jackson2JsonDecoderTests extends AbstractDataBufferAllocatingTestCa
assertFalse(decoder.canDecode(forClass(Pojo.class), APPLICATION_XML));
}
- @Test // SPR-15866
+ @Test // SPR-15866
public void canDecodeWithProvidedMimeType() {
MimeType textJavascript = new MimeType("text", "javascript", StandardCharsets.UTF_8);
Jackson2JsonDecoder decoder = new Jackson2JsonDecoder(new ObjectMapper(), textJavascript);
@@ -269,20 +260,24 @@ public class Jackson2JsonDecoderTests extends AbstractDataBufferAllocatingTestCa
public String getProperty2() {
return property2;
}
-
}
+
@JsonDeserialize(using = Deserializer.class)
public static class TestObject {
+
private int test;
+
public int getTest() {
return test;
}
+
public void setTest(int test) {
this.test = test;
}
}
+
public static class Deserializer extends StdDeserializer {
private static final long serialVersionUID = 1L;
@@ -292,8 +287,7 @@ public class Jackson2JsonDecoderTests extends AbstractDataBufferAllocatingTestCa
}
@Override
- public TestObject deserialize(JsonParser p,
- DeserializationContext ctxt) throws IOException, JsonProcessingException {
+ public TestObject deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
JsonNode node = p.readValueAsTree();
TestObject result = new TestObject();
result.setTest(node.get("test").asInt());
diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java
index 4cced42690..e44723140b 100644
--- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java
+++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java
@@ -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");
* you may not use this file except in compliance with the License.
@@ -45,10 +45,10 @@ import static java.util.Collections.*;
*/
public class Jackson2TokenizerTests extends AbstractDataBufferAllocatingTestCase {
- private ObjectMapper objectMapper;
-
private JsonFactory jsonFactory;
+ private ObjectMapper objectMapper;
+
@Before
public void createParser() {
@@ -56,6 +56,7 @@ public class Jackson2TokenizerTests extends AbstractDataBufferAllocatingTestCase
this.objectMapper = new ObjectMapper(this.jsonFactory);
}
+
@Test
public void doNotTokenizeArrayElements() {
testTokenize(
@@ -178,7 +179,7 @@ public class Jackson2TokenizerTests extends AbstractDataBufferAllocatingTestCase
testTokenize(asList("[1", ",2,", "3]"), asList("1", "2", "3"), true);
}
- @Test(expected = DecodingException.class) // SPR-16521
+ @Test(expected = DecodingException.class) // SPR-16521
public void jsonEOFExceptionIsWrappedAsDecodingError() {
Flux source = Flux.just(stringBuffer("{\"status\": \"noClosingQuote}"));
Flux tokens = Jackson2Tokenizer.tokenize(source, this.jsonFactory, false);
@@ -187,11 +188,9 @@ public class Jackson2TokenizerTests extends AbstractDataBufferAllocatingTestCase
private void testTokenize(List source, List expected, boolean tokenizeArrayElements) {
-
Flux tokenBufferFlux = Jackson2Tokenizer.tokenize(
Flux.fromIterable(source).map(this::stringBuffer),
- this.jsonFactory,
- tokenizeArrayElements);
+ this.jsonFactory, tokenizeArrayElements);
Flux result = tokenBufferFlux
.map(tokenBuffer -> {
@@ -228,4 +227,5 @@ public class Jackson2TokenizerTests extends AbstractDataBufferAllocatingTestCase
}
}
}
-}
\ No newline at end of file
+
+}