### Question:
RunSingleSPARQL { public QueryExecution createSPARQLQueryExecutionFactory(String query){ if(!sparqlprefix.isEmpty()){ Iterator<String> keys = sparqlprefix.keySet().iterator(); String prefix =""; while(keys.hasNext()){ String key = keys.next(); prefix = prefix+"PREFIX "+key+": "+sparqlprefix.get(key)+"\n"; } query = prefix+query; try{ return QueryExecutionFactory.create(query,jenamodel); }catch (Exception e){ e.printStackTrace(); return null; } }else{ System.err.println("There is not prefix defined in sparqlprefix."); return null; } } RunSingleSPARQL(OWLOntology owl);  RunSingleSPARQL(OWLOntology owl, Map<String,String> prefix); Map<String,String> getSPARQLprefix(); boolean addSPARQLprefix(String label,String prefix); boolean removeSPARQLprefix(String label); QueryExecution createSPARQLQueryExecutionFactory(String query);  }### Answer:
@Test public void testCreateSPARQLQueryExecutionFactory() { Map<String,String> map = new HashMap<String,String>(); map.put("rdfs","<http: map.put("xsd","<http: map.put("owl","<http: map.put("rdf","<http: map.put("ex","<http: String query = "SELECT * WHERE {?p rdf:type ex:Person .}"; RunSingleSPARQL instance = new RunSingleSPARQL(owl,map); QueryExecution queryExecution = instance.createSPARQLQueryExecutionFactory(query); if (queryExecution == null) { fail("Some errors occurred in createSPARQLQueryExecutionFactory of KReSRunSPARQL"); } ResultSet result = queryExecution.execSelect(); if(result!=null){ int m = 0; while(result.hasNext()){ result.next(); m++; } queryExecution.close(); assertEquals(3, m); }else{ fail("Some errors occur in createSPARQLQueryExecutionFactory of KReSRunSPARQL"); } }