Example usage for org.apache.http.fake FakeHttpLayerManager setDefaultHttpResponse

List of usage examples for org.apache.http.fake FakeHttpLayerManager setDefaultHttpResponse

Introduction

In this page you can find the example usage for org.apache.http.fake FakeHttpLayerManager setDefaultHttpResponse.

Prototype

public static void setDefaultHttpResponse(HttpResponse defaultHttpResponse) 

Source Link

Usage

From source file:com.jaspersoft.android.jaspermobile.test.acceptance.viewer.ReportViewPageTest.java

@Override
public void setUp() throws Exception {
    super.setUp();

    Application application = (Application) this.getInstrumentation().getTargetContext()
            .getApplicationContext();//  w w  w . j  a v  a2  s .co  m
    registerTestModule(new HackedTestModule());
    setDefaultCurrentProfile();

    favoritesHelper = FavoritesHelper_.getInstance_(application);

    ResourceLookupsList resourceLookupsList = TestResources.get().fromXML(ResourceLookupsList.class,
            "only_report");
    mResource = resourceLookupsList.getResourceLookups().get(0);
    mResource.setLabel(RESOURCE_LABEL);
    mResource.setUri(RESOURCE_URI);

    FakeHttpLayerManager.setDefaultHttpResponse(TestResponses.get().noContent());
}

From source file:com.jaspersoft.android.jaspermobile.test.acceptance.favorites.FavoritesPageTest.java

public void testAddToFavoriteFromReportView() {
    FakeHttpLayerManager.addHttpResponseRule(ApiMatcher.RESOURCES, TestResponses.ONLY_REPORT);
    startActivityUnderTest();//from   www  . ja  va  2 s.com

    // Force only reports
    Intent intent = LibraryActivity_.intent(mApplication).flags(Intent.FLAG_ACTIVITY_NEW_TASK).get();
    getInstrumentation().startActivitySync(intent);
    getInstrumentation().waitForIdleSync();

    // Select report
    FakeHttpLayerManager.setDefaultHttpResponse(TestResponses.get().noContent());
    onData(is(instanceOf(ResourceLookup.class))).inAdapterView(withId(android.R.id.list)).atPosition(0)
            .perform(click());

    // Add to favorite
    onView(withId(R.id.favoriteAction)).perform(click());
    pressBack();
    pressBack();

    onData(is(instanceOf(Cursor.class))).inAdapterView(withId(android.R.id.list)).atPosition(0)
            .perform(click());

    // Remove from favorite
    onView(withId(R.id.favoriteAction)).perform(click());
    pressBack();

    onView(withId(android.R.id.list)).check(hasTotalCount(0));
    onView(withId(android.R.id.empty))
            .check(matches(allOf(withText(R.string.f_empty_list_msg), isDisplayed())));
}