org.opencms.search
Class TestCmsSearch

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.opencms.test.OpenCmsTestCase
              extended by org.opencms.search.TestCmsSearch
All Implemented Interfaces:
junit.framework.Test

public class TestCmsSearch
extends OpenCmsTestCase

Unit test for the cms search indexer.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.opencms.test.OpenCmsTestCase
OpenCmsTestCase.ConnectionData
 
Field Summary
static String INDEX_OFFLINE
          Name of the index used for testing.
static String INDEX_TEST
          Name of the search index created using API.
 
Fields inherited from class org.opencms.test.OpenCmsTestCase
ARTICLE_TYPEID, DB_MYSQL, DB_ORACLE, m_additionalConnection, m_configuration, m_currentResourceStrorage, m_defaultConnection, m_defaultTablespace, m_indexTablespace, m_resourceStorages, m_setupConnection, m_tempTablespace
 
Constructor Summary
TestCmsSearch(String arg0)
          Default JUnit constructor.
 
Method Summary
static void printResults(List<CmsSearchResult> searchResult, CmsObject cms)
          Prints the given list of search results to STDOUT.
static void printResults(List<CmsSearchResult> searchResult, CmsObject cms, boolean showExcerpt)
          Prints the given list of search results to STDOUT.
static junit.framework.Test suite()
          Test suite for this test class.
 void testCmsSearchDocumentTypes()
          Tests searching in various document types.
 void testCmsSearchIndexer()
          Test the cms search indexer.
 void testCmsSearchLargeResult()
          Tests the cms search with a larger result set.
 void testCmsSearchUppercaseFolderName()
          Tests the CmsSearch with folder names with upper case letters.
 void testCmsSearchXmlContent()
          Test the cms search indexer.
 void testIndexGeneration()
          Tests index generation with different analyzers.
 void testQueryEncoding()
          Tests if CmsSearch.setQuery(String) modifies the query in an undesireable way (changes url encoded Strings).
 void testSearchIssueWithSpecialFoldernames()
          Tests an issue where no results are found in folders that have names like /basisdienstleistungen_-_zka/.
 
Methods inherited from class org.opencms.test.OpenCmsTestCase
addTestDataPath, assertAce, assertAcl, assertAcl, assertContains, assertContainsNot, assertContent, assertDateContent, assertDateContentAfter, assertDateCreated, assertDateCreatedAfter, assertDateExpired, assertDateLastModified, assertDateLastModifiedAfter, assertDateReleased, assertEquals, assertEquals, assertEquals, assertFilter, assertFilter, assertFilter, assertFilter, assertFlags, assertHistory, assertHistoryForRestored, assertIsFolder, assertIsIdentical, assertIsNotIdentical, assertLock, assertLock, assertLock, assertModifiedInCurrentProject, assertPermissionString, assertProject, assertPropertyChanged, assertPropertyChanged, assertPropertydefinitionExist, assertPropertydefinitions, assertPropertyEqual, assertPropertyNew, assertPropertyNew, assertPropertyRemoved, assertPropertyRemoved, assertRelation, assertResourceId, assertResourceType, assertSiblingCount, assertSiblingCountIncremented, assertState, assertStructureId, assertType, assertUserCreated, assertUserLastModified, assertVersion, checkErrors, createStorage, deleteFile, echo, generateContent, generateContent, generateName, generateProperties, generateResources, generateSetupTestWrapper, generateUsers, getCmsObject, getConnectionName, getDatabaseProduct, getDbProduct, getPreCalculatedState, getReplacer, getSetupDataPath, getSetupDb, getTestDataPath, importData, importResources, importTestResource, initTestDataPath, removeDatabase, removeDatabase, removeOpenCms, removeStorage, resetMapping, restart, restartOpenCms, setMapping, setupDatabase, setupDatabase, setupOpenCms, setupOpenCms, setupOpenCms, setupOpenCms, setupOpenCms, storeResources, storeResources, switchStorage
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INDEX_OFFLINE

public static final String INDEX_OFFLINE
Name of the index used for testing.

See Also:
Constant Field Values

INDEX_TEST

public static final String INDEX_TEST
Name of the search index created using API.

See Also:
Constant Field Values
Constructor Detail

TestCmsSearch

public TestCmsSearch(String arg0)
Default JUnit constructor.

Parameters:
arg0 - JUnit parameters
Method Detail

suite

public static junit.framework.Test suite()
Test suite for this test class.

Returns:
the test suite

testCmsSearchDocumentTypes

public void testCmsSearchDocumentTypes()
                                throws Throwable
Tests searching in various document types.

Throws:
Throwable - if something goes wrong

testCmsSearchIndexer

public void testCmsSearchIndexer()
                          throws Throwable
Test the cms search indexer.

Throws:
Throwable - if something goes wrong

testCmsSearchLargeResult

public void testCmsSearchLargeResult()
                              throws Throwable
Tests the cms search with a larger result set.

Throws:
Throwable - if something goes wrong

testCmsSearchUppercaseFolderName

public void testCmsSearchUppercaseFolderName()
                                      throws Exception
Tests the CmsSearch with folder names with upper case letters.

Throws:
Exception - in case the test fails

testCmsSearchXmlContent

public void testCmsSearchXmlContent()
                             throws Throwable
Test the cms search indexer.

Throws:
Throwable - if something goes wrong

testIndexGeneration

public void testIndexGeneration()
                         throws Throwable
Tests index generation with different analyzers.

This test was added in order to verify proper generation of resource "root path" information in the index.

Throws:
Throwable - if something goes wrong

testQueryEncoding

public void testQueryEncoding()
Tests if CmsSearch.setQuery(String) modifies the query in an undesireable way (changes url encoded Strings).


testSearchIssueWithSpecialFoldernames

public void testSearchIssueWithSpecialFoldernames()
                                           throws Exception
Tests an issue where no results are found in folders that have names like /basisdienstleistungen_-_zka/.

Throws:
Exception - if the test fails

printResults

public static void printResults(List<CmsSearchResult> searchResult,
                                CmsObject cms)
Prints the given list of search results to STDOUT.

Parameters:
searchResult - the list to print
cms - the current OpenCms user context

printResults

public static void printResults(List<CmsSearchResult> searchResult,
                                CmsObject cms,
                                boolean showExcerpt)
Prints the given list of search results to STDOUT.

Parameters:
searchResult - the list to print
cms - the current OpenCms user context
showExcerpt - if true, the generated excerpt is also displayed