@Override public void evosuite_updateProperty(String clientRmiIdentifier, String propertyName, Object value) throws RemoteException, IllegalArgumentException, IllegalAccessException, NoSuchParameterException { Properties.getInstance().setValue(propertyName, value); }
private void initializePhaseTimeouts() { if(phaseTimeouts!=null){ phaseTimeouts.clear(); } else { phaseTimeouts = new ConcurrentHashMap<>(); } // TODO: I don't understand why, but this may not have happened at this point Properties.getInstance(); phaseTimeouts.put(ClientState.SEARCH, (Long) 1000l * getSearchBudgetInSeconds()); phaseTimeouts.put(ClientState.MINIMIZATION, (Long) 1000l * Properties.MINIMIZATION_TIMEOUT); phaseTimeouts.put(ClientState.ASSERTION_GENERATION, (Long) 1000l * Properties.ASSERTION_TIMEOUT); phaseTimeouts.put(ClientState.CARVING, (Long) 1000l * Properties.CARVING_TIMEOUT); phaseTimeouts.put(ClientState.INITIALIZATION, (Long) 1000l * Properties.INITIALIZATION_TIMEOUT); phaseTimeouts.put(ClientState.JUNIT_CHECK, (Long) 1000l * Properties.JUNIT_CHECK_TIMEOUT); phaseTimeouts.put(ClientState.WRITING_TESTS, (Long) 1000l * Properties.WRITE_JUNIT_TIMEOUT); if(timeSpentInEachPhase!=null){ timeSpentInEachPhase.clear(); } else { timeSpentInEachPhase = new ConcurrentHashMap<ClientState,Long>(); } }
/** * Add all the properties that were set with -D * * @param javaOpts * @param line * @throws Error */ public static void addJavaDOptions(List<String> javaOpts, CommandLine line) throws Error { java.util.Properties properties = line.getOptionProperties("D"); Set<String> propertyNames = new HashSet<>(Properties.getParameters()); for (String propertyName : properties.stringPropertyNames()) { if (!propertyNames.contains(propertyName)) { LoggingUtils.getEvoLogger().error("* Unknown property: " + propertyName); throw new Error("Unknown property: " + propertyName); } String propertyValue = properties.getProperty(propertyName); javaOpts.add("-D" + propertyName + "=" + propertyValue); System.setProperty(propertyName, propertyValue); try { Properties.getInstance().setValue(propertyName, propertyValue); } catch (Exception e) { throw new Error("Invalid value for property " + propertyName+": "+propertyValue+". Exception "+e.getMessage(),e); } } }
@BeforeClass public static void initClass(){ Properties.getInstance(); }
Properties.getInstance().setValue("inheritance_file", Properties.OUTPUT_DIR + "/" + "inheritance.xml.gz"); + Properties.OUTPUT_DIR); LoggingUtils.getEvoLogger().info("* Classpath: " + Properties.CP); Properties.getInstance().writeConfiguration(EvoSuite.base_dir_path + File.separator + Properties.OUTPUT_DIR + File.separator
Properties.getInstance().resetToDefaults();
@Test public void testOutOfRangeInput() throws IllegalArgumentException, IllegalAccessException, NoSuchParameterException{ Properties.getInstance().setValue("crossover_rate", 0.6); //this should be OK try{ Properties.getInstance().setValue("crossover_rate", 2.5); fail(); } catch(Exception e){/* OK*/} try{ Properties.getInstance().setValue("crossover_rate", -10.6); fail(); } catch(Exception e){/* OK*/} }
@After public void reset(){ Properties.getInstance().resetToDefaults(); }
@Test public void testNeverEverDefinePropertiesBasedOnOthersOtherwiseChangingInFormerWillNotAffectTheLatter(){ Properties.getInstance().resetToDefaults(); assertTrue(! Properties.CTG_BESTS_DIR_NAME.startsWith(Properties.CTG_DIR)); assertTrue(! Properties.CTG_PROJECT_INFO.startsWith(Properties.CTG_DIR)); } }
Properties.getInstance();// should force the load, just to be sure Properties.TARGET_CLASS = targetClass; Properties.PROCESS_COMMUNICATION_PORT = port;
@Test public void testParameterThatDoesNotExist(){ try { Properties.getInstance().setValue("a_parameter_that_does_not_exist", 1); fail(); } catch (IllegalArgumentException | IllegalAccessException | NoSuchParameterException e) { //expected } }
@After public void tearDown() { TestGenerationContext.getInstance().resetContext(); System.setProperties(currentProperties); Properties.getInstance().resetToDefaults(); }
@Test public void testInvalidBooleanInput() throws Exception{ final boolean defaultValue = Properties.TEST_CARVING; boolean value = Properties.getBooleanValue("test_carving"); Assert.assertEquals(defaultValue, value); Properties.getInstance().setValue("test_carving", !defaultValue); value = Properties.getBooleanValue("test_carving"); Assert.assertNotEquals(defaultValue, value); try{ Properties.getInstance().setValue("test_carving", "tru"); fail(); } catch(Exception e){ //expected } }
@After public void tearDown() { if (DEFAULT_IS_TRACE_ENABLED) { ExecutionTracer.enableTraceCalls(); } else { ExecutionTracer.disableTraceCalls(); } TestGenerationContext.getInstance().resetContext(); ClassReInitializer.resetSingleton(); System.setProperties(currentProperties); Properties.getInstance().resetToDefaults(); }
@Test public void testReset(){ final String defaultValue = Properties.TARGET_CLASS; final String aString = "foo_foo_foo"; Assert.assertNotEquals(defaultValue, aString); Properties.TARGET_CLASS = aString; Assert.assertEquals(aString,Properties.TARGET_CLASS); Properties.getInstance().resetToDefaults(); Assert.assertEquals(defaultValue,Properties.TARGET_CLASS); } }
@Before public void setUp() { ClassPathHandler.getInstance().changeTargetCPtoTheSameAsEvoSuite(); Properties.getInstance().resetToDefaults(); Randomness.setSeed(42); TestGenerationContext.getInstance().resetContext(); ClassReInitializer.resetSingleton(); Randomness.setSeed(42); currentProperties = (java.util.Properties) System.getProperties().clone(); }
@Before public void setDefaultPropertiesForTestCases() { Properties.getInstance().resetToDefaults();
@After public void resetStaticVariables() { RuntimeInstrumentation.setAvoidInstrumentingShadedClasses(false); RuntimeSettings.applyUIDTransformation = false; TestCaseExecutor.getInstance().newObservers(); TestGenerationContext.getInstance().resetContext(); ClassReInitializer.resetSingleton(); System.setProperties(currentProperties); Properties.getInstance().resetToDefaults(); ExceptionCoverageFactory.getGoals().clear(); Archive.getArchiveInstance().reset(); }
@Before public void setUp() { ClassPathHandler.getInstance().changeTargetCPtoTheSameAsEvoSuite(); Properties.getInstance().resetToDefaults(); Randomness.setSeed(42); Properties.TARGET_CLASS = ""; TestGenerationContext.getInstance().resetContext(); ClassReInitializer.resetSingleton(); Randomness.setSeed(42); currentProperties = (java.util.Properties) System.getProperties().clone(); Properties.CRITERION = new Criterion[] { Criterion.LINE, Criterion.BRANCH, Criterion.EXCEPTION, Criterion.WEAKMUTATION, Criterion.OUTPUT, Criterion.METHOD, Criterion.METHODNOEXCEPTION, Criterion.CBRANCH }; ExecutionTracer.enableTraceCalls(); }
Properties.getInstance(); setupRuntimeProperties(); handleShadingSpecialCases();