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

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

Introduction

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

Prototype

public static void clearHttpResponseRules() 

Source Link

Usage

From source file:com.jaspersoft.android.jaspermobile.test.acceptance.library.LibraryPageRefreshingTest.java

@Override
protected void setUp() throws Exception {
    super.setUp();
    registerTestModule(new HackedTestModule());
    setDefaultCurrentProfile();/*  www. j a va 2 s . co  m*/
    FakeHttpLayerManager.clearHttpResponseRules();
}

From source file:com.jaspersoft.android.jaspermobile.test.acceptance.library.LibraryPageFilterTest.java

@Override
protected void setUp() throws Exception {
    super.setUp();
    registerTestModule(new HackedTestModule());
    setDefaultCurrentProfile();/*www.  j a v  a 2 s .  c o m*/

    FakeHttpLayerManager.clearHttpResponseRules();
}

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

@Override
protected void setUp() throws Exception {
    super.setUp();
    registerTestModule(new HackedTestModule());
    setDefaultCurrentProfile();/*from w  w w.  j  a  v a  2  s.c  o  m*/
    configureSearchIntent();
    FakeHttpLayerManager.clearHttpResponseRules();
}

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

@Override
protected void setUp() throws Exception {
    super.setUp();
    registerTestModule(new HackedTestModule());
    setDefaultCurrentProfile();//from   w w w  .j a  v  a  2s  .co  m
    idleInjector = WebViewInjector.registerFor(DashboardHtmlViewerActivity_.class);

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

    FakeHttpLayerManager.clearHttpResponseRules();
}

From source file:com.jaspersoft.android.jaspermobile.test.acceptance.library.LibraryPageSortTest.java

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

    registerTestModule(new TestModule());
    setDefaultCurrentProfile();/*  w w  w .ja  va 2  s.  c om*/

    // We don`t need to listen initial load of page
    FakeHttpLayerManager.clearHttpResponseRules();
    FakeHttpLayerManager.addHttpResponseRule(ApiMatcher.RESOURCES, TestResponses.ALL_RESOURCES);
}

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

@Override
protected void setUp() throws Exception {
    super.setUp();
    mApplication = (Application) this.getInstrumentation().getTargetContext().getApplicationContext();
    registerTestModule(new HackedTestModule());
    setDefaultCurrentProfile();/* ww  w .  j  av  a  2s . c o m*/

    favoritesHelper = FavoritesHelper_.getInstance_(mApplication);
    deleteAllFavorites(mApplication.getContentResolver());
    FakeHttpLayerManager.clearHttpResponseRules();
}

From source file:com.jaspersoft.android.jaspermobile.test.acceptance.home.HomePageTest.java

public void testOverAllNavigationForDashboard() {
    startActivityUnderTest();/* w w w.  j a v a  2  s .c  o  m*/

    // Check ActionBar server name
    onView(withId(R.id.profile_name)).check(matches(withText("Mobile Demo")));

    FakeHttpLayerManager.addHttpResponseRule(ApiMatcher.RESOURCES, TestResponses.ONLY_FOLDER);
    onView(withId(R.id.home_item_library)).perform(click());
    Espresso.pressBack();

    FakeHttpLayerManager.clearHttpResponseRules();
    FakeHttpLayerManager.addHttpResponseRule(ApiMatcher.GET_ROOT_FOLDER, TestResponses.ROOT_FOLDER);
    onView(withId(R.id.home_item_repository)).perform(click());
    Espresso.pressBack();

    onView(withId(R.id.home_item_favorites)).perform(click());
    Espresso.pressBack();
    onView(withId(R.id.home_item_saved_reports)).perform(click());
    Espresso.pressBack();
    onView(withId(R.id.home_item_settings)).perform(click());
    Espresso.pressBack();
    onView(withId(R.id.home_item_servers)).perform(click());
}

From source file:com.jaspersoft.android.jaspermobile.test.acceptance.library.LibraryPageTest.java

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

    smallLookUp = TestResources.get().fromXML(ResourceLookupsList.class, "library_reports_small");
    dashboardResource = smallLookUp.getResourceLookups().get(DASHBOARD_ITEM_POSITION);

    registerTestModule(new HackedTestModule());
    setDefaultCurrentProfile();// ww  w.j a v  a2  s.  c  o  m

    FakeHttpLayerManager.clearHttpResponseRules();
    FakeHttpLayerManager.addHttpResponseRule(ApiMatcher.RESOURCES, TestResponses.SMALL_LOOKUP);
}

From source file:com.jaspersoft.android.jaspermobile.test.acceptance.profile.ServersManagerPageTest.java

public void testPageShouldProperlyHandleUnAuthorized() {
    registerTestModule(new CommonTestModule() {
        @Override/*from ww w  .j  a v a  2  s  .  c o m*/
        protected void semanticConfigure() {
            bind(JsSpiceManager.class).toInstance(new JsSpiceManager() {
                @Override
                public <T> void execute(CachedSpiceRequest<T> cachedSpiceRequest,
                        final RequestListener<T> requestListener) {
                    HttpClientErrorException httpClientErrorException = new HttpClientErrorException(
                            HttpStatus.UNAUTHORIZED);
                    requestListener.onRequestFailure(new NetworkException(
                            "Exception occurred during invocation of web service.", httpClientErrorException));
                }
            });
        }
    });
    startActivityUnderTest();

    onView(withId(R.id.addProfile)).perform(click());

    onView(withId(R.id.aliasEdit)).perform(typeText(TEST_ALIAS));
    onView(withId(R.id.serverUrlEdit)).perform(typeText(TEST_SERVER_URL));
    onView(withId(R.id.organizationEdit)).perform(typeText("some invalid organization"));
    onView(withId(R.id.usernameEdit)).perform(typeText("some invalid username"));
    onView(withId(R.id.passwordEdit)).perform(typeText("some invalid password"));
    onView(withId(R.id.saveAction)).perform(click());

    FakeHttpLayerManager.clearHttpResponseRules();
    FakeHttpLayerManager.addHttpResponseRule(ApiMatcher.SERVER_INFO, TestResponses.get().notAuthorized());
    onView(withText(TEST_ALIAS)).perform(click());

    onOverflowView(getActivity(), withId(R.id.sdl__title)).check(matches(withText(R.string.error_msg)));
    onOverflowView(getActivity(), withId(R.id.sdl__message))
            .check(matches(withText(ExceptionRule.UNAUTHORIZED.getMessage())));
    onOverflowView(getActivity(), withId(R.id.sdl__negative_button)).perform(click());
}

From source file:com.jaspersoft.android.jaspermobile.test.acceptance.profile.ServersManagerPageTest.java

public void testServerLowerThanEmeraldNotAcceptable() {
    registerTestModule(new CommonTestModule() {
        @Override//www.j  av a 2 s  .c o m
        protected void semanticConfigure() {
            bind(JsSpiceManager.class).toInstance(new JsSpiceManager() {
                @Override
                public <T> void execute(CachedSpiceRequest<T> cachedSpiceRequest,
                        final RequestListener<T> requestListener) {
                    ServerInfo serverInfo = TestResources.get().fromXML(ServerInfo.class,
                            TestResources.EMERALD_MR1_SERVER_INFO);
                    requestListener.onRequestSuccess((T) serverInfo);
                }
            });
        }
    });
    startActivityUnderTest();
    onView(withId(R.id.addProfile)).perform(click());

    onView(withId(R.id.aliasEdit)).perform(typeText(DatabaseUtils.TEST_ALIAS));
    onView(withId(R.id.serverUrlEdit)).perform(typeText(DatabaseUtils.TEST_SERVER_URL));
    onView(withId(R.id.organizationEdit)).perform(typeText(DatabaseUtils.TEST_ORGANIZATION));
    onView(withId(R.id.usernameEdit)).perform(typeText(DatabaseUtils.TEST_USERNAME));
    onView(withId(R.id.passwordEdit)).perform(typeText(DatabaseUtils.TEST_PASS));
    onView(withId(R.id.saveAction)).perform(click());

    FakeHttpLayerManager.clearHttpResponseRules();
    FakeHttpLayerManager.addHttpResponseRule(ApiMatcher.SERVER_INFO, TestResponses.EMERALD_MR1_SERVER_INFO);
    onView(withText(TEST_ALIAS)).perform(click());

    onOverflowView(getActivity(), withId(R.id.sdl__title)).check(matches(withText(R.string.error_msg)));
    onOverflowView(getActivity(), withId(R.id.sdl__message))
            .check(matches(withText(R.string.r_error_server_not_supported)));
}