Permalink
Browse files

formatting code

  • Loading branch information...
1 parent 119deaf commit 9587758676d17c86a4bf787dc6544e4352c04b21 @klieber klieber committed Feb 1, 2016
Showing with 1,751 additions and 1,661 deletions.
  1. +13 −0 .editorconfig
  2. +69 −57 src/main/java/com/github/searls/jasmine/NullLog.java
  3. +8 −9 src/main/java/com/github/searls/jasmine/coffee/CoffeeScript.java
  4. +1 −1 src/main/java/com/github/searls/jasmine/coffee/DetectsCoffee.java
  5. +12 −14 src/main/java/com/github/searls/jasmine/coffee/HandlesRequestsForCoffee.java
  6. +19 −15 src/main/java/com/github/searls/jasmine/config/JasmineConfiguration.java
  7. +18 −19 src/main/java/com/github/searls/jasmine/driver/QuietHtmlUnitDriver.java
  8. +5 −5 src/main/java/com/github/searls/jasmine/driver/WebDriverFactory.java
  9. +1 −1 src/main/java/com/github/searls/jasmine/format/BuildsJavaScriptToWriteFailureHtml.java
  10. +4 −5 src/main/java/com/github/searls/jasmine/format/JasmineResultLogger.java
  11. +8 −8 src/main/java/com/github/searls/jasmine/io/IOUtilsWrapper.java
  12. +5 −5 src/main/java/com/github/searls/jasmine/io/RelativizesFilePaths.java
  13. +4 −4 src/main/java/com/github/searls/jasmine/io/ScansDirectory.java
  14. +6 −7 src/main/java/com/github/searls/jasmine/io/scripts/BasicScriptResolver.java
  15. +15 −15 src/main/java/com/github/searls/jasmine/io/scripts/ContextPathScriptResolver.java
  16. +3 −3 src/main/java/com/github/searls/jasmine/io/scripts/FindsScriptLocationsInDirectory.java
  17. +5 −5 src/main/java/com/github/searls/jasmine/io/scripts/ResolvesLocationOfPreloadSources.java
  18. +1 −1 src/main/java/com/github/searls/jasmine/io/scripts/ScriptResolver.java
  19. +1 −1 src/main/java/com/github/searls/jasmine/io/scripts/ScriptResolverException.java
  20. +1 −1 src/main/java/com/github/searls/jasmine/model/JasmineResult.java
  21. +380 −379 src/main/java/com/github/searls/jasmine/mojo/AbstractJasmineMojo.java
  22. +1 −1 src/main/java/com/github/searls/jasmine/mojo/Capability.java
  23. +2 −1 src/main/java/com/github/searls/jasmine/mojo/Context.java
  24. +22 −22 src/main/java/com/github/searls/jasmine/mojo/ServerMojo.java
  25. +49 −48 src/main/java/com/github/searls/jasmine/mojo/TestMojo.java
  26. +5 −7 src/main/java/com/github/searls/jasmine/runner/AbstractSpecRunnerHtmlGenerator.java
  27. +17 −18 src/main/java/com/github/searls/jasmine/runner/CreatesRunner.java
  28. +11 −11 src/main/java/com/github/searls/jasmine/runner/DefaultSpecRunnerHtmlGenerator.java
  29. +112 −112 src/main/java/com/github/searls/jasmine/runner/HtmlGeneratorConfiguration.java
  30. +79 −80 src/main/java/com/github/searls/jasmine/runner/SpecRunnerExecutor.java
  31. +6 −6 src/main/java/com/github/searls/jasmine/runner/SpecRunnerHtmlGenerator.java
  32. +2 −2 src/main/java/com/github/searls/jasmine/runner/SpecRunnerHtmlGeneratorFactory.java
  33. +12 −12 src/main/java/com/github/searls/jasmine/runner/SpecRunnerTemplate.java
  34. +2 −2 src/main/java/com/github/searls/jasmine/server/ResourceHandlerConfigurator.java
  35. +1 −1 src/main/java/com/github/searls/jasmine/thirdpartylibs/AbstractThirdPartyLibsResourceHandler.java
  36. +3 −3 src/main/java/com/github/searls/jasmine/thirdpartylibs/WebJarResourceHandler.java
  37. +33 −30 src/test/java/com/github/searls/jasmine/Matchers.java
  38. +25 −25 src/test/java/com/github/searls/jasmine/coffee/CoffeeScriptIntegrationTest.java
  39. +38 −36 src/test/java/com/github/searls/jasmine/coffee/DetectsCoffeeTest.java
  40. +29 −25 src/test/java/com/github/searls/jasmine/coffee/HandlesRequestsForCoffeeTest.java
  41. +1 −1 src/test/java/com/github/searls/jasmine/driver/CustomDriverWithDefaultConstructor.java
  42. +0 −1 src/test/java/com/github/searls/jasmine/driver/QuietHtmlUnitDriverTest.java
  43. +2 −2 src/test/java/com/github/searls/jasmine/driver/WebDriverFactoryTest.java
  44. +2 −2 src/test/java/com/github/searls/jasmine/exception/StringifiesStackTracesTest.java
  45. +8 −8 src/test/java/com/github/searls/jasmine/format/BuildsJavaScriptToWriteFailureHtmlTest.java
  46. +8 −8 src/test/java/com/github/searls/jasmine/format/FormatsScriptTagsTest.java
  47. +8 −7 src/test/java/com/github/searls/jasmine/format/JasmineResultLoggerTest.java
  48. +13 −13 src/test/java/com/github/searls/jasmine/io/IOUtilsWrapperIntegrationTest.java
  49. +9 −9 src/test/java/com/github/searls/jasmine/io/RelativizesFilePathsTest.java
  50. +69 −69 src/test/java/com/github/searls/jasmine/io/ScansDirectoryIntegrationTest.java
  51. +10 −11 src/test/java/com/github/searls/jasmine/io/scripts/BasicScriptResolverTest.java
  52. +22 −22 src/test/java/com/github/searls/jasmine/io/scripts/ContextPathScriptResolverTest.java
  53. +41 −38 src/test/java/com/github/searls/jasmine/io/scripts/ConvertsFileToUriStringIntegrationTest.java
  54. +13 −9 src/test/java/com/github/searls/jasmine/io/scripts/FindsScriptLocationsInDirectoryTest.java
  55. +27 −28 ...st/java/com/github/searls/jasmine/io/scripts/ResolvesLocationOfPreloadSourcesIntegrationTest.java
  56. +7 −5 src/test/java/com/github/searls/jasmine/model/JasmineResultTest.java
  57. +149 −145 src/test/java/com/github/searls/jasmine/mojo/AbstractJasmineMojoTest.java
  58. +34 −22 src/test/java/com/github/searls/jasmine/mojo/ServerMojoTest.java
  59. +140 −130 src/test/java/com/github/searls/jasmine/runner/CreatesRunnerTest.java
  60. +53 −54 src/test/java/com/github/searls/jasmine/runner/HtmlGeneratorConfigurationTest.java
  61. +40 −37 src/test/java/com/github/searls/jasmine/runner/SpecRunnerExecutorTest.java
  62. +7 −8 src/test/java/com/github/searls/jasmine/runner/SpecRunnerHtmlGeneratorFactoryTest.java
  63. +10 −5 src/test/java/com/github/searls/jasmine/runner/SpecRunnerHtmlGeneratorPseudoIntegrationTest.java
  64. +28 −19 src/test/java/com/github/searls/jasmine/server/JasmineResourceHandlerTest.java
  65. +3 −3 src/test/java/com/github/searls/jasmine/server/ResourceHandlerConfiguratorTest.java
  66. +1 −1 src/test/java/com/github/searls/jasmine/server/ServerManagerTest.java
  67. +5 −1 src/test/java/com/github/searls/jasmine/thirdpartylibs/ClassPathResourceHandlerTest.java
  68. +3 −1 src/test/java/com/github/searls/jasmine/thirdpartylibs/WebJarResourceHandlerTest.java
  69. +10 −5 src/test/java/org/eclipse/jetty/server/Server.java
View
@@ -0,0 +1,13 @@
+# editorconfig.org
+root = true
+
+[*]
+indent_style = space
+indent_size = 2
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false
@@ -2,60 +2,72 @@
public class NullLog implements org.apache.maven.plugin.logging.Log {
- @Override
- public boolean isDebugEnabled() {
- return false;
- }
-
- @Override
- public void debug(CharSequence content) {}
-
- @Override
- public void debug(CharSequence content, Throwable error) {}
-
- @Override
- public void debug(Throwable error) {}
-
- @Override
- public boolean isInfoEnabled() {
- return false;
- }
-
- @Override
- public void info(CharSequence content) {}
-
- @Override
- public void info(CharSequence content, Throwable error) {}
-
- @Override
- public void info(Throwable error) {}
-
- @Override
- public boolean isWarnEnabled() {
- return false;
- }
-
- @Override
- public void warn(CharSequence content) {}
-
- @Override
- public void warn(CharSequence content, Throwable error) {}
-
- @Override
- public void warn(Throwable error) {}
-
- @Override
- public boolean isErrorEnabled() {
- return false;
- }
-
- @Override
- public void error(CharSequence content) {}
-
- @Override
- public void error(CharSequence content, Throwable error) {}
-
- @Override
- public void error(Throwable error) {}
-
-}
+ @Override
+ public boolean isDebugEnabled() {
+ return false;
+ }
+
+ @Override
+ public void debug(CharSequence content) {
+ }
+
+ @Override
+ public void debug(CharSequence content, Throwable error) {
+ }
+
+ @Override
+ public void debug(Throwable error) {
+ }
+
+ @Override
+ public boolean isInfoEnabled() {
+ return false;
+ }
+
+ @Override
+ public void info(CharSequence content) {
+ }
+
+ @Override
+ public void info(CharSequence content, Throwable error) {
+ }
+
+ @Override
+ public void info(Throwable error) {
+ }
+
+ @Override
+ public boolean isWarnEnabled() {
+ return false;
+ }
+
+ @Override
+ public void warn(CharSequence content) {
+ }
+
+ @Override
+ public void warn(CharSequence content, Throwable error) {
+ }
+
+ @Override
+ public void warn(Throwable error) {
+ }
+
+ @Override
+ public boolean isErrorEnabled() {
+ return false;
+ }
+
+ @Override
+ public void error(CharSequence content) {
+ }
+
+ @Override
+ public void error(CharSequence content, Throwable error) {
+ }
+
+ @Override
+ public void error(Throwable error) {
+ }
+
+}
@@ -1,21 +1,20 @@
package com.github.searls.jasmine.coffee;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.apache.commons.lang3.StringEscapeUtils;
-
import com.gargoylesoftware.htmlunit.MockWebConnection;
import com.gargoylesoftware.htmlunit.ScriptResult;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.github.searls.jasmine.io.IOUtilsWrapper;
+import org.apache.commons.lang3.StringEscapeUtils;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+import java.util.WeakHashMap;
public class CoffeeScript {
- private static Map<String,String> cache = Collections.synchronizedMap(new WeakHashMap<String,String>());
+ private static Map<String, String> cache = Collections.synchronizedMap(new WeakHashMap<String, String>());
private final ThreadLocal<HtmlPage> htmlPage = new ThreadLocal<HtmlPage>() {
@Override
@@ -43,7 +42,7 @@ public String compile(String coffee) throws IOException {
private String compileAndCache(String input) {
ScriptResult scriptResult = htmlPage.get().executeJavaScript(String.format("CoffeeScript.compile(\"%s\");", input));
String result = (String) scriptResult.getJavaScriptResult();
- cache.put(input,result);
+ cache.put(input, result);
return result;
}
@@ -5,7 +5,7 @@
public class DetectsCoffee {
public boolean detect(String path) {
- return StringUtils.endsWith(StringUtils.substringBefore(path,"?"),".coffee");
+ return StringUtils.endsWith(StringUtils.substringBefore(path, "?"), ".coffee");
}
}
@@ -1,17 +1,15 @@
package com.github.searls.jasmine.coffee;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-
-import javax.servlet.http.HttpServletResponse;
-
+import com.github.searls.jasmine.config.JasmineConfiguration;
+import com.github.searls.jasmine.format.BuildsJavaScriptToWriteFailureHtml;
import org.apache.commons.io.IOUtils;
import org.eclipse.jetty.http.HttpHeaders;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.resource.Resource;
-import com.github.searls.jasmine.config.JasmineConfiguration;
-import com.github.searls.jasmine.format.BuildsJavaScriptToWriteFailureHtml;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
public class HandlesRequestsForCoffee {
@@ -20,17 +18,17 @@
private JasmineConfiguration configuration;
public HandlesRequestsForCoffee(JasmineConfiguration configuration) {
- this.configuration = configuration;
+ this.configuration = configuration;
}
public void handle(Request baseRequest, HttpServletResponse response, Resource resource) throws IOException {
baseRequest.setHandled(true);
String javascript = null;
if (!configuration.isCoffeeScriptCompilationEnabled()) {
- // CoffeeScript RequireJS plugin should be used for translation
- javascript = IOUtils.toString(resource.getInputStream(), "UTF-8");
+ // CoffeeScript RequireJS plugin should be used for translation
+ javascript = IOUtils.toString(resource.getInputStream(), "UTF-8");
} else {
- javascript = compileCoffee(resource);
+ javascript = compileCoffee(resource);
}
setHeaders(response, resource, javascript);
writeResponse(response, javascript);
@@ -46,7 +44,7 @@ private void setHeaders(HttpServletResponse response, Resource resource, String
response.setDateHeader(HttpHeaders.LAST_MODIFIED, resource.lastModified());
try {
int contentLength = javascript.getBytes("UTF-8").length;
- response.setHeader(HttpHeaders.CONTENT_LENGTH,Integer.toString(contentLength));
+ response.setHeader(HttpHeaders.CONTENT_LENGTH, Integer.toString(contentLength));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(
"The JVM does not support the compiler's default encoding.", e);
@@ -57,8 +55,8 @@ private void setHeaders(HttpServletResponse response, Resource resource, String
private String compileCoffee(Resource resource) {
try {
return coffeeScript.compile(IOUtils.toString(resource.getInputStream(), "UTF-8"));
- } catch(Exception e) {
- return buildsJavaScriptToWriteFailureHtml.build("CoffeeScript Error: failed to compile <code>"+resource.getName()+"</code>. <br/>Error message:<br/><br/><code>"+e.getMessage()+"</code>");
+ } catch (Exception e) {
+ return buildsJavaScriptToWriteFailureHtml.build("CoffeeScript Error: failed to compile <code>" + resource.getName() + "</code>. <br/>Error message:<br/><br/><code>" + e.getMessage() + "</code>");
}
}
@@ -11,30 +11,34 @@
public interface JasmineConfiguration {
File getBasedir();
- File getJasmineTargetDir();
- String getSrcDirectoryName();
- String getSpecDirectoryName();
+ File getJasmineTargetDir();
- ScriptSearch getSources();
- ScriptSearch getSpecs();
+ String getSrcDirectoryName();
+
+ String getSpecDirectoryName();
+
+ ScriptSearch getSources();
+
+ ScriptSearch getSpecs();
List<Context> getContexts();
- List<String> getPreloadSources();
+ List<String> getPreloadSources();
+
+ String getSourceEncoding();
+
+ Log getLog();
- String getSourceEncoding();
+ SpecRunnerTemplate getSpecRunnerTemplate();
- Log getLog();
+ File getCustomRunnerTemplate();
- SpecRunnerTemplate getSpecRunnerTemplate();
+ File getCustomRunnerConfiguration();
- File getCustomRunnerTemplate();
- File getCustomRunnerConfiguration();
+ int getAutoRefreshInterval();
- int getAutoRefreshInterval();
-
- boolean isCoffeeScriptCompilationEnabled();
+ boolean isCoffeeScriptCompilationEnabled();
- ClassLoader getProjectClassLoader();
+ ClassLoader getProjectClassLoader();
}
@@ -1,11 +1,10 @@
package com.github.searls.jasmine.driver;
-import org.openqa.selenium.Capabilities;
-import org.openqa.selenium.htmlunit.HtmlUnitDriver;
-
import com.gargoylesoftware.htmlunit.IncorrectnessListener;
import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
import com.gargoylesoftware.htmlunit.WebClient;
+import org.openqa.selenium.Capabilities;
+import org.openqa.selenium.htmlunit.HtmlUnitDriver;
/**
* The default web driver - overridden to tweak a few things.
@@ -14,24 +13,24 @@
private final boolean debug;
- public QuietHtmlUnitDriver(Capabilities capabilities, boolean debug) {
+ public QuietHtmlUnitDriver(Capabilities capabilities, boolean debug) {
super(capabilities);
this.debug = debug;
- this.setJavascriptEnabled(true);
- }
+ this.setJavascriptEnabled(true);
+ }
- @Override
- protected WebClient modifyWebClient(WebClient client) {
- client.setAjaxController(new NicelyResynchronizingAjaxController());
+ @Override
+ protected WebClient modifyWebClient(WebClient client) {
+ client.setAjaxController(new NicelyResynchronizingAjaxController());
- //Disables stuff like this "com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Obsolete content type encountered: 'text/javascript'."
- if (!this.debug) {
- client.setIncorrectnessListener(new IncorrectnessListener() {
- @Override
- public void notify(String message, Object origin) {
- }
- });
- }
- return client;
- }
+ //Disables stuff like this "com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Obsolete content type encountered: 'text/javascript'."
+ if (!this.debug) {
+ client.setIncorrectnessListener(new IncorrectnessListener() {
+ @Override
+ public void notify(String message, Object origin) {
+ }
+ });
+ }
+ return client;
+ }
}
@@ -103,7 +103,7 @@ private WebDriver createCustomWebDriver() throws Exception {
if (constructor.getParameterTypes().length == 0) {
return new Object[0];
}
- return new Object[] {getCapabilities()};
+ return new Object[]{getCapabilities()};
}
private DesiredCapabilities getCapabilities() {
@@ -117,12 +117,12 @@ private void customizeCapabilities(DesiredCapabilities capabilities) {
for (Capability capability : webDriverCapabilities) {
Object value = capability.getValue();
- if (value != null && (!String.class.isInstance(value) || StringUtils.isNotBlank((String)value))) {
- capabilities.setCapability(capability.getName(),capability.getValue());
+ if (value != null && (!String.class.isInstance(value) || StringUtils.isNotBlank((String) value))) {
+ capabilities.setCapability(capability.getName(), capability.getValue());
} else if (capability.getList() != null && !capability.getList().isEmpty()) {
- capabilities.setCapability(capability.getName(),capability.getList());
+ capabilities.setCapability(capability.getName(), capability.getList());
} else if (capability.getMap() != null && !capability.getMap().isEmpty()) {
- capabilities.setCapability(capability.getName(),capability.getMap());
+ capabilities.setCapability(capability.getName(), capability.getMap());
}
}
}
@@ -5,7 +5,7 @@
public class BuildsJavaScriptToWriteFailureHtml {
public String build(String html) {
- return "document.write(\""+StringEscapeUtils.escapeEcmaScript("<div class=\"suite spec failed\">"+html+"</div>")+"\")";
+ return "document.write(\"" + StringEscapeUtils.escapeEcmaScript("<div class=\"suite spec failed\">" + html + "</div>") + "\")";
}
}
Oops, something went wrong.

0 comments on commit 9587758

Please sign in to comment.