Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7821281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:35:31+00:00 2026-06-02T07:35:31+00:00

To test our API that connects to the facebook graph API we use a

  • 0

To test our API that connects to the facebook graph API we use a mock server setup based on Jersey Test Framework and grizzly:

@Path("/" + PostRest.RESOURCE)
@Produces("application/json")
public class PostRest {

    public static final String RESOURCE = "111_222";

    @GET
    public Response getPost(@QueryParam("access_token") String access_token) {
        if (access_token != VALID_TOKEN) {
            return Response.status(400).entity(createErrorJson()).build();
        }
        return Response.status(200).entity(createSomeJsonString()).build();
    }

Now while I can react to an invalid or missing access_token with the correct error response, I also want to test that my API reacts correctly when trying to access an unkown resource at facebook ie an unkown path.

Right now I get a 404 from my grizzly obviously, if I try to access say “/111_2”, but facebook seems to catch that error and wrap it inside a Json response, containing the string “false” with status 200.

So… How do I set up the Test Framework to return

Response.status(200).entity("false").build();

every time it is called for an known path?

Basic example:

@ContextConfiguration({ "classpath:context-test.xml" })
@RunWith(SpringJUnit4ClassRunner.class)
public class SomeTest extends JerseyTest {

    @Inject
    private SomeConnection connection;

    private String unkownId = "something";


    public SomeTest() throws Exception {
        super("jsonp", "", "com.packagename.something");
    }


    @Test(expected = NotFoundException.class)
    public void testUnkownObjectResponse() throws NotFoundException {
        // here it should NOT result in a 404 but a JSON wrapped error response 
        // which will be handled by the Connection class and 
        // result in a custom exception 
        connection.getObject(unkownId);
    }

Or maybe I can set up grizzly to behave as desired..?!

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:35:33+00:00Added an answer on June 2, 2026 at 7:35 am

    Obviously facebook has it own service to intercept errors. Same thing should be done in your code. Just expose you own test service that intercepts all request

    @Path("/test/errorTrap")
    public class ErrorTrapService{
     ....
    }
    

    This service will produce any response you want. So any un-existing pages like http://mytest/test/errorTrap/111_2 will be intercepted by test service and produce expected response for you

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We use SoapUI to mock web services to test our application (APP) before we
I am trying to test our source tree using PHPUnit with old, web based
I am writing a diagnostic site to test our server methods. One of the
For our test fixtures we use NHibernate to generate a database schema. We have
Our vendor needs some access to our test server, and thus we send them
In a load test of our PHP based web application we can easily reach
We are using Visual Studio 2010 and before each release to our test server
I'm currently working on some .Net based software (.Net Framework 3.5 SP1) that integrates
I have create a site embedded Google mapusing api V3 that shows our 4
I have a PHP script that connects to an api and posts information to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.