Wikipedia implements WikiConstants { public boolean existsPage(String title) { if (title == null || title.length() == 0) { return false; } Title t; try { t = new Title(title); } catch (WikiTitleParsingException e) { return false; } String encodedTitle = t.getWikiStyleTitle(); Session session = this.__getHibernateSession(); session.beginTransaction(); String query = "select p.id from PageMapLine as p where p.name = :pName"; if(dbConfig.supportsCollation()) { query += SQL_COLLATION; } Object returnValue = session.createNativeQuery(query) .setParameter("pName", encodedTitle, StringType.INSTANCE) .uniqueResult(); session.getTransaction().commit(); return returnValue != null; } Wikipedia(DatabaseConfiguration dbConfig); Page getPage(String title); Page getPageByExactTitle(String exactTitle); Set<Page> getPages(String title); Page getPage(int pageId); Title getTitle(int pageId); List<Integer> getPageIds(String title); List<Integer> getPageIdsCaseInsensitive(String title); Page getArticleForDiscussionPage(Page discussionPage); Page getDiscussionPage(int articlePageId); Page getDiscussionPage(String title); Page getDiscussionPage(Page articlePage); Iterable<Page> getDiscussionArchives(int articlePageId); Iterable<Page> getDiscussionArchives(String title); Iterable<Page> getDiscussionArchives(Page articlePage); Category getCategory(String title); Category getCategory(int pageId); Iterable<Category> getCategories(); Set<Category> getCategories(String pageTitle); Iterable<Page> getPages(); Iterable<Integer> getPageIds(); Iterable<Page> getPages(PageQuery query); Iterable<Page> getArticles(); Iterable<Title> getTitles(); Language getLanguage(); boolean existsPage(String title); boolean existsPage(int pageID); MetaData getMetaData(); DatabaseConfiguration getDatabaseConfiguration(); String getWikipediaId();  }
@Test public void testExistsPageByTitleNullOrEmpty() { assertFalse(wiki.existsPage(null)); assertFalse(wiki.existsPage("")); }
@Test public void testExistsPageByID() { assertTrue(wiki.existsPage(A_FAMOUS_PAGE_ID)); }
@Test public void testExistsPageByIDInvalid1() { assertFalse(wiki.existsPage(-42)); }
@Test public void testExistsPageByIDInvalid2() { assertFalse(wiki.existsPage(Integer.MAX_VALUE)); }
@Test public void testExistsPageByTitle() { assertTrue(wiki.existsPage(A_FAMOUS_PAGE)); }
@Test public void testExistsPageByTitleInvalid() { assertFalse(wiki.existsPage(A_FAMOUS_PAGE+"_")); assertFalse(wiki.existsPage(A_FAMOUS_PAGE+" (X)")); assertFalse(wiki.existsPage(" (X)")); }