How to throw a parseException in a switch statement?
<p>To increase my projects code coverage, I need to reach the branch <strong>ParseException</strong> in this method:</p>

<pre><code>public String filterMessage(String actionIn, String messageIn) {
        String message = null;
        try{
            switch (actionIn) {
            //EDIT: this calls the other class causing parseexception
            case "search":
                message = (srvmt.SearchEngine(messageIn));
                break;
            default:
                message = messageIn;
                break;
            }

        }catch (ParseException e) {
            System.out.println("Encountered parse exception");
            e.printStackTrace();
        }catch(IOException ioException){
            ioException.printStackTrace();
        }
        return message;
    }
</code></pre>

<p>Instincts are that we must put a String that is "illegal", that can't be parsed because it isn't actually a String, but how do you place something like that without causing a compile error (like putting an int to cause faulse parsing). Any ideas how to test this catch "branch"?</p>

<p>EDIT: This is the method the case above calls which uses a parse exception</p>

<pre><code>public  String SearchEngine(String removecommand)
{//INCOMING-SEARCH¿Email¿@gmail.com
    JSONArray databaseupdated = read(pathdatabase);
    ArrayList&lt;String&gt; matchlist = new ArrayList&lt;String&gt;();
    JSONObject mainobj = new JSONObject();
    JSONArray userinfo = new JSONArray();
    JSONObject obj = new JSONObject();
    for(int i = 0; i&lt;databaseupdated.size(); i++)
    {
        String option = "";
        String value = "";
        try {
            JSONObject json = (JSONObject) new JSONParser().parse(removecommand);
            option = (String) json.get("option");
            value = (String) json.get("value");
            mainobj= (JSONObject) new JSONParser().parse(databaseupdated.get(i).toString());
            userinfo =(JSONArray) new JSONParser().parse(mainobj.get(mainobj.keySet().toString().substring(1,mainobj.keySet().toString().length()-1)).toString());
            obj = (JSONObject) new JSONParser().parse(userinfo.get(0).toString());  
        } //EDIT, there is a lot of code not explained, but here is the parse EXCEPTION
          catch (ParseException e) {
            return "false";
        }
        if(SearchEngineTRUEFALSE1(mainobj.keySet().toString().substring(1,mainobj.keySet().toString().length()-1),option,value))
        {
            matchlist.add(obj.get("Email").toString());
        }
    }
    return matchlist.toString();
}
</code></pre>