use of com.google.code.tempusfugit.concurrency.annotations.Concurrent in project hive by apache.
the class TestDateWritableV2 method testConstructor.
@Test
@Concurrent(count = 4)
@Repeating(repetition = 100)
public void testConstructor() {
Date date = Date.valueOf(getRandomDateString());
DateWritableV2 dw1 = new DateWritableV2(date);
DateWritableV2 dw2 = new DateWritableV2(dw1);
DateWritableV2 dw3 = new DateWritableV2(dw1.getDays());
assertEquals(dw1, dw1);
assertEquals(dw1, dw2);
assertEquals(dw2, dw3);
assertEquals(date, dw1.get());
assertEquals(date, dw2.get());
assertEquals(date, dw3.get());
}
use of com.google.code.tempusfugit.concurrency.annotations.Concurrent in project hive by apache.
the class TestDateWritableV2 method testComparison.
@Test
@Concurrent(count = 4)
@Repeating(repetition = 100)
public void testComparison() {
// Get 2 different dates
Date date1 = Date.valueOf(getRandomDateString());
Date date2 = Date.valueOf(getRandomDateString());
while (date1.equals(date2)) {
date2 = Date.valueOf(getRandomDateString());
}
DateWritableV2 dw1 = new DateWritableV2(date1);
DateWritableV2 dw2 = new DateWritableV2(date2);
DateWritableV2 dw3 = new DateWritableV2(date1);
assertTrue("Dates should be equal", dw1.equals(dw1));
assertTrue("Dates should be equal", dw1.equals(dw3));
assertTrue("Dates should be equal", dw3.equals(dw1));
assertEquals("Dates should be equal", 0, dw1.compareTo(dw1));
assertEquals("Dates should be equal", 0, dw1.compareTo(dw3));
assertEquals("Dates should be equal", 0, dw3.compareTo(dw1));
assertFalse("Dates not should be equal", dw1.equals(dw2));
assertFalse("Dates not should be equal", dw2.equals(dw1));
assertTrue("Dates not should be equal", 0 != dw1.compareTo(dw2));
assertTrue("Dates not should be equal", 0 != dw2.compareTo(dw1));
}
use of com.google.code.tempusfugit.concurrency.annotations.Concurrent in project hive by apache.
the class TestDateWritableV2 method testWritableMethods.
@Test
@Concurrent(count = 4)
@Repeating(repetition = 100)
public void testWritableMethods() throws Throwable {
DateWritableV2 dw1 = new DateWritableV2(Date.valueOf(getRandomDateString()));
DateWritableV2 dw2 = new DateWritableV2();
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
DataOutput out = new DataOutputStream(byteStream);
dw1.write(out);
dw2.readFields(new DataInputStream(new ByteArrayInputStream(byteStream.toByteArray())));
assertEquals("Dates should be equal", dw1, dw2);
}
use of com.google.code.tempusfugit.concurrency.annotations.Concurrent in project hive by apache.
the class TestDateWritableV2 method testDateValueOf.
@Test
@Concurrent(count = 4)
@Repeating(repetition = 100)
public void testDateValueOf() {
// Just making sure Date.valueOf() works ok
String dateStr = getRandomDateString();
Date date = Date.valueOf(dateStr);
assertEquals(dateStr, date.toString());
}
use of com.google.code.tempusfugit.concurrency.annotations.Concurrent in project hive by apache.
the class TestDateWritableV2 method testGettersSetters.
@Test
@Concurrent(count = 4)
@Repeating(repetition = 100)
public void testGettersSetters() {
Date date1 = Date.valueOf(getRandomDateString());
Date date2 = Date.valueOf(getRandomDateString());
Date date3 = Date.valueOf(getRandomDateString());
DateWritableV2 dw1 = new DateWritableV2(date1);
DateWritableV2 dw2 = new DateWritableV2(date2);
DateWritableV2 dw3 = new DateWritableV2(date3);
DateWritableV2 dw4 = new DateWritableV2();
// Getters
assertEquals(date1, dw1.get());
assertEquals(date1.toEpochSecond(), dw1.getTimeInSeconds());
dw4.set(Date.valueOf("1970-01-02"));
assertEquals(1, dw4.getDays());
dw4.set(Date.valueOf("1971-01-01"));
assertEquals(365, dw4.getDays());
// Setters
dw4.set(dw1.getDays());
assertEquals(dw1, dw4);
dw4.set(dw2.get());
assertEquals(dw2, dw4);
dw4.set(dw3);
assertEquals(dw3, dw4);
}
Aggregations