org.springframework.core.SpringProperties Java Examples
The following examples show how to use
org.springframework.core.SpringProperties.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourcePropertiesUtilTest.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Test public void getInputStream(){ ClassLoader cl = SpringProperties.class.getClassLoader(); URL url = cl.getResource("defaults/jdbc.properties"); if (url != null) { System.out.println("OK."); }else{ System.out.println("failure."); } }
Example #2
Source File: SpringObjenesis.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Create a new {@code SpringObjenesis} instance with the * given standard instantiator strategy. * @param strategy the instantiator strategy to use */ public SpringObjenesis(InstantiatorStrategy strategy) { this.strategy = (strategy != null ? strategy : new StdInstantiatorStrategy()); // Evaluate the "spring.objenesis.ignore" property upfront... if (SpringProperties.getFlag(SpringObjenesis.IGNORE_OBJENESIS_PROPERTY_NAME)) { this.worthTrying = Boolean.FALSE; } }
Example #3
Source File: ContextCacheUtils.java From spring-analysis-note with MIT License | 5 votes |
/** * Retrieve the maximum size of the {@link ContextCache}. * <p>Uses {@link SpringProperties} to retrieve a system property or Spring * property named {@code spring.test.context.cache.maxSize}. * <p>Falls back to the value of the {@link ContextCache#DEFAULT_MAX_CONTEXT_CACHE_SIZE} * if no such property has been set or if the property is not an integer. * @return the maximum size of the context cache * @see ContextCache#MAX_CONTEXT_CACHE_SIZE_PROPERTY_NAME */ public static int retrieveMaxCacheSize() { try { String maxSize = SpringProperties.getProperty(ContextCache.MAX_CONTEXT_CACHE_SIZE_PROPERTY_NAME); if (StringUtils.hasText(maxSize)) { return Integer.parseInt(maxSize.trim()); } } catch (Exception ex) { // ignore } // Fallback return ContextCache.DEFAULT_MAX_CONTEXT_CACHE_SIZE; }
Example #4
Source File: SpringObjenesis.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Create a new {@code SpringObjenesis} instance with the * given standard instantiator strategy. * @param strategy the instantiator strategy to use */ public SpringObjenesis(InstantiatorStrategy strategy) { this.strategy = (strategy != null ? strategy : new StdInstantiatorStrategy()); // Evaluate the "spring.objenesis.ignore" property upfront... if (SpringProperties.getFlag(SpringObjenesis.IGNORE_OBJENESIS_PROPERTY_NAME)) { this.worthTrying = Boolean.FALSE; } }
Example #5
Source File: SpringObjenesis.java From java-technology-stack with MIT License | 5 votes |
/** * Create a new {@code SpringObjenesis} instance with the * given standard instantiator strategy. * @param strategy the instantiator strategy to use */ public SpringObjenesis(InstantiatorStrategy strategy) { this.strategy = (strategy != null ? strategy : new StdInstantiatorStrategy()); // Evaluate the "spring.objenesis.ignore" property upfront... if (SpringProperties.getFlag(SpringObjenesis.IGNORE_OBJENESIS_PROPERTY_NAME)) { this.worthTrying = Boolean.FALSE; } }
Example #6
Source File: ContextCacheUtils.java From java-technology-stack with MIT License | 5 votes |
/** * Retrieve the maximum size of the {@link ContextCache}. * <p>Uses {@link SpringProperties} to retrieve a system property or Spring * property named {@code spring.test.context.cache.maxSize}. * <p>Falls back to the value of the {@link ContextCache#DEFAULT_MAX_CONTEXT_CACHE_SIZE} * if no such property has been set or if the property is not an integer. * @return the maximum size of the context cache * @see ContextCache#MAX_CONTEXT_CACHE_SIZE_PROPERTY_NAME */ public static int retrieveMaxCacheSize() { try { String maxSize = SpringProperties.getProperty(ContextCache.MAX_CONTEXT_CACHE_SIZE_PROPERTY_NAME); if (StringUtils.hasText(maxSize)) { return Integer.parseInt(maxSize.trim()); } } catch (Exception ex) { // ignore } // Fallback return ContextCache.DEFAULT_MAX_CONTEXT_CACHE_SIZE; }
Example #7
Source File: SpringObjenesis.java From spring-analysis-note with MIT License | 5 votes |
/** * Create a new {@code SpringObjenesis} instance with the * given standard instantiator strategy. * @param strategy the instantiator strategy to use */ public SpringObjenesis(InstantiatorStrategy strategy) { this.strategy = (strategy != null ? strategy : new StdInstantiatorStrategy()); // Evaluate the "spring.objenesis.ignore" property upfront... if (SpringProperties.getFlag(SpringObjenesis.IGNORE_OBJENESIS_PROPERTY_NAME)) { this.worthTrying = Boolean.FALSE; } }
Example #8
Source File: StandardEnvironmentTests.java From java-technology-stack with MIT License | 4 votes |
@Test public void suppressGetenvAccessThroughSpringFlag() { SpringProperties.setFlag("spring.getenv.ignore"); assertTrue(environment.getSystemEnvironment().isEmpty()); SpringProperties.setProperty("spring.getenv.ignore", null); }
Example #9
Source File: StandardEnvironmentTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Test public void suppressGetenvAccessThroughSpringFlag() { SpringProperties.setFlag("spring.getenv.ignore"); assertTrue(environment.getSystemEnvironment().isEmpty()); SpringProperties.setProperty("spring.getenv.ignore", null); }
Example #10
Source File: StandardEnvironmentTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Test public void suppressGetenvAccessThroughSpringProperty() { SpringProperties.setProperty("spring.getenv.ignore", "true"); assertTrue(environment.getSystemEnvironment().isEmpty()); SpringProperties.setProperty("spring.getenv.ignore", null); }
Example #11
Source File: ContextCacheUtilsTests.java From java-technology-stack with MIT License | 4 votes |
@Test public void retrieveMaxCacheSizeFromSpringProperty() { SpringProperties.setProperty(MAX_CONTEXT_CACHE_SIZE_PROPERTY_NAME, "99"); assertEquals(99, retrieveMaxCacheSize()); }
Example #12
Source File: ContextCacheUtilsTests.java From java-technology-stack with MIT License | 4 votes |
@Test public void retrieveMaxCacheSizeFromDecimalSpringProperty() { SpringProperties.setProperty(MAX_CONTEXT_CACHE_SIZE_PROPERTY_NAME, "3.14"); assertDefaultValue(); }
Example #13
Source File: ContextCacheUtilsTests.java From java-technology-stack with MIT License | 4 votes |
@Test public void retrieveMaxCacheSizeFromBogusSpringProperty() { SpringProperties.setProperty(MAX_CONTEXT_CACHE_SIZE_PROPERTY_NAME, "bogus"); assertDefaultValue(); }
Example #14
Source File: ContextCacheUtilsTests.java From java-technology-stack with MIT License | 4 votes |
@Before @After public void clearProperties() { System.clearProperty(MAX_CONTEXT_CACHE_SIZE_PROPERTY_NAME); SpringProperties.setProperty(MAX_CONTEXT_CACHE_SIZE_PROPERTY_NAME, null); }
Example #15
Source File: StandardEnvironmentTests.java From java-technology-stack with MIT License | 4 votes |
@Test public void suppressGetenvAccessThroughSpringProperty() { SpringProperties.setProperty("spring.getenv.ignore", "true"); assertTrue(environment.getSystemEnvironment().isEmpty()); SpringProperties.setProperty("spring.getenv.ignore", null); }
Example #16
Source File: ContextCacheUtilsTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void retrieveMaxCacheSizeFromSpringProperty() { SpringProperties.setProperty(MAX_CONTEXT_CACHE_SIZE_PROPERTY_NAME, "99"); assertEquals(99, retrieveMaxCacheSize()); }
Example #17
Source File: ContextCacheUtilsTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void retrieveMaxCacheSizeFromDecimalSpringProperty() { SpringProperties.setProperty(MAX_CONTEXT_CACHE_SIZE_PROPERTY_NAME, "3.14"); assertDefaultValue(); }
Example #18
Source File: ContextCacheUtilsTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void retrieveMaxCacheSizeFromBogusSpringProperty() { SpringProperties.setProperty(MAX_CONTEXT_CACHE_SIZE_PROPERTY_NAME, "bogus"); assertDefaultValue(); }
Example #19
Source File: ContextCacheUtilsTests.java From spring-analysis-note with MIT License | 4 votes |
@Before @After public void clearProperties() { System.clearProperty(MAX_CONTEXT_CACHE_SIZE_PROPERTY_NAME); SpringProperties.setProperty(MAX_CONTEXT_CACHE_SIZE_PROPERTY_NAME, null); }
Example #20
Source File: StandardEnvironmentTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void suppressGetenvAccessThroughSpringFlag() { SpringProperties.setFlag("spring.getenv.ignore"); assertTrue(environment.getSystemEnvironment().isEmpty()); SpringProperties.setProperty("spring.getenv.ignore", null); }
Example #21
Source File: StandardEnvironmentTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void suppressGetenvAccessThroughSpringProperty() { SpringProperties.setProperty("spring.getenv.ignore", "true"); assertTrue(environment.getSystemEnvironment().isEmpty()); SpringProperties.setProperty("spring.getenv.ignore", null); }
Example #22
Source File: TestConstructorUtils.java From spring-analysis-note with MIT License | 3 votes |
/** * Determine if the supplied constructor for the given test class is * autowirable. * * <p>A constructor is considered to be autowirable if one of the following * conditions is {@code true}. * * <ol> * <li>The constructor is annotated with {@link Autowired @Autowired}.</li> * <li>{@link TestConstructor @TestConstructor} is <em>present</em> or * <em>meta-present</em> on the test class with * {@link TestConstructor#autowire autowire} set to {@code true}.</li> * <li>The default <em>test constructor autowire</em> mode is set to {@code true} * (see {@link TestConstructor#TEST_CONSTRUCTOR_AUTOWIRE_PROPERTY_NAME}).</li> * </ol> * * @param constructor a constructor for the test class * @param testClass the test class * @return {@code true} if the constructor is autowirable * @see #isAutowirableConstructor(Executable, Class) */ public static boolean isAutowirableConstructor(Constructor<?> constructor, Class<?> testClass) { // Is the constructor annotated with @Autowired? if (AnnotatedElementUtils.hasAnnotation(constructor, Autowired.class)) { return true; } // Is the test class annotated with @TestConstructor? TestConstructor testConstructor = AnnotatedElementUtils.findMergedAnnotation(testClass, TestConstructor.class); if (testConstructor != null) { return testConstructor.autowire(); } // Else use global default. return SpringProperties.getFlag(TestConstructor.TEST_CONSTRUCTOR_AUTOWIRE_PROPERTY_NAME); }
Example #23
Source File: AbstractEnvironment.java From java-technology-stack with MIT License | 2 votes |
/** * Determine whether to suppress {@link System#getenv()}/{@link System#getenv(String)} * access for the purposes of {@link #getSystemEnvironment()}. * <p>If this method returns {@code true}, an empty dummy Map will be used instead * of the regular system environment Map, never even trying to call {@code getenv} * and therefore avoiding security manager warnings (if any). * <p>The default implementation checks for the "spring.getenv.ignore" system property, * returning {@code true} if its value equals "true" in any case. * @see #IGNORE_GETENV_PROPERTY_NAME * @see SpringProperties#getFlag */ protected boolean suppressGetenvAccess() { return SpringProperties.getFlag(IGNORE_GETENV_PROPERTY_NAME); }
Example #24
Source File: AbstractEnvironment.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Determine whether to suppress {@link System#getenv()}/{@link System#getenv(String)} * access for the purposes of {@link #getSystemEnvironment()}. * <p>If this method returns {@code true}, an empty dummy Map will be used instead * of the regular system environment Map, never even trying to call {@code getenv} * and therefore avoiding security manager warnings (if any). * <p>The default implementation checks for the "spring.getenv.ignore" system property, * returning {@code true} if its value equals "true" in any case. * @see #IGNORE_GETENV_PROPERTY_NAME * @see SpringProperties#getFlag */ protected boolean suppressGetenvAccess() { return SpringProperties.getFlag(IGNORE_GETENV_PROPERTY_NAME); }
Example #25
Source File: AbstractEnvironment.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Determine whether to suppress {@link System#getenv()}/{@link System#getenv(String)} * access for the purposes of {@link #getSystemEnvironment()}. * <p>If this method returns {@code true}, an empty dummy Map will be used instead * of the regular system environment Map, never even trying to call {@code getenv} * and therefore avoiding security manager warnings (if any). * <p>The default implementation checks for the "spring.getenv.ignore" system property, * returning {@code true} if its value equals "true" in any case. * @see #IGNORE_GETENV_PROPERTY_NAME * @see SpringProperties#getFlag */ protected boolean suppressGetenvAccess() { return SpringProperties.getFlag(IGNORE_GETENV_PROPERTY_NAME); }
Example #26
Source File: AbstractEnvironment.java From spring-analysis-note with MIT License | 2 votes |
/** * Determine whether to suppress {@link System#getenv()}/{@link System#getenv(String)} * access for the purposes of {@link #getSystemEnvironment()}. * <p>If this method returns {@code true}, an empty dummy Map will be used instead * of the regular system environment Map, never even trying to call {@code getenv} * and therefore avoiding security manager warnings (if any). * <p>The default implementation checks for the "spring.getenv.ignore" system property, * returning {@code true} if its value equals "true" in any case. * @see #IGNORE_GETENV_PROPERTY_NAME * @see SpringProperties#getFlag */ protected boolean suppressGetenvAccess() { return SpringProperties.getFlag(IGNORE_GETENV_PROPERTY_NAME); }