Search in sources :

Example 1 with MIMEType

use of com.examples.with.different.packagename.concolic.MIMEType in project evosuite by EvoSuite.

the class TestLocalSearchMIMEType method createTestCase2.

private DefaultTestCase createTestCase2() throws NoSuchFieldException, SecurityException, NoSuchMethodException, ClassNotFoundException {
    final Class<?> mimeTypeClass = TestGenerationContext.getInstance().getClassLoaderForSUT().loadClass(MIMEType.class.getName());
    final Field rdfField = mimeTypeClass.getDeclaredField("RDF");
    final Method hashCode = mimeTypeClass.getMethod("hashCode");
    final Field slashField = mimeTypeClass.getDeclaredField("slash");
    final Method getTypeMethod = mimeTypeClass.getMethod("getType");
    final Method getSubTypeMethod = mimeTypeClass.getMethod("getSubType");
    final Method equalsMethod = mimeTypeClass.getMethod("equals", Object.class);
    final Field mimeTypeField = mimeTypeClass.getDeclaredField("mimeType");
    final Constructor<?> constructorStringBoolean = mimeTypeClass.getConstructor(String.class, boolean.class);
    final TestCaseBuilder builder = new TestCaseBuilder();
    VariableReference mIMEType0 = builder.appendStaticFieldStmt(rdfField);
    VariableReference string0 = builder.appendStringPrimitive("");
    VariableReference int0 = builder.appendMethod(mIMEType0, hashCode);
    VariableReference string1 = builder.appendStringPrimitive("");
    VariableReference int1 = builder.appendIntPrimitive(0);
    VariableReference string2 = builder.appendStringPrimitive("com.examples.with.different.packagename.concolic.MalformedMIMETypeException");
    builder.appendAssignment(mIMEType0, slashField, int1);
    VariableReference int2 = builder.appendFieldStmt(mIMEType0, slashField);
    VariableReference string3 = builder.appendMethod(mIMEType0, getTypeMethod);
    VariableReference string4 = builder.appendMethod(mIMEType0, getSubTypeMethod);
    VariableReference boolean0 = builder.appendMethod(mIMEType0, equalsMethod, string3);
    VariableReference string5 = builder.appendFieldStmt(mIMEType0, mimeTypeField);
    VariableReference string6 = builder.appendMethod(mIMEType0, getSubTypeMethod);
    VariableReference int3 = builder.appendFieldStmt(mIMEType0, slashField);
    VariableReference string7 = builder.appendStringPrimitive("xT7vo\"<|[E{4");
    builder.appendConstructor(constructorStringBoolean, string7, boolean0);
    builder.addException(new Error());
    System.out.println("Test Case #2=" + builder.toCode());
    return builder.getDefaultTestCase();
}
Also used : Field(java.lang.reflect.Field) TestCaseBuilder(org.evosuite.symbolic.TestCaseBuilder) MIMEType(com.examples.with.different.packagename.concolic.MIMEType) VariableReference(org.evosuite.testcase.variable.VariableReference) Method(java.lang.reflect.Method)

Example 2 with MIMEType

use of com.examples.with.different.packagename.concolic.MIMEType in project evosuite by EvoSuite.

the class TestLocalSearchMIMEType method createTestCase1.

private DefaultTestCase createTestCase1() throws NoSuchFieldException, SecurityException, NoSuchMethodException, ClassNotFoundException {
    final TestCaseBuilder builder = new TestCaseBuilder();
    final Class<?> mimeTypeClass = TestGenerationContext.getInstance().getClassLoaderForSUT().loadClass(MIMEType.class.getName());
    final Class<?> objectClass = TestGenerationContext.getInstance().getClassLoaderForSUT().loadClass(Object.class.getName());
    final Constructor<?> constructorStringBoolean = mimeTypeClass.getConstructor(String.class, boolean.class);
    final Constructor<?> constructorString = mimeTypeClass.getConstructor(String.class);
    final Field mimeTypeField = mimeTypeClass.getDeclaredField("mimeType");
    final Field slashField = mimeTypeClass.getDeclaredField("slash");
    final Method getSubTypeMethod = mimeTypeClass.getMethod("getSubType");
    final Method equalsMethod = mimeTypeClass.getMethod("equals", Object.class);
    final Method getTypeMethod = mimeTypeClass.getMethod("getType");
    VariableReference string0 = builder.appendStringPrimitive("Y.8p>:/]WybaL");
    VariableReference boolean0 = builder.appendBooleanPrimitive(false);
    VariableReference mIMEType0 = builder.appendConstructor(constructorStringBoolean, string0, boolean0);
    VariableReference int0 = builder.appendIntPrimitive(-1);
    VariableReference int1 = builder.appendIntPrimitive(-1);
    VariableReference int2 = builder.appendIntPrimitive(1);
    builder.appendAssignment(mIMEType0, slashField, int2);
    builder.appendAssignment(mIMEType0, slashField, int0);
    builder.appendAssignment(mIMEType0, slashField, int1);
    VariableReference int3 = builder.appendIntPrimitive(0);
    VariableReference string1 = builder.appendStringPrimitive("Jm");
    builder.appendAssignment(mIMEType0, mimeTypeField, string1);
    VariableReference int4 = builder.appendIntPrimitive(2556);
    VariableReference int5 = builder.appendIntPrimitive(2556);
    builder.appendAssignment(mIMEType0, slashField, int4);
    builder.appendAssignment(mIMEType0, slashField, int3);
    VariableReference string2 = builder.appendMethod(mIMEType0, getSubTypeMethod);
    VariableReference object0 = builder.appendNull(objectClass);
    VariableReference boolean1 = builder.appendMethod(mIMEType0, equalsMethod, object0);
    VariableReference object1 = builder.appendNull(objectClass);
    VariableReference boolean2 = builder.appendMethod(mIMEType0, equalsMethod, object1);
    VariableReference string3 = builder.appendStringPrimitive("");
    VariableReference mIMEType1 = builder.appendConstructor(constructorString, string3);
    builder.addException(new Exception());
    builder.appendAssignment(mIMEType1, slashField, int5);
    VariableReference string4 = builder.appendStringPrimitive("DI'XL>AQzq1");
    builder.appendAssignment(mIMEType1, mimeTypeField, string4);
    VariableReference string5 = builder.appendFieldStmt(mIMEType1, mimeTypeField);
    VariableReference string6 = builder.appendStringPrimitive("bjvXpt%");
    VariableReference boolean3 = builder.appendBooleanPrimitive(true);
    VariableReference mIMEType2 = builder.appendConstructor(constructorStringBoolean, string6, boolean3);
    builder.appendAssignment(mIMEType2, slashField, mIMEType0, slashField);
    VariableReference string7 = builder.appendMethod(mIMEType0, getTypeMethod);
    VariableReference mIMEType3 = builder.appendConstructor(constructorStringBoolean, string5, boolean1);
    builder.appendAssignment(mIMEType1, mimeTypeField, string7);
    VariableReference string8 = builder.appendStringPrimitive("g");
    VariableReference mIMEType4 = builder.appendConstructor(constructorString, string8);
    VariableReference string9 = builder.appendMethod(mIMEType1, getTypeMethod);
    System.out.println("Test Case #1=" + builder.toCode());
    return builder.getDefaultTestCase();
}
Also used : Field(java.lang.reflect.Field) TestCaseBuilder(org.evosuite.symbolic.TestCaseBuilder) MIMEType(com.examples.with.different.packagename.concolic.MIMEType) VariableReference(org.evosuite.testcase.variable.VariableReference) Method(java.lang.reflect.Method)

Example 3 with MIMEType

use of com.examples.with.different.packagename.concolic.MIMEType 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();
}
Also used : Field(java.lang.reflect.Field) TestCaseBuilder(org.evosuite.symbolic.TestCaseBuilder) MIMEType(com.examples.with.different.packagename.concolic.MIMEType) VariableReference(org.evosuite.testcase.variable.VariableReference) Method(java.lang.reflect.Method)

Aggregations

MIMEType (com.examples.with.different.packagename.concolic.MIMEType)3 Field (java.lang.reflect.Field)3 Method (java.lang.reflect.Method)3 TestCaseBuilder (org.evosuite.symbolic.TestCaseBuilder)3 VariableReference (org.evosuite.testcase.variable.VariableReference)3