Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Formatting fixes

  • Loading branch information...
commit a9b14e8cef7b1ae30cc10de4abc60a56e2518440 1 parent d4167ee
@Randgalt Randgalt authored
Showing with 44 additions and 10 deletions.
  1. +38 −10 blogs/mockwebserver.html
  2. +6 −0 css/blog.css
View
48 blogs/mockwebserver.html
@@ -1,12 +1,35 @@
<h1>Why mock servers that don't mock matter</h1>
-Operations folk can relate to the idea that best intentions, and cleverest libraries, do not a stable system make. &nbsp;More recently in <a href="http://techblog.netflix.com/2013/03/denominator-multi-vendor-interface-for.html">denominator</a>, I've relied on the ability to check what's going onto the wire as a foundation for crafting http api requests. &nbsp;A <a href="https://twitter.com/adrianfcole/status/309152829778575361">quick poll</a> suggests I should say more.<br />
-<br />
-When using libraries or otherwise creating http requests, a false sense of security is your worst nightmare. &nbsp;For example,&nbsp;in java 6&nbsp;<code>Expect</code> is a <a href="http://javasourcecode.org/html/open-source/jdk/jdk-6u23/sun/net/www/protocol/http/HttpURLConnection.java.html">restricted header</a>, eventhough it isn't <a href="http://www.docjar.com/html/api/sun/net/www/protocol/http/HttpURLConnection.java.html">afterwards</a>. &nbsp;Typical mock tests cannot prove your application can work when they test above a&nbsp;<a href="http://android-developers.blogspot.com/2011/09/androids-http-clients.html">library or runtime</a>&nbsp;that can change. &nbsp;These changes occur more than you think, especially with <a href="http://www.oracle.com/technetwork/java/eol-135779.html">Java 6 EOL</a> migrations and Java 8 around the corner.<br />
-<br />
-<a href="http://code.google.com/p/mockwebserver/">mockwebserver</a>&nbsp;is a great way to setup truths that your application must adhere to, without regard to how it is crafted. &nbsp;Despite its name, mockwebserver literally reads bytes off the wire to assert the expected behavior. &nbsp;Unlike many libraries, but <a href="http://stackoverflow.com/questions/393099/mocking-http-server">similar to some</a>, mockwebserver is only several small classes with one <a href="http://code.google.com/p/mockwebserver/source/browse/trunk/src/main/java/com/google/mockwebserver/MockWebServer.java">main controller</a>. &nbsp;The small code base is easy to read when you are in the middle of debugging a gnarly issue.<br />
-<br />
-Case in point: in <a href="https://github.com/Netflix/denominator">denominator</a>, I want to assure any aggregate commands needed for a dns change are ordered and have the expected result. &nbsp;In a <a href="https://github.com/Netflix/denominator/blob/master/providers/denominator-route53/src/test/java/denominator/route53/Route53ResourceRecordSetApiMockTest.java">mock test</a>, setup tests like below to make assert that behavior. &nbsp;The only requirement is that my code can accept a url.<br />
-<br />
+
+<p>
+Operations folk can relate to the idea that best intentions, and cleverest libraries, do not a stable system
+make. More recently in <a href="http://techblog.netflix.com/2013/03/denominator-multi-vendor-interface-for.html">denominator</a>,
+I've relied on the ability to check what's going onto the wire as a foundation for crafting http api requests.
+A <a href="https://twitter.com/adrianfcole/status/309152829778575361">quick poll</a> suggests I should say more.
+</p>
+
+<p>
+When using libraries or otherwise creating http requests, a false sense of security is your worst nightmare. For example, in
+java 6 <code>Expect</code> is a <a href="http://javasourcecode.org/html/open-source/jdk/jdk-6u23/sun/net/www/protocol/http/HttpURLConnection.java.html">restricted header</a>,
+eventhough it isn't <a href="http://www.docjar.com/html/api/sun/net/www/protocol/http/HttpURLConnection.java.html">afterwards</a>. Typical mock tests cannot prove your
+application can work when they test above a <a href="http://android-developers.blogspot.com/2011/09/androids-http-clients.html">library or runtime</a> that can change.
+These changes occur more than you think, especially with <a href="http://www.oracle.com/technetwork/java/eol-135779.html">Java 6 EOL</a> migrations and Java 8 around the corner.
+</p>
+
+<p>
+<a href="http://code.google.com/p/mockwebserver/">mockwebserver</a> is a great way to setup truths that your application must adhere to,
+without regard to how it is crafted. Despite its name, mockwebserver literally reads bytes off the wire to assert the expected behavior.
+Unlike many libraries, but <a href="http://stackoverflow.com/questions/393099/mocking-http-server">similar to some</a>, mockwebserver is only
+several small classes with one <a href="http://code.google.com/p/mockwebserver/source/browse/trunk/src/main/java/com/google/mockwebserver/MockWebServer.java">main
+controller</a>. The small code base is easy to read when you are in the middle of debugging a gnarly issue.
+</p>
+
+<p>
+Case in point: in <a href="https://github.com/Netflix/denominator">denominator</a>, I want to assure any aggregate commands needed for a
+dns change are ordered and have the expected result. In a <a href="https://github.com/Netflix/denominator/blob/master/providers/denominator-route53/src/test/java/denominator/route53/Route53ResourceRecordSetApiMockTest.java">mock test</a>,
+setup tests like below to make assert that behavior. The only requirement is that my code can accept a url.
+</p>
+
+<p>
<pre>@Test
public void addSecondRecordRecreatesRRSetAndRetainsTTL() throws IOException, InterruptedException {
MockWebServer server = new MockWebServer();
@@ -34,5 +57,10 @@
}
}
</pre>
-<br />
-Tests written in mockwebserver, applied across a number of JREs, will bullet-proof your tests for your supported configurations. &nbsp;In summary, it doesn't really matter if you choose to use mockwebserver or something else to assure your http traffic shapes as expected. &nbsp;Main idea is to be strict so that regardless of runtime shifts, you know what your application sends and what it is resilient to.
+</p>
+
+<p>
+Tests written in mockwebserver, applied across a number of JREs, will bullet-proof your tests for your supported
+configurations. In summary, it doesn't really matter if you choose to use mockwebserver or something else to assure your
+http traffic shapes as expected. Main idea is to be strict so that regardless of runtime shifts, you know what your application sends and what it is resilient to.
+</p>
View
6 css/blog.css
@@ -22,4 +22,10 @@
#blog-content p
{
margin-bottom: 5px;
+}
+
+#blog-content code
+{
+ overflow-x: auto;
+ white-space: pre;
}
Please sign in to comment.
Something went wrong with that request. Please try again.