Java Code Examples for org.joda.time.DateTimeUtils#setCurrentMillisSystem()

The following examples show how to use org.joda.time.DateTimeUtils#setCurrentMillisSystem() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuestionRssEntryFactoryTest.java    From mamute with Apache License 2.0 6 votes vote down vote up
@Test
public void should_create_entry_from_a_question() throws IOException {
	DefaultEnvironment env = new DefaultEnvironment(new EnvironmentType("mamute"));
	QuestionRssEntryFactory factory = new QuestionRssEntryFactory(env);
	QuestionBuilder builder = new QuestionBuilder();
	DateTimeUtils.setCurrentMillisFixed(100);
	
	Question question = builder.withAuthor(user("author", "author@email"))
		.withTitle("question title")
		.withDescription("description")
		.withId(1l)
		.build();
	
	DateTimeUtils.setCurrentMillisSystem();
	
	ByteArrayOutputStream output = new ByteArrayOutputStream();
	factory.writeEntry(question, output);
	output.close();
	String xml = new String(output.toByteArray());
	assertTrue(xml.contains("<link>http://localhost:8080/1-question-title</link>"));
	assertTrue(xml.contains("<title><![CDATA[question title]]></title>"));
	assertTrue(xml.contains("<author><![CDATA[author]]></author>"));
}
 
Example 2
Source File: TestIslamicChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
protected void tearDown() throws Exception {
    DateTimeUtils.setCurrentMillisSystem();
    DateTimeZone.setDefault(originalDateTimeZone);
    TimeZone.setDefault(originalTimeZone);
    Locale.setDefault(originalLocale);
    originalDateTimeZone = null;
    originalTimeZone = null;
    originalLocale = null;
}
 
Example 3
Source File: TestPeriodFormatterBuilder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
protected void tearDown() throws Exception {
    DateTimeUtils.setCurrentMillisSystem();
    DateTimeZone.setDefault(originalDateTimeZone);
    TimeZone.setDefault(originalTimeZone);
    Locale.setDefault(originalLocale);
    originalDateTimeZone = null;
    originalTimeZone = null;
    originalLocale = null;
}
 
Example 4
Source File: TestEthiopicChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
protected void tearDown() throws Exception {
    DateTimeUtils.setCurrentMillisSystem();
    DateTimeZone.setDefault(originalDateTimeZone);
    TimeZone.setDefault(originalTimeZone);
    Locale.setDefault(originalLocale);
    originalDateTimeZone = null;
    originalTimeZone = null;
    originalLocale = null;
}
 
Example 5
Source File: TestIslamicChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
protected void tearDown() throws Exception {
    DateTimeUtils.setCurrentMillisSystem();
    DateTimeZone.setDefault(originalDateTimeZone);
    TimeZone.setDefault(originalTimeZone);
    Locale.setDefault(originalLocale);
    originalDateTimeZone = null;
    originalTimeZone = null;
    originalLocale = null;
}
 
Example 6
Source File: TestGJChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
protected void tearDown() throws Exception {
    DateTimeUtils.setCurrentMillisSystem();
    DateTimeZone.setDefault(originalDateTimeZone);
    TimeZone.setDefault(originalTimeZone);
    Locale.setDefault(originalLocale);
    originalDateTimeZone = null;
    originalTimeZone = null;
    originalLocale = null;
}
 
Example 7
Source File: TestPeriodFormatterBuilder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
protected void tearDown() throws Exception {
    DateTimeUtils.setCurrentMillisSystem();
    DateTimeZone.setDefault(originalDateTimeZone);
    TimeZone.setDefault(originalTimeZone);
    Locale.setDefault(originalLocale);
    originalDateTimeZone = null;
    originalTimeZone = null;
    originalLocale = null;
}
 
Example 8
Source File: TestEthiopicChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
protected void tearDown() throws Exception {
    DateTimeUtils.setCurrentMillisSystem();
    DateTimeZone.setDefault(originalDateTimeZone);
    TimeZone.setDefault(originalTimeZone);
    Locale.setDefault(originalLocale);
    originalDateTimeZone = null;
    originalTimeZone = null;
    originalLocale = null;
}
 
Example 9
Source File: TestBuddhistChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
protected void tearDown() throws Exception {
    DateTimeUtils.setCurrentMillisSystem();
    DateTimeZone.setDefault(originalDateTimeZone);
    TimeZone.setDefault(originalTimeZone);
    Locale.setDefault(originalLocale);
    originalDateTimeZone = null;
    originalTimeZone = null;
    originalLocale = null;
}
 
Example 10
Source File: TestDateTimeFormatStyle.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
protected void tearDown() throws Exception {
    DateTimeUtils.setCurrentMillisSystem();
    DateTimeZone.setDefault(originalDateTimeZone);
    TimeZone.setDefault(originalTimeZone);
    Locale.setDefault(originalLocale);
    originalDateTimeZone = null;
    originalTimeZone = null;
    originalLocale = null;
}
 
Example 11
Source File: RssFeedFactoryTest.java    From mamute with Apache License 2.0 5 votes vote down vote up
@Test
public void should_generate_feed() throws IOException {
	DefaultEnvironment env = new DefaultEnvironment(new EnvironmentType("mamute"));
	QuestionRssEntryFactory factory = new QuestionRssEntryFactory(env);
	RssFeedFactory rssFeedFactory = new RssFeedFactory(env, factory);
	
	QuestionBuilder builder = new QuestionBuilder();
	
	DateTimeUtils.setCurrentMillisFixed(100);
	User user1 = user("author1", "author@email");
	user1.setPhotoUri(new URL("http://imagemsuser1.com"));
	Question question1 = builder.withAuthor(user1)
		.withTitle("first question")
		.withDescription("question")
		.withId(1l)
		.build();
	
	User user2 = user("author2", "author@email");
	user2.setPhotoUri(new URL("http://imagemsuser2.com"));
	Question question2 = builder.withId(2l)
		.withTitle("second question")
		.withAuthor(user2)
		.build();
	
	ByteArrayOutputStream output = new ByteArrayOutputStream();
	rssFeedFactory.build(Arrays.<RssContent>asList(question1, question2), output, "title", "description");
	output.close();
	String xml = new String(output.toByteArray());
	assertTrue(xml.contains("first question"));
	assertTrue(xml.contains("second question"));
	assertTrue(xml.contains("http://imagemsuser1.com"));
	assertTrue(xml.contains("http://imagemsuser2.com"));
	DateTimeUtils.setCurrentMillisSystem();
}
 
Example 12
Source File: ApplicationLifecycleControllerTest.java    From Cheddar with Apache License 2.0 4 votes vote down vote up
@After
public void tearDown() {
    DateTimeUtils.setCurrentMillisSystem();
}
 
Example 13
Source File: LookbackPartitionFilterGeneratorTest.java    From incubator-gobblin with Apache License 2.0 4 votes vote down vote up
@AfterMethod
public void tearDown()
    throws Exception {
  DateTimeUtils.setCurrentMillisSystem();
}
 
Example 14
Source File: StageTest.java    From gocd with Apache License 2.0 4 votes vote down vote up
private void resetTime() {
    DateTimeUtils.setCurrentMillisSystem();
}
 
Example 15
Source File: JobResultsServiceImplITest.java    From batchers with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setUp() {
    DateTimeUtils.setCurrentMillisSystem();
}
 
Example 16
Source File: RedshiftJdbcClientTest.java    From pocket-etl with Apache License 2.0 4 votes vote down vote up
@After
public void unfreezeTime() {
    DateTimeUtils.setCurrentMillisSystem();
}
 
Example 17
Source File: WithUserPaginatedDAOTest.java    From mamute with Apache License 2.0 4 votes vote down vote up
@After
public void tearDown() {
	DateTimeUtils.setCurrentMillisSystem();
}
 
Example 18
Source File: TestCase.java    From mamute with Apache License 2.0 4 votes vote down vote up
@Before
public void fixTime() {
	DateTimeUtils.setCurrentMillisSystem();
}
 
Example 19
Source File: ResetDateTimeProvider.java    From beam with Apache License 2.0 4 votes vote down vote up
@Override
protected void after() {
  DateTimeUtils.setCurrentMillisSystem();
}
 
Example 20
Source File: NormalizerTest.java    From api-compiler with Apache License 2.0 4 votes vote down vote up
@After
public void after() {
  // Reset the current time to return the system time.
  DateTimeUtils.setCurrentMillisSystem();
}