Search in sources :

Example 6 with GwtTestException

use of com.googlecode.gwt.test.exceptions.GwtTestException in project gwt-test-utils by gwt-test-utils.

the class ConfigurationLoader method extractSrcUrlsFromBooterJar.

private URL[] extractSrcUrlsFromBooterJar(String surefireBooterJarPath) {
    try {
        // handles spaces encoded %20 to fix
        // https://github.com/gwt-test-utils/gwt-test-utils/issues/17
        String decodedJarPath = URLDecoder.decode(surefireBooterJarPath, "utf-8");
        JarFile surefireBooterJar = new JarFile(decodedJarPath);
        Manifest mf = surefireBooterJar.getManifest();
        Attributes a = mf.getMainAttributes();
        String[] classpathEntries = a.getValue("Class-Path").split(" ");
        URL[] urls = new URL[classpathEntries.length];
        for (int i = 0; i < classpathEntries.length; i++) {
            urls[i] = new URL(classpathEntries[i]);
        }
        return urls;
    } catch (Exception e) {
        throw new GwtTestException("Error while parsing maven-surefire-plugin booter jar: " + surefireBooterJarPath, e);
    }
}
Also used : GwtTestException(com.googlecode.gwt.test.exceptions.GwtTestException) Attributes(java.util.jar.Attributes) JarFile(java.util.jar.JarFile) Manifest(java.util.jar.Manifest) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) GwtTestPatchException(com.googlecode.gwt.test.exceptions.GwtTestPatchException) MalformedURLException(java.net.MalformedURLException) GwtTestException(com.googlecode.gwt.test.exceptions.GwtTestException) IOException(java.io.IOException) GwtTestConfigurationException(com.googlecode.gwt.test.exceptions.GwtTestConfigurationException)

Example 7 with GwtTestException

use of com.googlecode.gwt.test.exceptions.GwtTestException in project gwt-test-utils by gwt-test-utils.

the class GwtTranslator method applyJavaClassModifiers.

private void applyJavaClassModifiers(CtClass ctClass) {
    try {
        // Apply internal modifiers
        serializableModifier.modify(ctClass);
        hasHTMLModifier.modify(ctClass);
        hasNameModifier.modify(ctClass);
        classVisibilityModifier.modify(ctClass);
    } catch (Exception e) {
        if (GwtTestException.class.isInstance(e)) {
            throw (GwtTestException) e;
        }
        throw new GwtTestPatchException(e);
    }
}
Also used : GwtTestPatchException(com.googlecode.gwt.test.exceptions.GwtTestPatchException) GwtTestException(com.googlecode.gwt.test.exceptions.GwtTestException) GwtTestException(com.googlecode.gwt.test.exceptions.GwtTestException) NotFoundException(javassist.NotFoundException) GwtTestPatchException(com.googlecode.gwt.test.exceptions.GwtTestPatchException)

Example 8 with GwtTestException

use of com.googlecode.gwt.test.exceptions.GwtTestException in project gwt-test-utils by gwt-test-utils.

the class ModuleData method parseModule.

private void parseModule(String moduleName) {
    try {
        Document document = createDocument(moduleName);
        XPath xpath = XPathFactory.newInstance().newXPath();
        parseModuleFile(moduleName, document, xpath);
        alias = getModuleAlias(document, xpath);
    } catch (Exception e) {
        if (GwtTestException.class.isInstance(e)) {
            throw (GwtTestException) e;
        } else {
            throw new GwtTestConfigurationException("Error while parsing GWT module '" + moduleName + "'", e);
        }
    }
}
Also used : XPath(javax.xml.xpath.XPath) GwtTestException(com.googlecode.gwt.test.exceptions.GwtTestException) GwtTestConfigurationException(com.googlecode.gwt.test.exceptions.GwtTestConfigurationException) Document(org.w3c.dom.Document) XPathExpressionException(javax.xml.xpath.XPathExpressionException) GwtTestException(com.googlecode.gwt.test.exceptions.GwtTestException) FileNotFoundException(java.io.FileNotFoundException) GwtTestConfigurationException(com.googlecode.gwt.test.exceptions.GwtTestConfigurationException)

Example 9 with GwtTestException

use of com.googlecode.gwt.test.exceptions.GwtTestException in project gwt-test-utils by gwt-test-utils.

the class DocumentPatcher method nativeGet.

@PatchMethod
static Document nativeGet() {
    if (DOCUMENT_HOLDER.document == null) {
        try {
            DOCUMENT_HOLDER.document = JsoUtils.newDocument();
            Element e = parseHTMLElement(DOCUMENT_HOLDER.document);
            DOCUMENT_HOLDER.document.appendChild(e);
            JavaScriptObjects.setProperty(DOCUMENT_HOLDER.document, DOCUMENT_ELEMENT, e);
            return DOCUMENT_HOLDER.document;
        } catch (Exception e) {
            if (GwtTestException.class.isInstance(e)) {
                throw (GwtTestException) e;
            } else {
                throw new GwtTestDomException("Unable to create Document", e);
            }
        }
    }
    return DOCUMENT_HOLDER.document;
}
Also used : GwtTestException(com.googlecode.gwt.test.exceptions.GwtTestException) GwtTestDomException(com.googlecode.gwt.test.exceptions.GwtTestDomException) GwtTestException(com.googlecode.gwt.test.exceptions.GwtTestException) GwtTestConfigurationException(com.googlecode.gwt.test.exceptions.GwtTestConfigurationException) GwtTestDomException(com.googlecode.gwt.test.exceptions.GwtTestDomException) PatchMethod(com.googlecode.gwt.test.patchers.PatchMethod)

Example 10 with GwtTestException

use of com.googlecode.gwt.test.exceptions.GwtTestException in project gwt-test-utils by gwt-test-utils.

the class JsonUtilsPatcher method eval.

private static <T extends JavaScriptObject> T eval(String json) {
    JsonParser jp = null;
    try {
        jp = getFactory().createJsonParser(json);
        // will return JsonToken.START_OBJECT (verify?)
        jp.nextToken();
        return extractJso(json, jp.getCurrentToken(), jp).<T>cast();
    } catch (Exception e) {
        if (e instanceof GwtTestException) {
            throw (GwtTestException) e;
        }
        throw new GwtTestJSONException("Error while parsing JSON string '" + json + "'", e);
    } finally {
        if (jp != null) {
            try {
                // ensure resources get cleaned up timely and properly
                jp.close();
            } catch (IOException e) {
            // should never happen
            }
        }
    }
}
Also used : GwtTestException(com.googlecode.gwt.test.exceptions.GwtTestException) GwtTestJSONException(com.googlecode.gwt.test.exceptions.GwtTestJSONException) IOException(java.io.IOException) GwtTestException(com.googlecode.gwt.test.exceptions.GwtTestException) IOException(java.io.IOException) GwtTestJSONException(com.googlecode.gwt.test.exceptions.GwtTestJSONException) JsonParseException(org.codehaus.jackson.JsonParseException) JsonParser(org.codehaus.jackson.JsonParser)

Aggregations

GwtTestException (com.googlecode.gwt.test.exceptions.GwtTestException)13 IOException (java.io.IOException)4 GwtTestConfigurationException (com.googlecode.gwt.test.exceptions.GwtTestConfigurationException)3 GwtTestPatchException (com.googlecode.gwt.test.exceptions.GwtTestPatchException)3 Field (java.lang.reflect.Field)3 GwtTestJSONException (com.googlecode.gwt.test.exceptions.GwtTestJSONException)2 GwtTestUiBinderException (com.googlecode.gwt.test.exceptions.GwtTestUiBinderException)2 ReflectionException (com.googlecode.gwt.test.exceptions.ReflectionException)2 PatchMethod (com.googlecode.gwt.test.patchers.PatchMethod)2 JsonParseException (org.codehaus.jackson.JsonParseException)2 JsonParser (org.codehaus.jackson.JsonParser)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 Command (com.google.gwt.user.client.Command)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 StatusCodeException (com.google.gwt.user.client.rpc.StatusCodeException)1 UIObject (com.google.gwt.user.client.ui.UIObject)1 UmbrellaException (com.google.web.bindery.event.shared.UmbrellaException)1 GwtTestWithMockito (com.googlecode.gwt.test.GwtTestWithMockito)1 RemoteServiceExecutionHandler (com.googlecode.gwt.test.RemoteServiceExecutionHandler)1 GwtTestDomException (com.googlecode.gwt.test.exceptions.GwtTestDomException)1