commit
075d5e8d12
|
@ -33,7 +33,7 @@ import static org.junit.Assert.fail;
|
||||||
*
|
*
|
||||||
* @author Craig Walls
|
* @author Craig Walls
|
||||||
*/
|
*/
|
||||||
public class AbstractSocialAutoConfigurationTests {
|
public abstract class AbstractSocialAutoConfigurationTests {
|
||||||
|
|
||||||
protected AnnotationConfigWebApplicationContext context;
|
protected AnnotationConfigWebApplicationContext context;
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ import static org.mockito.Mockito.verify;
|
||||||
*
|
*
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
*/
|
*/
|
||||||
public class AbstractDevToolsDataSourceAutoConfigurationTests {
|
public abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void singleManuallyConfiguredDataSourceIsNotClosed() throws SQLException {
|
public void singleManuallyConfiguredDataSourceIsNotClosed() throws SQLException {
|
||||||
|
|
|
@ -22,10 +22,8 @@ import java.sql.Statement;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
import org.springframework.boot.testutil.FilteredClassPathRunner;
|
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
|
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
|
@ -36,7 +34,6 @@ import static org.mockito.Mockito.verify;
|
||||||
*
|
*
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
*/
|
*/
|
||||||
@RunWith(FilteredClassPathRunner.class)
|
|
||||||
public class DevToolsPooledDataSourceAutoConfigurationTests
|
public class DevToolsPooledDataSourceAutoConfigurationTests
|
||||||
extends AbstractDevToolsDataSourceAutoConfigurationTests {
|
extends AbstractDevToolsDataSourceAutoConfigurationTests {
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||||
* {@link RunWith @RunWith} the {@link SpringRunner}.
|
* {@link RunWith @RunWith} the {@link SpringRunner}.
|
||||||
* <p>
|
* <p>
|
||||||
* Spies can be applied by type or by {@link #name() bean name}. All beans in the context
|
* Spies can be applied by type or by {@link #name() bean name}. All beans in the context
|
||||||
* of the same type will be wrapped with the spy, if no existing bean is defined a new one
|
* of the same type will be wrapped with the spy. If no existing bean is defined a new one
|
||||||
* will be added.
|
* will be added.
|
||||||
* <p>
|
* <p>
|
||||||
* When {@code @SpyBean} is used on a field, as well as being registered in the
|
* When {@code @SpyBean} is used on a field, as well as being registered in the
|
||||||
|
@ -69,7 +69,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p>
|
* <p>
|
||||||
* This annotation is {@code @Repeatable} and may be specified multiple times when working
|
* This annotation is {@code @Repeatable} and may be specified multiple times when working
|
||||||
* with Java 8 or contained within an {@link SpyBeans @SpyBeans} annotation.
|
* with Java 8 or contained within a {@link SpyBeans @SpyBeans} annotation.
|
||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
|
@ -91,7 +91,7 @@ public @interface SpyBean {
|
||||||
/**
|
/**
|
||||||
* The classes to spy. This is an alias of {@link #classes()} which can be used for
|
* The classes to spy. This is an alias of {@link #classes()} which can be used for
|
||||||
* brevity if no other attributes are defined. See {@link #classes()} for details.
|
* brevity if no other attributes are defined. See {@link #classes()} for details.
|
||||||
* @return the classes to mock
|
* @return the classes to spy
|
||||||
*/
|
*/
|
||||||
@AliasFor("classes")
|
@AliasFor("classes")
|
||||||
Class<?>[] value() default {};
|
Class<?>[] value() default {};
|
||||||
|
@ -100,12 +100,12 @@ public @interface SpyBean {
|
||||||
* The classes to spy. Each class specified here will result in a spy being applied.
|
* The classes to spy. Each class specified here will result in a spy being applied.
|
||||||
* Classes can be omitted when the annotation is used on a field.
|
* Classes can be omitted when the annotation is used on a field.
|
||||||
* <p>
|
* <p>
|
||||||
* When {@code @MockBean} also defines a {@code name} this attribute can only contain
|
* When {@code @SpyBean} also defines a {@code name} this attribute can only contain
|
||||||
* a single value.
|
* a single value.
|
||||||
* <p>
|
* <p>
|
||||||
* If this is the only specified attribute consider using the {@code value} alias
|
* If this is the only specified attribute consider using the {@code value} alias
|
||||||
* instead.
|
* instead.
|
||||||
* @return the classes to mock
|
* @return the classes to spy
|
||||||
*/
|
*/
|
||||||
@AliasFor("value")
|
@AliasFor("value")
|
||||||
Class<?>[] classes() default {};
|
Class<?>[] classes() default {};
|
||||||
|
|
|
@ -35,7 +35,7 @@ import static org.mockito.Mockito.verify;
|
||||||
* @see SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests
|
* @see SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@ContextConfiguration(classes = MockBeanOnTestFieldForExistingBeanConfig.class)
|
@ContextConfiguration(classes = SpyBeanOnTestFieldForExistingBeanConfig.class)
|
||||||
public class SpyBeanOnTestFieldForExistingBeanIntegrationTests {
|
public class SpyBeanOnTestFieldForExistingBeanIntegrationTests {
|
||||||
|
|
||||||
@SpyBean
|
@SpyBean
|
||||||
|
|
|
@ -67,14 +67,14 @@ public class SpringPhysicalNamingStrategy implements PhysicalNamingStrategy {
|
||||||
}
|
}
|
||||||
StringBuilder text = new StringBuilder(name.getText().replace('.', '_'));
|
StringBuilder text = new StringBuilder(name.getText().replace('.', '_'));
|
||||||
for (int i = 1; i < text.length() - 1; i++) {
|
for (int i = 1; i < text.length() - 1; i++) {
|
||||||
if (isDashRequired(text.charAt(i - 1), text.charAt(i), text.charAt(i + 1))) {
|
if (isUnderscoreRequired(text.charAt(i - 1), text.charAt(i), text.charAt(i + 1))) {
|
||||||
text.insert(i++, '_');
|
text.insert(i++, '_');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Identifier(text.toString().toLowerCase(Locale.ROOT), name.isQuoted());
|
return new Identifier(text.toString().toLowerCase(Locale.ROOT), name.isQuoted());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDashRequired(char before, char current, char after) {
|
private boolean isUnderscoreRequired(char before, char current, char after) {
|
||||||
return Character.isLowerCase(before) && Character.isUpperCase(current)
|
return Character.isLowerCase(before) && Character.isUpperCase(current)
|
||||||
&& Character.isLowerCase(after);
|
&& Character.isLowerCase(after);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue