Actually most if not all the tests in this generated test class don’t look that good:
/*
* This file was automatically generated by EvoSuite
* Mon Oct 07 13:18:11 GMT 2019
*/
package org.xwiki.xml.internal.html;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.evosuite.shaded.org.mockito.Mockito.*;
import java.io.Reader;
import java.io.StringReader;
import org.evosuite.runtime.ViolatedAssumptionAnswer;
import org.evosuite.runtime.javaee.injection.Injector;
import org.w3c.dom.Document;
import org.xwiki.context.Execution;
import org.xwiki.context.ExecutionContext;
import org.xwiki.xml.html.HTMLCleanerConfiguration;
import org.xwiki.xml.internal.html.DefaultHTMLCleaner;
import org.xwiki.xml.internal.html.DefaultHTMLCleanerConfiguration;
import org.xwiki.xml.internal.html.filter.FontFilter;
import org.xwiki.xml.internal.html.filter.ListFilter;
import org.xwiki.xml.internal.html.filter.UniqueIdFilter;
public class DefaultHTMLCleaner_ESTest {
@Test(timeout = 4000)
public void test0() throws Throwable {
DefaultHTMLCleaner defaultHTMLCleaner0 = new DefaultHTMLCleaner();
// Undeclared exception!
try {
defaultHTMLCleaner0.clean((Reader) null);
fail("Expecting exception: RuntimeException");
} catch(RuntimeException e) {
//
// Unhandled error when cleaning HTML
//
}
}
@Test(timeout = 4000)
public void test1() throws Throwable {
DefaultHTMLCleaner defaultHTMLCleaner0 = new DefaultHTMLCleaner();
UniqueIdFilter uniqueIdFilter0 = new UniqueIdFilter();
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "attributeFilter", (Object) uniqueIdFilter0);
FontFilter fontFilter0 = new FontFilter();
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "bodyFilter", (Object) fontFilter0);
Execution execution0 = mock(Execution.class, new ViolatedAssumptionAnswer());
doReturn((ExecutionContext) null).when(execution0).getContext();
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "execution", (Object) execution0);
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "fontFilter", (Object) fontFilter0);
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "linkFilter", (Object) fontFilter0);
ListFilter listFilter0 = new ListFilter();
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "listFilter", (Object) listFilter0);
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "listItemFilter", (Object) listFilter0);
Injector.validateBean(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class);
StringReader stringReader0 = new StringReader("Eb_H#\"[M");
Document document0 = defaultHTMLCleaner0.clean((Reader) stringReader0);
assertNotNull(document0);
}
@Test(timeout = 4000)
public void test2() throws Throwable {
DefaultHTMLCleaner defaultHTMLCleaner0 = new DefaultHTMLCleaner();
UniqueIdFilter uniqueIdFilter0 = new UniqueIdFilter();
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "attributeFilter", (Object) uniqueIdFilter0);
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "bodyFilter", (Object) uniqueIdFilter0);
ExecutionContext executionContext0 = new ExecutionContext();
Execution execution0 = mock(Execution.class, new ViolatedAssumptionAnswer());
doReturn(executionContext0).when(execution0).getContext();
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "execution", (Object) execution0);
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "fontFilter", (Object) uniqueIdFilter0);
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "linkFilter", (Object) uniqueIdFilter0);
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "listFilter", (Object) uniqueIdFilter0);
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "listItemFilter", (Object) uniqueIdFilter0);
Injector.validateBean(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class);
StringReader stringReader0 = new StringReader("\b K.}|3}@L<U(E|Gpi");
Document document0 = defaultHTMLCleaner0.clean((Reader) stringReader0);
assertNotNull(document0);
}
@Test(timeout = 4000)
public void test3() throws Throwable {
DefaultHTMLCleaner defaultHTMLCleaner0 = new DefaultHTMLCleaner();
HTMLCleanerConfiguration hTMLCleanerConfiguration0 = defaultHTMLCleaner0.getDefaultConfiguration();
// Undeclared exception!
try {
defaultHTMLCleaner0.clean((Reader) null, hTMLCleanerConfiguration0);
fail("Expecting exception: RuntimeException");
} catch(RuntimeException e) {
//
// Unhandled error when cleaning HTML
//
}
}
@Test(timeout = 4000)
public void test4() throws Throwable {
DefaultHTMLCleaner defaultHTMLCleaner0 = new DefaultHTMLCleaner();
UniqueIdFilter uniqueIdFilter0 = new UniqueIdFilter();
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "attributeFilter", (Object) uniqueIdFilter0);
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "bodyFilter", (Object) uniqueIdFilter0);
ExecutionContext executionContext0 = mock(ExecutionContext.class, new ViolatedAssumptionAnswer());
doReturn(uniqueIdFilter0).when(executionContext0).getProperty(anyString());
Execution execution0 = mock(Execution.class, new ViolatedAssumptionAnswer());
doReturn(executionContext0).when(execution0).getContext();
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "execution", (Object) execution0);
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "fontFilter", (Object) uniqueIdFilter0);
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "linkFilter", (Object) uniqueIdFilter0);
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "listFilter", (Object) uniqueIdFilter0);
Injector.inject(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class, "listItemFilter", (Object) uniqueIdFilter0);
Injector.validateBean(defaultHTMLCleaner0, (Class<?>) DefaultHTMLCleaner.class);
StringReader stringReader0 = new StringReader("\b K.}|3}@L<U(E|Gpi");
// Undeclared exception!
try {
defaultHTMLCleaner0.clean((Reader) stringReader0);
fail("Expecting exception: ClassCastException");
} catch(ClassCastException e) {
//
// org.xwiki.xml.internal.html.filter.UniqueIdFilter cannot be cast to javax.xml.parsers.DocumentBuilder
//
}
}
@Test(timeout = 4000)
public void test5() throws Throwable {
DefaultHTMLCleaner defaultHTMLCleaner0 = new DefaultHTMLCleaner();
StringReader stringReader0 = new StringReader("'");
// Undeclared exception!
try {
defaultHTMLCleaner0.clean((Reader) stringReader0);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// no message in exception (getMessage() returned null)
//
}
}
@Test(timeout = 4000)
public void test6() throws Throwable {
DefaultHTMLCleaner defaultHTMLCleaner0 = new DefaultHTMLCleaner();
StringReader stringReader0 = new StringReader("namespacesAware");
DefaultHTMLCleanerConfiguration defaultHTMLCleanerConfiguration0 = new DefaultHTMLCleanerConfiguration();
// Undeclared exception!
try {
defaultHTMLCleaner0.clean((Reader) stringReader0, (HTMLCleanerConfiguration) defaultHTMLCleanerConfiguration0);
fail("Expecting exception: NullPointerException");
} catch(NullPointerException e) {
//
// no message in exception (getMessage() returned null)
//
}
}
}