use of org.evosuite.runtime.testdata.EvoSuiteURL in project evosuite by EvoSuite.
the class SymbolicObserver method after.
private void after(UrlPrimitiveStatement s, Scope scope) {
EvoSuiteURL conc_url = s.getValue();
VariableReference varRef = s.getReturnValue();
String varRefName = varRef.getName();
ReferenceExpression urlRef;
if (conc_url == null) {
urlRef = env.heap.getReference(null);
if (urlRef.getConcreteValue() != null) {
throw new IllegalStateException("Expected null concrete value");
}
} else {
urlRef = (ReferenceConstant) env.heap.getReference(conc_url);
if (urlRef.getConcreteValue() == null) {
throw new IllegalStateException("Expected non-null concrete value");
}
}
symb_references.put(varRefName, urlRef);
}
use of org.evosuite.runtime.testdata.EvoSuiteURL in project evosuite by EvoSuite.
the class ConcolicExecutionEnvironmentTest method buildTestCaseWithURL.
private static DefaultTestCase buildTestCaseWithURL() throws SecurityException, NoSuchMethodException {
TestCaseBuilder tc = new TestCaseBuilder();
// int int0 = 10;
VariableReference int0 = tc.appendIntPrimitive(10);
// String urlString = "http://evosuite.org/hello.txt";
VariableReference urlStringVarRef = tc.appendStringPrimitive("http://evosuite.org/hello.txt");
// MockURL mockURL0 = MockURL.URL(urlString);
Method urlMethod = MockURL.class.getMethod("URL", String.class);
VariableReference mockURLVarRef = tc.appendMethod(null, urlMethod, urlStringVarRef);
// EvoSuiteURL evosuiteURL = new EvoSuiteURL();
Constructor<EvoSuiteURL> evoSuiteURLCtor = EvoSuiteURL.class.getConstructor(String.class);
VariableReference evosuiteURL = tc.appendConstructor(evoSuiteURLCtor, urlStringVarRef);
// String string0 = "<<FILE CONTENT>>"
VariableReference string0VarRef = tc.appendStringPrimitive("<<FILE CONTENT>>");
// NetworkHandling.createRemoteTextFile(url, string0)
Method appendStringToFileMethod = NetworkHandling.class.getMethod("createRemoteTextFile", EvoSuiteURL.class, String.class);
tc.appendMethod(null, appendStringToFileMethod, evosuiteURL, string0VarRef);
// TestCaseWithURL testCaseWithURL0 = new TestCaseWithURL();
Constructor<TestCaseWithURL> ctor = TestCaseWithURL.class.getConstructor();
VariableReference testCaseWithURLVarRef = tc.appendConstructor(ctor);
// String ret_val = dseWithFile0.test((URL) mockURL0);
Method testMethod = TestCaseWithURL.class.getMethod("test", URL.class);
tc.appendMethod(testCaseWithURLVarRef, testMethod, mockURLVarRef);
// DseWithFile.isiZero(int0)
Method isZeroMethod = TestCaseWithFile.class.getMethod("isZero", int.class);
tc.appendMethod(null, isZeroMethod, int0);
return tc.getDefaultTestCase();
}
use of org.evosuite.runtime.testdata.EvoSuiteURL in project evosuite by EvoSuite.
the class MockUrlSystemTest method testLoading_ReadFromURL.
@Test(timeout = 5000)
public void testLoading_ReadFromURL() throws Exception {
// for some reason, this class failed when using loop limit in the search
RuntimeSettings.useVNET = true;
RuntimeSettings.maxNumberOfIterationsPerLoop = 100_000;
MethodCallReplacementCache.resetSingleton();
org.evosuite.runtime.Runtime.getInstance().resetRuntime();
EvoClassLoader loader = new EvoClassLoader();
Class<?> clazz = loader.loadClass(ReadFromURL.class.getCanonicalName());
Method m = clazz.getMethod("checkResource");
boolean b = (Boolean) m.invoke(null);
Assert.assertFalse(b);
EvoSuiteURL evoURL = new EvoSuiteURL("http://www.evosuite.org/index.html");
NetworkHandling.createRemoteTextFile(evoURL, "foo");
b = (Boolean) m.invoke(null);
Assert.assertTrue(b);
}
Aggregations