PageRenderTime 20ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/facebook-java-api/src/test/java/com/google/code/facebookapi/Issue41PhotosGetSubjectTest.java

http://facebook-java-api.googlecode.com/
Java | 36 lines | 19 code | 11 blank | 6 comment | 0 complexity | 3153cd237d76d591b658e44b2a8b1c1f MD5 | raw file
 1package com.google.code.facebookapi;
 2
 3import static org.junit.Assert.assertTrue;
 4
 5import javax.xml.xpath.XPath;
 6import javax.xml.xpath.XPathFactory;
 7
 8import org.junit.Test;
 9import org.w3c.dom.Document;
10
11/**
12 * For this test to work, the owner of the API KEY in use when running the JUnit test must have photos *of themself*.
13 * 
14 * If you're running the test as yourself, that's probably the case anyway. If you're running it as a batch test user, ensure that at least one photo is posted for that
15 * fake user.
16 */
17public class Issue41PhotosGetSubjectTest {
18
19	@Test
20	public void testGetPhotosBySubject() throws Exception {
21		FacebookXmlRestClient client = FacebookSessionTestUtils.getValidClient( FacebookXmlRestClient.class );
22
23		long apiUserId = client.users_getLoggedInUser();
24
25		Document result = client.photos_get( apiUserId );
26
27		XPathFactory factory = XPathFactory.newInstance();
28		XPath xpath = factory.newXPath();
29		xpath.setNamespaceContext( new FacebookNamespaceContext() );
30
31		String numOfPhotos = xpath.evaluate( "count(//fbapi:photo)", result );
32
33		assertTrue( "No photos tagged with user found. (For this test to pass test user must have at least one tagged photo)", Integer.parseInt( numOfPhotos ) > 0 );
34	}
35
36}