org.jivesoftware.smackx.packet.LastActivity Java Examples

The following examples show how to use org.jivesoftware.smackx.packet.LastActivity. 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: LastActivityManagerTest.java    From Smack with Apache License 2.0 6 votes vote down vote up
/**
 * This is a test to check if a LastActivity request for last logged out
 * lapsed time is answered and correct
 */
public void testLastLoggedOut() {
	TCPConnection conn0 = getConnection(0);

	LastActivity lastActivity = null;
	try {
		lastActivity = LastActivityManager.getLastActivity(conn0, getBareJID(1));
	} catch (XMPPException e) {
		e.printStackTrace();
		fail("An error occurred requesting the Last Activity");
	}

	assertNotNull("No last activity packet", lastActivity);
       assertTrue("The last activity idle time should be 0 since the user is logged in: " +
               lastActivity.getIdleTime(), lastActivity.getIdleTime() == 0);
   }
 
Example #2
Source File: LastActivityManagerTest.java    From Smack with Apache License 2.0 6 votes vote down vote up
/**
 * This is a test to check if a LastActivity request for server uptime
 * is answered and correct
 */
public void testServerUptime() {
	TCPConnection conn0 = getConnection(0);

	LastActivity lastActivity = null;
	try {
		lastActivity = LastActivityManager.getLastActivity(conn0, getHost());
	} catch (XMPPException e) {
		if (e.getStanzaError().getCode() == 403) {
			//The test can not be done since the host do not allow this kind of request
			return;
		}
		e.printStackTrace();
		fail("An error occurred requesting the Last Activity");
	}

	assertNotNull("No last activity packet", lastActivity);
       assertTrue("The last activity idle time should be greater than 0 : " +
               lastActivity.getIdleTime(), lastActivity.getIdleTime() > 0);
   }