// Path: android/Commons/src/triaina/commons/exception/SecurityRuntimeException.java
// public class SecurityRuntimeException extends CommonRuntimeException {
// 
// 	private static final long serialVersionUID = 6244026068714272574L;
// 
// 	private String mUrl;
// 
// 	public SecurityRuntimeException() {
// 		super();
// 	}
// 
// 	public SecurityRuntimeException(String detailMessage, Throwable throwable) {
// 		super(detailMessage, throwable);
// 	}
// 
// 	public SecurityRuntimeException(String detailMessage) {
// 		super(detailMessage);
// 	}
// 
// 	public SecurityRuntimeException(String detailMessage, String url) {
// 		this(detailMessage);
// 		mUrl = url;
// 	}
// 
// 	public SecurityRuntimeException(Throwable throwable) {
// 		super(throwable);
// 	}
// 
// 	public SecurityRuntimeException(Throwable throwable, String url) {
// 		this(throwable);
// 		mUrl = url;
// 	}
// 
// 	public String getUrl(){
// 		return mUrl;
// 	}
// }
// 
// Path: android/WebViewBridge/src/triaina/webview/WebViewBridge.java
// public static interface SecurityRuntimeExceptionResolver {
//     public void resolve(SecurityRuntimeException e);
// }
// 
// Path: android/WebViewBridge/src/triaina/webview/WebViewBridge.java
// public static class WebViewClientProxy extends WebViewClient {
//     private WebViewClient mWebViewClient;
//     private DomainConfig mDomainConfig;
//     private SecurityRuntimeExceptionResolver mSecurityRuntimeExceptionResolver;
// 
//     public WebViewClientProxy(WebViewClient webViewClient, DomainConfig domainConfig) {
//         this(webViewClient, domainConfig, null);
//     }
// 
//     public WebViewClientProxy(WebViewClient webViewClient, DomainConfig domainConfig, SecurityRuntimeExceptionResolver resolver) {
//         mWebViewClient = webViewClient;
//         mDomainConfig = domainConfig;
//         mSecurityRuntimeExceptionResolver = resolver;
//     }
// 
//     public boolean shouldOverrideUrlLoading(WebView view, String url) {
//         return mWebViewClient.shouldOverrideUrlLoading(view, url);
//     }
// 
//     public void onPageStarted(WebView view, String url, Bitmap favicon) {
//         try {
//             // XXX ugly
//             mWebViewClient.onPageStarted(view, url, favicon);
//         } catch (SkipDomainCheckRuntimeException exp) {
//             return;
//         }
// 
//         Uri uri = Uri.parse(url);
//         String[] domains = mDomainConfig.getDomains();
//         for (String domain : domains) {
//             if (UriUtils.compareDomain(uri, domain))
//                 return;
//         }
// 
//         SecurityRuntimeException exception = new SecurityRuntimeException("cannot load " + url, url);
//         if(mSecurityRuntimeExceptionResolver != null){
//             mSecurityRuntimeExceptionResolver.resolve(exception);
//         } else {
//             throw exception;
//         }
//     }
// 
//     public void onPageFinished(WebView view, String url) {
//         mWebViewClient.onPageFinished(view, url);
//     }
// 
//     public void onLoadResource(WebView view, String url) {
//         mWebViewClient.onLoadResource(view, url);
//     }
// 
//     @SuppressWarnings("deprecation")
//     public void onTooManyRedirects(WebView view, Message cancelMsg, Message continueMsg) {
//         mWebViewClient.onTooManyRedirects(view, cancelMsg, continueMsg);
//     }
// 
//     public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
//         mWebViewClient.onReceivedError(view, errorCode, description, failingUrl);
//     }
// 
//     public boolean equals(Object o) {
//         return mWebViewClient.equals(o);
//     }
// 
//     public void onFormResubmission(WebView view, Message dontResend, Message resend) {
//         mWebViewClient.onFormResubmission(view, dontResend, resend);
//     }
// 
//     public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) {
//         mWebViewClient.doUpdateVisitedHistory(view, url, isReload);
//     }
// 
//     public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
//         mWebViewClient.onReceivedSslError(view, handler, error);
//     }
// 
//     public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
//         mWebViewClient.onReceivedHttpAuthRequest(view, handler, host, realm);
//     }
// 
//     public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) {
//         return mWebViewClient.shouldOverrideKeyEvent(view, event);
//     }
// 
//     public int hashCode() {
//         return mWebViewClient.hashCode();
//     }
// 
//     public void onUnhandledKeyEvent(WebView view, KeyEvent event) {
//         mWebViewClient.onUnhandledKeyEvent(view, event);
//     }
// 
//     public void onScaleChanged(WebView view, float oldScale, float newScale) {
//         mWebViewClient.onScaleChanged(view, oldScale, newScale);
//     }
// 
//     public String toString() {
//         return mWebViewClient.toString();
//     }
// }


import android.webkit.WebViewClient;
import junit.framework.TestCase;
import triaina.commons.exception.SecurityRuntimeException;
import triaina.webview.WebViewBridge.SecurityRuntimeExceptionResolver;
import triaina.webview.WebViewBridge.WebViewClientProxy;
import triaina.webview.config.DomainConfig;
            WebViewClient client = new WebViewClientProxy(new WebViewClient(), mConfig);
            client.onPageStarted(null, WRONG_URL, null);
            fail();
        } catch (SecurityRuntimeException e) {
            assertTrue(true);
        } catch (Exception e) {
            fail();
        }
    }

    public void testOnPageStartedOnExceptionWithoutExceptionResolver() {
        try {
            WebViewClient client = new WebViewClientProxy(new WebViewClient(), mConfig, null);
            client.onPageStarted(null, WRONG_URL, null);
            fail();
        } catch (SecurityRuntimeException e) {
            assertTrue(true);
        } catch (Exception e) {
            fail();
        }
    }

    public void testOnPageStartedOnExceptionHandlingWithExceptionResolver() {
        try {
            SecurityRuntimeExceptionResolver resolver = new SecurityRuntimeExceptionResolver() {
                @Override
                public void resolve(SecurityRuntimeException e) {
                    assertEquals(WRONG_URL, e.getUrl());
                }
            };
// Path: android/Commons/src/triaina/commons/exception/SecurityRuntimeException.java
// public class SecurityRuntimeException extends CommonRuntimeException {
// 
// 	private static final long serialVersionUID = 6244026068714272574L;
// 
// 	private String mUrl;
// 
// 	public SecurityRuntimeException() {
// 		super();
// 	}
// 
// 	public SecurityRuntimeException(String detailMessage, Throwable throwable) {
// 		super(detailMessage, throwable);
// 	}
// 
// 	public SecurityRuntimeException(String detailMessage) {
// 		super(detailMessage);
// 	}
// 
// 	public SecurityRuntimeException(String detailMessage, String url) {
// 		this(detailMessage);
// 		mUrl = url;
// 	}
// 
// 	public SecurityRuntimeException(Throwable throwable) {
// 		super(throwable);
// 	}
// 
// 	public SecurityRuntimeException(Throwable throwable, String url) {
// 		this(throwable);
// 		mUrl = url;
// 	}
// 
// 	public String getUrl(){
// 		return mUrl;
// 	}
// }
// 
// Path: android/WebViewBridge/src/triaina/webview/WebViewBridge.java
// public static interface SecurityRuntimeExceptionResolver {
//     public void resolve(SecurityRuntimeException e);
// }
// 
// Path: android/WebViewBridge/src/triaina/webview/WebViewBridge.java
// public static class WebViewClientProxy extends WebViewClient {
//     private WebViewClient mWebViewClient;
//     private DomainConfig mDomainConfig;
//     private SecurityRuntimeExceptionResolver mSecurityRuntimeExceptionResolver;
// 
//     public WebViewClientProxy(WebViewClient webViewClient, DomainConfig domainConfig) {
//         this(webViewClient, domainConfig, null);
//     }
// 
//     public WebViewClientProxy(WebViewClient webViewClient, DomainConfig domainConfig, SecurityRuntimeExceptionResolver resolver) {
//         mWebViewClient = webViewClient;
//         mDomainConfig = domainConfig;
//         mSecurityRuntimeExceptionResolver = resolver;
//     }
// 
//     public boolean shouldOverrideUrlLoading(WebView view, String url) {
//         return mWebViewClient.shouldOverrideUrlLoading(view, url);
//     }
// 
//     public void onPageStarted(WebView view, String url, Bitmap favicon) {
//         try {
//             // XXX ugly
//             mWebViewClient.onPageStarted(view, url, favicon);
//         } catch (SkipDomainCheckRuntimeException exp) {
//             return;
//         }
// 
//         Uri uri = Uri.parse(url);
//         String[] domains = mDomainConfig.getDomains();
//         for (String domain : domains) {
//             if (UriUtils.compareDomain(uri, domain))
//                 return;
//         }
// 
//         SecurityRuntimeException exception = new SecurityRuntimeException("cannot load " + url, url);
//         if(mSecurityRuntimeExceptionResolver != null){
//             mSecurityRuntimeExceptionResolver.resolve(exception);
//         } else {
//             throw exception;
//         }
//     }
// 
//     public void onPageFinished(WebView view, String url) {
//         mWebViewClient.onPageFinished(view, url);
//     }
// 
//     public void onLoadResource(WebView view, String url) {
//         mWebViewClient.onLoadResource(view, url);
//     }
// 
//     @SuppressWarnings("deprecation")
//     public void onTooManyRedirects(WebView view, Message cancelMsg, Message continueMsg) {
//         mWebViewClient.onTooManyRedirects(view, cancelMsg, continueMsg);
//     }
// 
//     public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
//         mWebViewClient.onReceivedError(view, errorCode, description, failingUrl);
//     }
// 
//     public boolean equals(Object o) {
//         return mWebViewClient.equals(o);
//     }
// 
//     public void onFormResubmission(WebView view, Message dontResend, Message resend) {
//         mWebViewClient.onFormResubmission(view, dontResend, resend);
//     }
// 
//     public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) {
//         mWebViewClient.doUpdateVisitedHistory(view, url, isReload);
//     }
// 
//     public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
//         mWebViewClient.onReceivedSslError(view, handler, error);
//     }
// 
//     public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
//         mWebViewClient.onReceivedHttpAuthRequest(view, handler, host, realm);
//     }
// 
//     public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) {
//         return mWebViewClient.shouldOverrideKeyEvent(view, event);
//     }
// 
//     public int hashCode() {
//         return mWebViewClient.hashCode();
//     }
// 
//     public void onUnhandledKeyEvent(WebView view, KeyEvent event) {
//         mWebViewClient.onUnhandledKeyEvent(view, event);
//     }
// 
//     public void onScaleChanged(WebView view, float oldScale, float newScale) {
//         mWebViewClient.onScaleChanged(view, oldScale, newScale);
//     }
// 
//     public String toString() {
//         return mWebViewClient.toString();
//     }
// }


// Path: android/WebViewBridge/tests/java/triaina/test/webview/WebViewClientProxyTest.java
import android.webkit.WebViewClient;
import junit.framework.TestCase;
import triaina.commons.exception.SecurityRuntimeException;
import triaina.webview.WebViewBridge.SecurityRuntimeExceptionResolver;
import triaina.webview.WebViewBridge.WebViewClientProxy;
import triaina.webview.config.DomainConfig;

            WebViewClient client = new WebViewClientProxy(new WebViewClient(), mConfig);
            client.onPageStarted(null, WRONG_URL, null);
            fail();
        } catch (SecurityRuntimeException e) {
            assertTrue(true);
        } catch (Exception e) {
            fail();
        }
    }

    public void testOnPageStartedOnExceptionWithoutExceptionResolver() {
        try {
            WebViewClient client = new WebViewClientProxy(new WebViewClient(), mConfig, null);
            client.onPageStarted(null, WRONG_URL, null);
            fail();
        } catch (SecurityRuntimeException e) {
            assertTrue(true);
        } catch (Exception e) {
            fail();
        }
    }

    public void testOnPageStartedOnExceptionHandlingWithExceptionResolver() {
        try {
            SecurityRuntimeExceptionResolver resolver = new SecurityRuntimeExceptionResolver() {
                @Override
                public void resolve(SecurityRuntimeException e) {
                    assertEquals(WRONG_URL, e.getUrl());
                }
            };
            WebViewClient client = new WebViewClientProxy(new WebViewClient(), mConfig, resolver);