Commit 2c09703f authored by Nanfeng Liu's avatar Nanfeng Liu
Browse files

fixed null pointer exception

parent 275ffa39
Pipeline #63726 failed with stages
in 66 minutes and 43 seconds
......@@ -39,14 +39,14 @@ public class WebServer {
public static Page execute(String query, String type) {
if (query.length() <3){
query += " ";
/* java.lang.IllegalArgumentException: Prefix string
"" too short: length must be at least 3 */
}
if (query == null) {
return new IndexPage();
} else {
if (query.length() <3){
query += " ";
/* java.lang.IllegalArgumentException: Prefix string
"" too short: length must be at least 3 */
}
String result = new QueryProcessor().process(query);
if(type == null){
return new HTMLResultPage(query, result);
......
......@@ -3,7 +3,6 @@ import static ic.doc.WebServer.execute;
import static junit.framework.TestCase.assertTrue;
import ic.doc.web.HTMLResultPage;
import ic.doc.web.IndexPage;
import ic.doc.web.Page;
import java.io.File;
import org.junit.Test;
......@@ -47,7 +46,7 @@ public class doGetTest {
Page p = execute("shakespeare", "markdown");
assertTrue(p instanceof MarkDownPage);
}
//test that there is a markdown file created
@Test
public void markdownFileCreated() throws Exception {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment