/** * 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; } }
@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."); } }
@Test public void suppressGetenvAccessThroughSpringProperty() { SpringProperties.setProperty("spring.getenv.ignore", "true"); assertTrue(environment.getSystemEnvironment().isEmpty()); SpringProperties.setProperty("spring.getenv.ignore", null); }
@Test public void suppressGetenvAccessThroughSpringFlag() { SpringProperties.setFlag("spring.getenv.ignore"); assertTrue(environment.getSystemEnvironment().isEmpty()); SpringProperties.setProperty("spring.getenv.ignore", null); }
/** * 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); }