@After public void reset(){ Properties.getInstance().resetToDefaults(); }
@Override public void evosuite_updateProperty(String clientRmiIdentifier, String propertyName, Object value) throws RemoteException, IllegalArgumentException, IllegalAccessException, NoSuchParameterException { Properties.getInstance().setValue(propertyName, value); }
private void setupProperties() { if (base_dir_path.equals("")) { Properties.getInstanceSilent(); } else { Properties.getInstanceSilent().loadProperties(base_dir_path + separator + Properties.PROPERTIES_FILE, true); } }
/** Constructor */ private Properties(boolean loadProperties, boolean silent) { if (loadProperties) loadProperties(silent); setClassPrefix(); }
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>(); } }
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
@Override public void zero() { this.value = Properties.getTargetClassAndDontInitialise(); }
/** * 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); } } }
@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 } }
public static boolean canBeFunctionalMocked(Type type) { Class<?> rawClass = new GenericClass(type).getRawClass(); final Class<?> targetClass = Properties.getTargetClassAndDontInitialise(); if (Properties.hasTargetClassBeenLoaded() && GenericClass.isAssignable(targetClass, rawClass)) { return false; } return canBeFunctionalMockedIncludingSUT(type); }
setValue(key, Integer.parseInt(value)); } else if (f.getType().equals(Integer.class)) { setValue(key, (Integer) Integer.parseInt(value)); setValue(key, Long.parseLong(value)); } else if (f.getType().equals(Long.class)) { setValue(key, (Long) Long.parseLong(value)); setValue(key, strictParseBoolean(value)); } else if (f.getType().equals(Boolean.class)) { setValue(key, (Boolean) strictParseBoolean(value)); setValue(key, Double.parseDouble(value)); } else if (f.getType().equals(Double.class)) { setValue(key, (Double) Double.parseDouble(value)); setValue(key, value.split(":")); } else if (f.getType().getComponentType().equals(Criterion.class)) { String[] values = value.split(":");
/** * Initialize properties from property file or command line parameters */ private void initializeProperties() throws IllegalStateException{ for (String parameter : parameterMap.keySet()) { try { String property = System.getProperty(parameter); if (property == null) { property = properties.getProperty(parameter); } if (property != null) { setValue(parameter, property); } } catch (Exception e) { throw new IllegalStateException("Wrong parameter settings for '" + parameter + "': " + e.getMessage()); } } if (POPULATION_LIMIT == PopulationLimit.STATEMENTS) { if (MAX_LENGTH < POPULATION) { MAX_LENGTH = POPULATION; } } }
/** * Update the evosuite.properties file with the current setting */ public void writeConfiguration() { URL fileURL = this.getClass().getClassLoader() .getResource("evosuite.properties"); String name = fileURL.getFile(); writeConfiguration(name); }
/** * @param args */ public static void main(String[] args) { if (args.length != 2) { System.err.println("Expected parameters: <TestCase> <Target Classpath>"); return; } Properties.getInstanceSilent(); DetermineSUT det = new DetermineSUT(); try { System.out.println(det.getSUTName(args[0], args[1])); } catch (NoJUnitClassException e) { System.err.println("Found no JUnit test case"); } }
@BeforeClass public static void initClass(){ Properties.getInstance(); }
public ClassPrimitiveStatement(TestCase tc) { // super(tc, new GenericClass(Class.class).getWithWildcardTypes(), super( tc, new GenericClass(Class.class).getWithParameterTypes(new Type[] { Properties.getTargetClassAndDontInitialise() }), Properties.getTargetClassAndDontInitialise()); // super(tc, new GenericClass(Properties.getTargetClass()), // Properties.getTargetClass()); }
final Class<?> targetClass = Properties.getTargetClassAndDontInitialise(); if(Properties.hasTargetClassBeenLoaded() && !f.getDeclaringClass().equals(targetClass)) { logger.debug("Skipping deprecated field " + f.getName()); return false;
@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)); } }
@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*/} }
Properties.getInstance();// should force the load, just to be sure Properties.TARGET_CLASS = targetClass; Properties.PROCESS_COMMUNICATION_PORT = port;