Adding parameters to DateTimeWithPrecisionTest so that it tests all the timezones NIHVIVO-2197

This commit is contained in:
bdc34 2011-03-04 16:55:20 +00:00
parent 558ed44132
commit 4db82c0585

View file

@ -2,13 +2,21 @@
package edu.cornell.mannlib.vitro.webapp.edit.elements; package edu.cornell.mannlib.vitro.webapp.edit.elements;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.TimeZone;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
import com.hp.hpl.jena.datatypes.xsd.XSDDateTime; import com.hp.hpl.jena.datatypes.xsd.XSDDateTime;
@ -20,8 +28,41 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditSubmission;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.Field; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.Field;
@RunWith(value= Parameterized.class)
public class DateTimeWithPrecisionTest { public class DateTimeWithPrecisionTest {
TimeZone orginalTimeZone;
TimeZone testZone;
public DateTimeWithPrecisionTest(TimeZone tz){
orginalTimeZone = TimeZone.getDefault();
testZone = tz;
}
@Parameters
public static Collection<Object[]> data(){
String allZones[] = TimeZone.getAvailableIDs();
ArrayList<Object[]> data = new ArrayList<Object[]>( allZones.length );
for( String zoneId : allZones ){
Object v[] = new Object[1];
v[0] = TimeZone.getTimeZone(zoneId);
data.add(v);
}
return data;
}
@Before
public void beforeTest(){
TimeZone.setDefault( testZone );
}
@After
public void after(){
if( orginalTimeZone != null){
TimeZone.setDefault(orginalTimeZone);
}
}
@Test @Test
public void fieldNameTemplateVariableTest() throws Exception{ public void fieldNameTemplateVariableTest() throws Exception{
String FIELDNAME = "testfield"; String FIELDNAME = "testfield";
@ -333,4 +374,5 @@ public class DateTimeWithPrecisionTest {
Assert.assertNotNull(precisionURI); Assert.assertNotNull(precisionURI);
Assert.assertEquals(VitroVocabulary.Precision.DAY.uri(), precisionURI); Assert.assertEquals(VitroVocabulary.Precision.DAY.uri(), precisionURI);
} }
} }