Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

Commit

Permalink
Documentation and test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jaguililla committed Jan 31, 2015
1 parent f39ad6e commit c505a7d
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 181 deletions.
78 changes: 0 additions & 78 deletions assets/sabina-mono.svg

This file was deleted.

4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ jbake {

task site (dependsOn: 'jbake') {
copy {
from 'core/build/docs/javadoc/'
into "$buildDir/site/core/"
from 'html/build/docs/javadoc/'
into "$buildDir/site/html/"
include ('**')
}
copy {
Expand Down
16 changes: 8 additions & 8 deletions http/src/test/java/sabina/it/BooksIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.testng.annotations.Test;
import sabina.util.TestUtil;

public class BooksIT {
@Test public class BooksIT {
private static final String AUTHOR = "FOO", TITLE = "BAR", NEW_TITLE = "SABINA";

private static TestUtil testUtil = new TestUtil ();
Expand Down Expand Up @@ -123,7 +123,7 @@ public class BooksIT {
testUtil.waitForShutdown ();
}

@Test public void createBook () throws FileNotFoundException {
public void createBook () throws FileNotFoundException {
UrlResponse res =
testUtil.doPost ("/books?author=" + AUTHOR + "&title=" + TITLE);
sid = res.body.trim ();
Expand All @@ -134,7 +134,7 @@ public class BooksIT {
assertEquals (201, res.status);
}

@Test public void listBooks () throws FileNotFoundException {
public void listBooks () throws FileNotFoundException {
createBook ();
UrlResponse res = testUtil.doGet ("/books");

Expand All @@ -145,7 +145,7 @@ public class BooksIT {
assertEquals (200, res.status);
}

@Test public void getBook () throws FileNotFoundException {
public void getBook () throws FileNotFoundException {
// ensure there is a book
createBook ();
UrlResponse res = testUtil.doGet ("/books/" + sid);
Expand All @@ -161,7 +161,7 @@ public class BooksIT {
assertTrue (res.headers.get ("FOZ").equals ("BAZ"));
}

@Test public void updateBook () throws FileNotFoundException {
public void updateBook () throws FileNotFoundException {
createBook ();
UrlResponse res = testUtil.doPut ("/books/" + sid + "?title=" + NEW_TITLE);

Expand All @@ -172,7 +172,7 @@ public class BooksIT {
assertEquals (200, res.status);
}

@Test public void getUpdatedBook () throws FileNotFoundException {
public void getUpdatedBook () throws FileNotFoundException {
updateBook ();
UrlResponse res = testUtil.doGet ("/books/" + sid);

Expand All @@ -183,7 +183,7 @@ public class BooksIT {
assertEquals (200, res.status);
}

@Test public void deleteBook () throws FileNotFoundException {
public void deleteBook () throws FileNotFoundException {
UrlResponse res = testUtil.doDelete ("/books/" + sid);

assertNotNull (res);
Expand All @@ -193,7 +193,7 @@ public class BooksIT {
assertEquals (200, res.status);
}

@Test public void bookNotFound () throws FileNotFoundException {
public void bookNotFound () throws FileNotFoundException {
UrlResponse res = testUtil.doGet ("/books/" + 9999);

assertNotNull (res);
Expand Down
8 changes: 4 additions & 4 deletions http/src/test/java/sabina/it/CookiesIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*
* @author dreambrother
*/
public class CookiesIT {
@Test public class CookiesIT {
private static TestUtil testUtil = new TestUtil ();

@BeforeClass public static void setup () throws InterruptedException {
Expand Down Expand Up @@ -68,19 +68,19 @@ public class CookiesIT {
testUtil.waitForShutdown ();
}

@Test public void emptyCookies () {
public void emptyCookies () {
testUtil.doPost ("/assertNoCookies");
}

@Test public void createCookie () {
public void createCookie () {
String cookieName = "testCookie";
String cookieValue = "testCookieValue";
String cookie = cookieName + "&cookieValue=" + cookieValue;
testUtil.doPost ("/setCookie?cookieName=" + cookie);
testUtil.doPost ("/assertHasCookie?cookieName=" + cookie);
}

@Test public void removeCookie () {
public void removeCookie () {
String cookieName = "testCookie";
String cookieValue = "testCookieValue";
String cookie = cookieName + "&cookieValue=" + cookieValue;
Expand Down
38 changes: 19 additions & 19 deletions http/src/test/java/sabina/it/GenericIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.testng.annotations.Test;
import sabina.util.TestUtil;

public class GenericIT {
@Test public class GenericIT {

private static TestUtil testUtil = new TestUtil ();
private static File tmpExternalFile;
Expand Down Expand Up @@ -91,62 +91,62 @@ public class GenericIT {
testUtil.waitForStartup ();
}

@Test public void filtersShouldBeAcceptTypeAware () throws Exception {
public void filtersShouldBeAcceptTypeAware () throws Exception {
UrlResponse response =
testUtil.doMethod ("GET", "/protected/resource", null, "application/json");
assertTrue (response.status == 401);
assertEquals ("{\"message\": \"Go Away!\"}", response.body);
}

@Test public void routesShouldBeAcceptTypeAware () throws Exception {
public void routesShouldBeAcceptTypeAware () throws Exception {
UrlResponse response = testUtil.doMethod ("GET", "/hi", null, "application/json");
assertEquals (200, response.status);
assertEquals ("{\"message\": \"Hello World\"}", response.body);
}

@Test public void getHi () {
public void getHi () {
UrlResponse response = testUtil.doMethod ("GET", "/hi");
assertEquals (200, response.status);
assertEquals ("Hello World!", response.body);
}

@Test public void hiHead () {
public void hiHead () {
UrlResponse response = testUtil.doMethod ("HEAD", "/hi");
assertEquals (200, response.status);
assertEquals ("", response.body);
}

@Test public void getHiAfterFilter () {
public void getHiAfterFilter () {
UrlResponse response = testUtil.doMethod ("GET", "/hi");
assertTrue (response.headers.get ("after").contains ("foobar"));
}

@Test public void getRoot () {
public void getRoot () {
UrlResponse response = testUtil.doMethod ("GET", "/");
assertEquals (200, response.status);
assertEquals ("Hello Root!", response.body);
}

@Test public void paramAndWild () {
public void paramAndWild () {
UrlResponse response =
testUtil.doMethod ("GET", "/paramandwild/thedude/stuff/andits");
assertEquals (200, response.status);
assertEquals ("paramandwild: thedudeandits", response.body);
}

@Test public void echoParam1 () {
public void echoParam1 () {
UrlResponse response = testUtil.doMethod ("GET", "/param/shizzy");
assertEquals (200, response.status);
assertEquals ("echo: shizzy", response.body);
}

@Test public void echoParam2 () {
public void echoParam2 () {
UrlResponse response = testUtil.doMethod ("GET", "/param/gunit");
assertEquals (200, response.status);
assertEquals ("echo: gunit", response.body);
}

@Test public void echoParamWithUpperCaseInValue () {
public void echoParamWithUpperCaseInValue () {
final String camelCased = "ThisIsAValueAndSabinaShouldRetainItsUpperCasedCharacters";
UrlResponse response = testUtil.doMethod ("GET", "/param/" + camelCased);
assertEquals (200, response.status);
Expand Down Expand Up @@ -177,48 +177,48 @@ private static void assertEchoRoute (String routePart) {
assertEquals (routePart + " route: " + expected, response.body);
}

@Test public void echoParamWithMaj () {
public void echoParamWithMaj () {
UrlResponse response = testUtil.doMethod ("GET", "/paramwithmaj/plop");
assertEquals (200, response.status);
assertEquals ("echo: plop", response.body);
}

@Test public void unauthorized () throws Exception {
public void unauthorized () throws Exception {
UrlResponse response = testUtil.doMethod ("GET", "/protected/resource");
assertTrue (response.status == 401);
}

@Test public void notFound () throws Exception {
public void notFound () throws Exception {
UrlResponse response = testUtil.doMethod ("GET", "/no/resource");
assertTrue (response.status == 404);
}

@Test public void fileNotFound () throws Exception {
public void fileNotFound () throws Exception {
UrlResponse response = testUtil.doMethod ("GET", "/resource.html");
assertTrue (response.status == 404);
}

@Test public void postOk () {
public void postOk () {
UrlResponse response = testUtil.doMethod ("POST", "/poster", "Fo shizzy");
out.println (response.body);
assertEquals (201, response.status);
assertTrue (response.body.contains ("Fo shizzy"));
}

@Test public void patchOk () {
public void patchOk () {
UrlResponse response = testUtil.doMethod ("PATCH", "/patcher", "Fo shizzy");
out.println (response.body);
assertEquals (200, response.status);
assertTrue (response.body.contains ("Fo shizzy"));
}

@Test public void staticFile () throws Exception {
public void staticFile () throws Exception {
UrlResponse response = testUtil.doMethod ("GET", "/css/style.css");
assertEquals (200, response.status);
assertEquals ("/*\n * Content of css file\n */\n", response.body);
}

@Test public void externalStaticFile () throws Exception {
public void externalStaticFile () throws Exception {
UrlResponse response = testUtil.doMethod ("GET", "/externalFile.html");
assertEquals (200, response.status);
assertEquals ("Content of external file", response.body);
Expand Down
24 changes: 12 additions & 12 deletions http/src/test/java/sabina/it/GenericSecureIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.testng.annotations.Test;
import sabina.util.TestUtil;

public class GenericSecureIT {
@Test public class GenericSecureIT {

private static TestUtil testUtil = new TestUtil ();

Expand Down Expand Up @@ -70,65 +70,65 @@ public class GenericSecureIT {
testUtil.waitForStartup ();
}

@Test public void getHi () {
public void getHi () {
UrlResponse response = testUtil.doMethodSecure ("GET", "/hi");
assertEquals (200, response.status);
assertEquals ("Hello World!", response.body);
}

@Test public void hiHead () {
public void hiHead () {
UrlResponse response = testUtil.doMethodSecure ("HEAD", "/hi");
assertEquals (200, response.status);
assertEquals ("", response.body);
}

@Test public void getHiAfterFilter () {
public void getHiAfterFilter () {
UrlResponse response = testUtil.doMethodSecure ("GET", "/hi");
assertTrue (response.headers.get ("after").contains ("foobar"));
}

@Test public void getRoot () {
public void getRoot () {
UrlResponse response = testUtil.doMethodSecure ("GET", "/");
assertEquals (200, response.status);
assertEquals ("Hello Root!", response.body);
}

@Test public void echoParam1 () {
public void echoParam1 () {
UrlResponse response = testUtil.doMethodSecure ("GET", "/shizzy");
assertEquals (200, response.status);
assertEquals ("echo: shizzy", response.body);
}

@Test public void echoParam2 () {
public void echoParam2 () {
UrlResponse response = testUtil.doMethodSecure ("GET", "/gunit");
assertEquals (200, response.status);
assertEquals ("echo: gunit", response.body);
}

@Test public void echoParamWithMaj () {
public void echoParamWithMaj () {
UrlResponse response = testUtil.doMethodSecure ("GET", "/paramwithmaj/plop");
assertEquals (200, response.status);
assertEquals ("echo: plop", response.body);
}

@Test public void unauthorized () throws Exception {
public void unauthorized () throws Exception {
UrlResponse urlResponse = testUtil.doMethodSecure ("GET", "/protected/resource");
assertTrue (urlResponse.status == 401);
}

@Test public void notFound () throws Exception {
public void notFound () throws Exception {
UrlResponse urlResponse = testUtil.doMethodSecure ("GET", "/no/resource");
assertTrue (urlResponse.status == 404);
}

@Test public void postOk () {
public void postOk () {
UrlResponse response = testUtil.doMethodSecure ("POST", "/poster", "Fo shizzy");
out.println (response.body);
assertEquals (201, response.status);
assertTrue (response.body.contains ("Fo shizzy"));
}

@Test public void patchOk () {
public void patchOk () {
UrlResponse response = testUtil.doMethodSecure ("PATCH", "/patcher", "Fo shizzy");
out.println (response.body);
assertEquals (200, response.status);
Expand Down
Loading

0 comments on commit c505a7d

Please sign in to comment.