/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

  1. package com.google.code.facebookapi;
  2. import static org.junit.Assert.assertTrue;
  3. import javax.xml.xpath.XPath;
  4. import javax.xml.xpath.XPathFactory;
  5. import org.junit.Test;
  6. import org.w3c.dom.Document;
  7. /**
  8. * For this test to work, the owner of the API KEY in use when running the JUnit test must have photos *of themself*.
  9. *
  10. * 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
  11. * fake user.
  12. */
  13. public class Issue41PhotosGetSubjectTest {
  14. @Test
  15. public void testGetPhotosBySubject() throws Exception {
  16. FacebookXmlRestClient client = FacebookSessionTestUtils.getValidClient( FacebookXmlRestClient.class );
  17. long apiUserId = client.users_getLoggedInUser();
  18. Document result = client.photos_get( apiUserId );
  19. XPathFactory factory = XPathFactory.newInstance();
  20. XPath xpath = factory.newXPath();
  21. xpath.setNamespaceContext( new FacebookNamespaceContext() );
  22. String numOfPhotos = xpath.evaluate( "count(//fbapi:photo)", result );
  23. 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 );
  24. }
  25. }