Search in sources :

Example 1 with ServletRedirectResult

use of jodd.madvoc.result.ServletRedirectResult in project jodd by oblac.

the class ResultsManagerTest method testDuplicateResults2.

@Test
public void testDuplicateResults2() {
    ResultsManager resultsManager = new ResultsManager() {

        @Override
        protected void initializeResult(ActionResult result) {
        }

        @Override
        protected boolean resultMayReplaceExistingOne(Class<? extends ActionResult> actionResultClass) {
            if (actionResultClass.getName().contains("Test")) {
                return true;
            }
            return super.resultMayReplaceExistingOne(actionResultClass);
        }
    };
    // register
    resultsManager.register(new MyRedirect1());
    // ignore
    resultsManager.register(new MyRedirect1());
    // ignore
    resultsManager.register(new ServletRedirectResult());
    assertNull(resultsManager.allResults.get(ServletRedirectResult.class));
    assertEquals(MyRedirect1.class, resultsManager.stringResults.get("redirect").getClass());
    // ignore
    resultsManager.register(new MyRedirect2());
    assertEquals(MyRedirect2.class, resultsManager.stringResults.get("redirect").getClass());
    assertEquals(1, resultsManager.allResults.size());
}
Also used : ServletRedirectResult(jodd.madvoc.result.ServletRedirectResult) ActionResult(jodd.madvoc.result.ActionResult) Test(org.junit.Test)

Example 2 with ServletRedirectResult

use of jodd.madvoc.result.ServletRedirectResult in project jodd by oblac.

the class ResultsManagerTest method testDuplicateResults1.

@Test
public void testDuplicateResults1() {
    ResultsManager resultsManager = new ResultsManager() {

        @Override
        protected void initializeResult(ActionResult result) {
        }

        @Override
        protected boolean resultMayReplaceExistingOne(Class<? extends ActionResult> actionResultClass) {
            if (actionResultClass.getName().contains("Test")) {
                return true;
            }
            return super.resultMayReplaceExistingOne(actionResultClass);
        }
    };
    // new
    resultsManager.register(new ServletRedirectResult());
    // ignore
    resultsManager.register(new ServletRedirectResult());
    // replace
    resultsManager.register(new MyRedirect1());
    assertNull(resultsManager.allResults.get(ServletRedirectResult.class));
    assertEquals(MyRedirect1.class, resultsManager.stringResults.get("redirect").getClass());
    // replace
    resultsManager.register(new MyRedirect2());
    assertEquals(MyRedirect2.class, resultsManager.stringResults.get("redirect").getClass());
    assertEquals(1, resultsManager.allResults.size());
}
Also used : ServletRedirectResult(jodd.madvoc.result.ServletRedirectResult) ActionResult(jodd.madvoc.result.ActionResult) Test(org.junit.Test)

Aggregations

ActionResult (jodd.madvoc.result.ActionResult)2 ServletRedirectResult (jodd.madvoc.result.ServletRedirectResult)2 Test (org.junit.Test)2