Skip to content
Snippets Groups Projects
Commit 22a1dc85 authored by kaloyane's avatar kaloyane
Browse files

minor: comment out broken test

SVN: 20412
parent b40f7ded
No related branches found
No related tags found
No related merge requests found
...@@ -21,31 +21,19 @@ import static org.testng.AssertJUnit.assertFalse; ...@@ -21,31 +21,19 @@ import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue; import static org.testng.AssertJUnit.assertTrue;
import static org.testng.AssertJUnit.fail; import static org.testng.AssertJUnit.fail;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.commons.io.FileUtils;
import org.hibernate.classic.Session;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
import org.testng.AssertJUnit; import org.testng.AssertJUnit;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import ch.rinn.restrictions.Friend; import ch.rinn.restrictions.Friend;
import ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked;
import ch.systemsx.cisd.common.filesystem.FileUtilities;
import ch.systemsx.cisd.common.test.AssertionUtil; import ch.systemsx.cisd.common.test.AssertionUtil;
import ch.systemsx.cisd.openbis.generic.server.dataaccess.IHibernateSearchDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IHibernateSearchDAO;
import ch.systemsx.cisd.openbis.generic.server.dataaccess.db.search.FullTextIndexerRunnable;
import ch.systemsx.cisd.openbis.generic.server.util.TestInitializer;
import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetAttributeSearchFieldKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetAttributeSearchFieldKind;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DetailedSearchAssociationCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DetailedSearchAssociationCriteria;
...@@ -55,10 +43,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DetailedSearchField; ...@@ -55,10 +43,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DetailedSearchField;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MatchingEntity; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MatchingEntity;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SearchCriteriaConnection; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SearchCriteriaConnection;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetPropertyPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.EntityPropertyPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.IEntityPropertiesHolder;
import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialPE; import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialPropertyPE; import ch.systemsx.cisd.openbis.generic.shared.dto.MaterialPropertyPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.PropertyTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.PropertyTypePE;
...@@ -77,31 +62,31 @@ import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils; ...@@ -77,31 +62,31 @@ import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils;
public final class HibernateSearchDAOTest extends AbstractDAOTest public final class HibernateSearchDAOTest extends AbstractDAOTest
{ {
private final static String LUCENE_INDEX_TEMPLATE_PATH = "./sourceTest/lucene/indices"; // private final static String LUCENE_INDEX_TEMPLATE_PATH = "./sourceTest/lucene/indices";
//
@BeforeClass // @BeforeClass
public void setUpIndex() // public void setUpIndex()
{ // {
restoreSearchIndex(); // restoreSearchIndex();
} // }
//
// create a fresh copy of the Lucene index // // create a fresh copy of the Lucene index
private static void restoreSearchIndex() // private static void restoreSearchIndex()
{ // {
File targetPath = new File(TestInitializer.LUCENE_INDEX_PATH); // File targetPath = new File(TestInitializer.LUCENE_INDEX_PATH);
FileUtilities.deleteRecursively(targetPath); // FileUtilities.deleteRecursively(targetPath);
targetPath.mkdirs(); // targetPath.mkdirs();
File srcPath = new File(LUCENE_INDEX_TEMPLATE_PATH); // File srcPath = new File(LUCENE_INDEX_TEMPLATE_PATH);
try // try
{ // {
FileUtils.copyDirectory(srcPath, targetPath); // FileUtils.copyDirectory(srcPath, targetPath);
new File(srcPath, FullTextIndexerRunnable.FULL_TEXT_INDEX_MARKER_FILENAME) // new File(srcPath, FullTextIndexerRunnable.FULL_TEXT_INDEX_MARKER_FILENAME)
.createNewFile(); // .createNewFile();
} catch (IOException ex) // } catch (IOException ex)
{ // {
throw new IOExceptionUnchecked(ex); // throw new IOExceptionUnchecked(ex);
} // }
} // }
@SuppressWarnings("unused") @SuppressWarnings("unused")
@DataProvider(name = "registratorTerm") @DataProvider(name = "registratorTerm")
...@@ -523,102 +508,102 @@ public final class HibernateSearchDAOTest extends AbstractDAOTest ...@@ -523,102 +508,102 @@ public final class HibernateSearchDAOTest extends AbstractDAOTest
// } // }
// TODO 2010-10-22, Piotr Buczek: write a different test (auto update is switched off) // TODO 2010-10-22, Piotr Buczek: write a different test (auto update is switched off)
@Test(groups = "broken") // @Test(groups = "broken")
/* // /*
* Checks if the dataset search index is properly updated after properties of a dataset have // * Checks if the dataset search index is properly updated after properties of a dataset have
* changed. // * changed.
*/ // */
public final void testSearchForDataSetsAfterPropertiesUpdate() throws InterruptedException // public final void testSearchForDataSetsAfterPropertiesUpdate() throws InterruptedException
{ // {
String propertyCode = "COMMENT"; // String propertyCode = "COMMENT";
DetailedSearchCriterion criterion1 = // DetailedSearchCriterion criterion1 =
mkCriterion(DetailedSearchField.createPropertyField(propertyCode), "no comment"); // mkCriterion(DetailedSearchField.createPropertyField(propertyCode), "no comment");
DetailedSearchCriterion criterion2 = createSimpleFieldCriterion(); // DetailedSearchCriterion criterion2 = createSimpleFieldCriterion();
//
DetailedSearchCriteria criteria = createAndDatasetQuery(criterion1, criterion2); // DetailedSearchCriteria criteria = createAndDatasetQuery(criterion1, criterion2);
//
assertCorrectDatasetsFound(criteria, DSLoc.LOC3, DSLoc.LOC4); // assertCorrectDatasetsFound(criteria, DSLoc.LOC3, DSLoc.LOC4);
//
// This data set has "no comment" value as a COMMENT property and TIFF file type. // // This data set has "no comment" value as a COMMENT property and TIFF file type.
// We change it and check if it is removed from results. // // We change it and check if it is removed from results.
ExternalDataPE externalData = findExternalData("20081105092159111-1"); // LOC3 // ExternalDataPE externalData = findExternalData("20081105092159111-1"); // LOC3
String newValue = "sth"; // String newValue = "sth";
changeExternalDataProperty(externalData, propertyCode, newValue); // changeExternalDataProperty(externalData, propertyCode, newValue);
flushSearchIndices(); // flushSearchIndices();
assertCorrectDatasetsFound(criteria, DSLoc.LOC4); // assertCorrectDatasetsFound(criteria, DSLoc.LOC4);
restoreSearchIndex(); // restoreSearchIndex();
} // }
//
private void flushSearchIndices() // private void flushSearchIndices()
{ // {
Session currentSession = sessionFactory.getCurrentSession(); // Session currentSession = sessionFactory.getCurrentSession();
FullTextSession fullTextSession = Search.getFullTextSession(currentSession); // FullTextSession fullTextSession = Search.getFullTextSession(currentSession);
fullTextSession.flushToIndexes(); // fullTextSession.flushToIndexes();
} // }
//
private void flushSession() // private void flushSession()
{ // {
sessionFactory.getCurrentSession().flush(); // sessionFactory.getCurrentSession().flush();
} // }
//
private void changeExternalDataProperty(ExternalDataPE externalData, String propertyCode, // private void changeExternalDataProperty(ExternalDataPE externalData, String propertyCode,
String newValue) // String newValue)
{ // {
EntityPropertyPE property = findProperty(externalData, propertyCode); // EntityPropertyPE property = findProperty(externalData, propertyCode);
//
removeProperty(externalData, property); // removeProperty(externalData, property);
flushSession(); // flushSession();
//
DataSetPropertyPE newProperty = new DataSetPropertyPE(); // DataSetPropertyPE newProperty = new DataSetPropertyPE();
copyPropertyWithNewValue(newValue, property, newProperty); // copyPropertyWithNewValue(newValue, property, newProperty);
addProperty(externalData, newProperty); // addProperty(externalData, newProperty);
flushSession(); // flushSession();
} // }
//
private void copyPropertyWithNewValue(String newValue, EntityPropertyPE oldProperty, // private void copyPropertyWithNewValue(String newValue, EntityPropertyPE oldProperty,
EntityPropertyPE newProperty) // EntityPropertyPE newProperty)
{ // {
newProperty.setEntityTypePropertyType(oldProperty.getEntityTypePropertyType()); // newProperty.setEntityTypePropertyType(oldProperty.getEntityTypePropertyType());
newProperty.setRegistrator(oldProperty.getRegistrator()); // newProperty.setRegistrator(oldProperty.getRegistrator());
newProperty.setValue(newValue); // newProperty.setValue(newValue);
} // }
//
private static <T extends EntityPropertyPE> void addProperty( // private static <T extends EntityPropertyPE> void addProperty(
IEntityPropertiesHolder propertiesHolder, T newProperty) // IEntityPropertiesHolder propertiesHolder, T newProperty)
{ // {
Set<EntityPropertyPE> properties = getCopiedProperties(propertiesHolder); // Set<EntityPropertyPE> properties = getCopiedProperties(propertiesHolder);
properties.add(newProperty); // properties.add(newProperty);
propertiesHolder.setProperties(properties); // propertiesHolder.setProperties(properties);
} // }
//
private static Set<EntityPropertyPE> removeProperty(IEntityPropertiesHolder propertiesHolder, // private static Set<EntityPropertyPE> removeProperty(IEntityPropertiesHolder propertiesHolder,
EntityPropertyPE property) // EntityPropertyPE property)
{ // {
Set<EntityPropertyPE> properties = getCopiedProperties(propertiesHolder); // Set<EntityPropertyPE> properties = getCopiedProperties(propertiesHolder);
boolean removed = properties.remove(property); // boolean removed = properties.remove(property);
assert removed : "property could not be removed"; // assert removed : "property could not be removed";
propertiesHolder.setProperties(properties); // propertiesHolder.setProperties(properties);
return properties; // return properties;
} // }
//
private static Set<EntityPropertyPE> getCopiedProperties( // private static Set<EntityPropertyPE> getCopiedProperties(
IEntityPropertiesHolder propertiesHolder) // IEntityPropertiesHolder propertiesHolder)
{ // {
return new HashSet<EntityPropertyPE>(propertiesHolder.getProperties()); // return new HashSet<EntityPropertyPE>(propertiesHolder.getProperties());
} // }
//
private static EntityPropertyPE findProperty(IEntityPropertiesHolder propertiesHolder, // private static EntityPropertyPE findProperty(IEntityPropertiesHolder propertiesHolder,
String propertyCode) // String propertyCode)
{ // {
for (EntityPropertyPE prop : propertiesHolder.getProperties()) // for (EntityPropertyPE prop : propertiesHolder.getProperties())
{ // {
if (prop.getEntityTypePropertyType().getPropertyType().getCode().equals(propertyCode)) // if (prop.getEntityTypePropertyType().getPropertyType().getCode().equals(propertyCode))
{ // {
return prop; // return prop;
} // }
} // }
fail("property not found: " + propertyCode); // fail("property not found: " + propertyCode);
return null; // never happens // return null; // never happens
} // }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment