/** * Only log once for a class * @param className * @param msg */ public synchronized void logWarn(String className, String msg){ AtMostOnceLogger.warn(logger,msg); }
/** * Rather use AtMostOnceLogger directly * * @param logger * @param message */ @Deprecated public static void logErrorAtMostOnce(Logger logger, String message){ AtMostOnceLogger.error(logger, message); }
public static void error(Logger logger, String message){ logAtMostOnce(logger, message, true); } }
/** * Rather use AtMostOnceLogger directly * * @param logger * @param message */ @Deprecated public static void logWarnAtMostOnce(Logger logger, String message){ AtMostOnceLogger.warn(logger, message); }
/** * Determine if there are generators * * @param clazz * @return */ public boolean hasGenerator(GenericClass clazz) { try { cacheGenerators(clazz); } catch (ConstructionFailedException e) { AtMostOnceLogger.error(logger, "Failed to check cache for "+clazz+" : "+e.getMessage()); } if (!generatorCache.containsKey(clazz)) return false; return !generatorCache.get(clazz).isEmpty(); }
public static void warn(Logger logger, String message){ logAtMostOnce(logger,message,false); }
/** * Creates a solution based on the best solutions in the archive and the parameter solution. * * @param solution a {@link org.evosuite.testsuite.TestSuiteChromosome} object. * @return a {@link org.evosuite.testsuite.TestSuiteChromosome} object. */ @SuppressWarnings("unchecked") public <C extends Chromosome> C mergeArchiveAndSolution(C solution) { if (solution instanceof TestChromosome) { return (C) this.createMergedSolution((TestChromosome) solution); } else if (solution instanceof TestSuiteChromosome) { return (C) this.createMergedSolution((TestSuiteChromosome) solution); } AtMostOnceLogger.warn(logger, "Type of solution '" + solution.getClass().getCanonicalName() + "' not supported"); return null; }
return true; } catch (Exception e){ AtMostOnceLogger.error(logger, "Failed to clear database: "+e); return false;
private void addToArchive(F target, T solution) { this.uncovered.remove(target); this.covered.put(target, solution); this.removeNonCoveredTargetOfAMethod(target); this.hasBeenUpdated = true; ExecutionResult result = solution.getLastExecutionResult(); if (result != null && (result.hasTimeout() || result.hasTestException())) { AtMostOnceLogger.warn(logger, "A solution with a timeout/exception result has been added to the archive. The covered goal was " + target.toString()); } }
throw e; } catch(java.lang.NoClassDefFoundError e) { AtMostOnceLogger.error(logger, "Cannot use Mockito on "+targetClass+" due to failed class initialization: "+e.getMessage()); return; //or should throw an exception? } catch(MockitoException | IllegalAccessException | IllegalAccessError | IllegalArgumentException e) { AtMostOnceLogger.error(logger, "Cannot use Mockito on "+targetClass+" due to IAE: "+e.getMessage()); throw new CodeUnderTestException(e); //or should throw an exception? } catch (Throwable t) { AtMostOnceLogger.error(logger, "Failed to use Mockito on " + targetClass + ": " + t.getMessage()); throw new EvosuiteError(t);
/** * This method is called when a new individual is sent from a client. * The individual represents the best individual of the current generation. * * @param individual best individual of current generation */ public void currentIndividual(Chromosome individual) { if(backend == null) return; if(!(individual instanceof TestSuiteChromosome)) { AtMostOnceLogger.warn(logger, "searchStatistics expected a TestSuiteChromosome"); return; } logger.debug("Received individual"); bestIndividual = (TestSuiteChromosome) individual; for(ChromosomeOutputVariableFactory<?> v : variableFactories.values()) { setOutputVariable(v.getVariable((TestSuiteChromosome) individual)); } for(SequenceOutputVariableFactory<?> v : sequenceOutputVariableFactories.values()) { v.update((TestSuiteChromosome) individual); } }
logger.error(""+e,e); } catch (NoClassDefFoundError e){ AtMostOnceLogger.error(logger,e.toString()); } catch(InvocationTargetException e){
AtMostOnceLogger.warn(logger, "Problem with class "+rawClass.getName()+": " + e.toString()); return false;
private static List<Class<?>> loadClasses(ClassLoader classLoader, String... classNames) { List<Class<?>> classes = new ArrayList<>(); InstrumentingAgent.activate(); boolean safe = Sandbox.isSafeToExecuteSUTCode(); //assert !Sandbox.isSecurityManagerInitialized() || Sandbox.isOnAndExecutingSUTCode(); for (int i=0; i< classNames.length;i++) { org.evosuite.runtime.Runtime.getInstance().resetRuntime(); String classNameToLoad = classNames[i]; Sandbox.goingToExecuteSUTCode(); boolean wasLoopCheckOn = LoopCounter.getInstance().isActivated(); try { if(!safe){ Sandbox.goingToExecuteUnsafeCodeOnSameThread(); } LoopCounter.getInstance().setActive(false); Class<?> aClass = Class.forName(classNameToLoad, true, classLoader); classes.add(aClass); } catch (Exception | Error ex) { AtMostOnceLogger.error(logger,"Could not initialize " + classNameToLoad + ": " + ex.getMessage()); } finally { if(!safe){ Sandbox.doneWithExecutingUnsafeCodeOnSameThread(); } Sandbox.doneWithExecutingSUTCode(); LoopCounter.getInstance().setActive(wasLoopCheckOn); } } InstrumentingAgent.deactivate(); return classes; }
AtMostOnceLogger.warn(logger, "Unknown criterion '" + criterion.name() + "'"); break;
AtMostOnceLogger.warn(LoggingUtils.getEvoLogger(), "ArrayStoreException caught while handling class "+c.getName()); AtMostOnceLogger.warn(LoggingUtils.getEvoLogger(), "This is likely due to a missing dependency used as annotation: https://bugs.java.com/view_bug.do?bug_id=JDK-7183985"); return false;
AtMostOnceLogger.warn(logger, "Not sufficient candidates for reproduction, consider increasing the population size, or the truncation rate");
AtMostOnceLogger.warn(logger, msg); throw new ConstructionFailedException(msg);
AtMostOnceLogger.warn(logger, msg); fms.fillWithNullRefs(); return changed;
AtMostOnceLogger.warn(logger,"Failed environment insertion: "+e);