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());
}
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());
}
Aggregations