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

minor: fix tests to run on JVM 1.5 and 1.6

SVN: 21153
parent 4c3f6daf
No related branches found
No related tags found
No related merge requests found
/*
* Copyright 2011 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.common.utilities;
import java.util.Comparator;
/**
* A comparator based on the string representation of the objects.
*
* @author Kaloyan Enimanev
*/
public class ToStringComparator implements Comparator<Object>
{
public int compare(Object o1, Object o2)
{
String o1String = o1.toString();
String o2String = o2.toString();
return o1String.compareTo(o2String);
}
}
......@@ -20,7 +20,10 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
......@@ -364,9 +367,19 @@ public class DatabaseInstanceImporterTest extends AbstractFileSystemTestCase
fail("UserFailureException expected");
} catch (UserFailureException ex)
{
assertEquals(
"Current database does not have tables [DATABASE_INSTANCES, PROPERTY_TYPES, PROPERTY_VALUES]\n"
+ " which exist in the database to be imported.", ex.getMessage());
String errMessagePattern =
"Current database does not have tables \\[(.*)]\n"
+ " which exist in the database to be imported.";
Pattern pattern = Pattern.compile(errMessagePattern);
Matcher matcher = pattern.matcher(ex.getMessage());
assertTrue(matcher.matches());
String[] tableNames = matcher.group(1).split(", ");
List<String> tableNamesList = Arrays.asList(tableNames);
Collections.sort(tableNamesList);
assertEquals("[DATABASE_INSTANCES, PROPERTY_TYPES, PROPERTY_VALUES]",
tableNamesList.toString());
}
context.assertIsSatisfied();
......
......@@ -21,15 +21,19 @@ import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.fail;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.testng.annotations.Test;
import ch.systemsx.cisd.common.utilities.ToStringComparator;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.SampleBrowserTest;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.GridRowModels;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ListSampleDisplayCriteria;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ResultSetWithEntityTypes;
import ch.systemsx.cisd.openbis.generic.shared.basic.GridRowModel;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.BasicEntityType;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListSampleCriteria;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample;
......@@ -68,8 +72,12 @@ public class SampleBrowsingTest extends GenericSystemTestCase
ResultSetWithEntityTypes<Sample> samples =
commonClientService.listSamples(new ListSampleDisplayCriteria(listCriteria));
assertEquals(41, samples.getResultSet().getTotalLength());
assertEquals("[REINFECT_PLATE, MASTER_PLATE, DILUTION_PLATE, CELL_PLATE, CONTROL_LAYOUT]",
samples.getAvailableEntityTypes().toString());
List<BasicEntityType> availableEntityTypes = new ArrayList<BasicEntityType>();
availableEntityTypes.addAll(samples.getAvailableEntityTypes());
Collections.sort(availableEntityTypes, new ToStringComparator());
assertEquals("[CELL_PLATE, CONTROL_LAYOUT, DILUTION_PLATE, MASTER_PLATE, REINFECT_PLATE]",
availableEntityTypes.toString());
GridRowModels<Sample> list = samples.getResultSet().getList();
......
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