use of org.evosuite.symbolic.TestCaseBuilder in project evosuite by EvoSuite.
the class TestSolverStringFunctions method buildTestEqualsIgnoreCase.
private static DefaultTestCase buildTestEqualsIgnoreCase() throws SecurityException, NoSuchMethodException {
TestCaseBuilder tc = new TestCaseBuilder();
VariableReference string0 = tc.appendStringPrimitive("Hello World");
Method method = TestCaseStringEqualsIgnoreCase.class.getMethod("test", String.class);
tc.appendMethod(null, method, string0);
return tc.getDefaultTestCase();
}
use of org.evosuite.symbolic.TestCaseBuilder in project evosuite by EvoSuite.
the class TestSolverStringFunctions method buildTestSubstringFromTo.
private static DefaultTestCase buildTestSubstringFromTo() throws SecurityException, NoSuchMethodException {
TestCaseBuilder tc = new TestCaseBuilder();
VariableReference string0 = tc.appendStringPrimitive("hamburger");
Method method = TestCaseStringSubstringFromTo.class.getMethod("test", String.class);
tc.appendMethod(null, method, string0);
return tc.getDefaultTestCase();
}
use of org.evosuite.symbolic.TestCaseBuilder in project evosuite by EvoSuite.
the class MockJOptionPaneTest method buildTestCase1.
private static TestCase buildTestCase1(InstrumentingClassLoader cl) throws ClassNotFoundException, NoSuchMethodException, SecurityException {
TestCaseBuilder builder = new TestCaseBuilder();
VariableReference string0 = builder.appendStringPrimitive("input0");
Class<?> jOptionPaneInputsClass = JOptionPaneInputs.class;
final String ENQUEUE_INPUT_STRING = "enqueueInputString";
Method enqueueStringMethod = jOptionPaneInputsClass.getMethod(ENQUEUE_INPUT_STRING, String.class);
builder.appendMethod(null, enqueueStringMethod, string0);
Class<?> clazz = cl.loadClass(TARGET_CLASS);
Constructor<?> constructor = clazz.getConstructor();
VariableReference showMessageDialogExample0 = builder.appendConstructor(constructor);
Method showConfirmDialogsMethod = clazz.getMethod("ask");
builder.appendMethod(showMessageDialogExample0, showConfirmDialogsMethod);
return builder.getDefaultTestCase();
}
use of org.evosuite.symbolic.TestCaseBuilder in project evosuite by EvoSuite.
the class TestLocalSearchMIMEType method createTestCase3.
private DefaultTestCase createTestCase3() throws NoSuchFieldException, SecurityException, NoSuchMethodException, ClassNotFoundException {
final Class<?> mimeTypeClass = TestGenerationContext.getInstance().getClassLoaderForSUT().loadClass(MIMEType.class.getName());
final Field xmlField = mimeTypeClass.getDeclaredField("XML");
final Method toString = mimeTypeClass.getMethod("toString");
final TestCaseBuilder builder = new TestCaseBuilder();
VariableReference mIMEType0 = builder.appendStaticFieldStmt(xmlField);
VariableReference string0 = builder.appendMethod(mIMEType0, toString);
System.out.println("Test Case #3=" + builder.toCode());
return builder.getDefaultTestCase();
}
use of org.evosuite.symbolic.TestCaseBuilder in project evosuite by EvoSuite.
the class TestLocalSearchMIMEType method createTestCase4.
private DefaultTestCase createTestCase4() throws NoSuchFieldException, SecurityException, NoSuchMethodException, ClassNotFoundException {
final Class<?> mimeTypeClass = TestGenerationContext.getInstance().getClassLoaderForSUT().loadClass(MIMEType.class.getName());
final Field rdfField = mimeTypeClass.getDeclaredField("RDF");
final Field slashField = mimeTypeClass.getDeclaredField("slash");
final Method equalsMethod = mimeTypeClass.getMethod("equals", Object.class);
final Constructor<?> constructorString = mimeTypeClass.getConstructor(String.class);
final Field mimeTypeField = mimeTypeClass.getDeclaredField("mimeType");
final Method getTypeMethod = mimeTypeClass.getMethod("getType");
final Method toString = mimeTypeClass.getMethod("toString");
final TestCaseBuilder builder = new TestCaseBuilder();
VariableReference mIMEType0 = builder.appendStaticFieldStmt(rdfField);
VariableReference int0 = builder.appendIntPrimitive(2415);
VariableReference int1 = builder.appendIntPrimitive(2415);
VariableReference int2 = builder.appendIntPrimitive(-196);
builder.appendAssignment(mIMEType0, slashField, int2);
builder.appendAssignment(mIMEType0, slashField, int0);
VariableReference int3 = builder.appendIntPrimitive(0);
builder.appendAssignment(mIMEType0, slashField, int1);
builder.appendAssignment(mIMEType0, slashField, int3);
VariableReference boolean0 = builder.appendMethod(mIMEType0, equalsMethod, mIMEType0);
VariableReference string0 = builder.appendStringPrimitive("/");
VariableReference string1 = builder.appendStringPrimitive("\"cC3$]nc.<p) u:");
VariableReference mIMEType1 = builder.appendConstructor(constructorString, string0);
builder.appendAssignment(mIMEType1, slashField, mIMEType0, slashField);
VariableReference string2 = builder.appendNull(String.class);
builder.appendAssignment(mIMEType1, mimeTypeField, string2);
VariableReference int4 = builder.appendFieldStmt(mIMEType0, slashField);
builder.appendMethod(mIMEType1, getTypeMethod);
builder.addException(new NullPointerException());
VariableReference string3 = builder.appendMethod(mIMEType1, toString);
System.out.println("Test Case #4=" + builder.toCode());
return builder.getDefaultTestCase();
}
Aggregations