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