Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lincolnthree committed Apr 18, 2012
1 parent 6ec312a commit 8a897a6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 32 deletions.
Expand Up @@ -8,10 +8,10 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ocpsoft.prettyfaces.annotation.basic.convert.UppercaseConverter;
import org.ocpsoft.prettyfaces.test.PrettyFacesTestBase;
import org.ocpsoft.prettyfaces.test.PrettyFacesTest;

@RunWith(Arquillian.class)
public class QueryParameterConversionTest extends PrettyFacesTestBase
public class QueryParameterConversionTest extends PrettyFacesTest
{

@Deployment(testable = false)
Expand All @@ -26,15 +26,13 @@ public static WebArchive getDeployment()
@Test
public void testQueryParameterConversion() throws Exception
{
String page = getPageAsString("/page?q=abcd");
assertTrue(page.contains("Query Parameter = [ABCD]"));
assertTrue(get("/page?q=abcd").getResponseContent().contains("Query Parameter = [ABCD]"));
}

@Test
public void testQueryParameterConversionWithMissingParameter() throws Exception
{
String page = getPageAsString("/page");
assertTrue(page.contains("Query Parameter = []"));
assertTrue(get("/page").getResponseContent().contains("Query Parameter = []"));
}

}
Expand Up @@ -7,10 +7,10 @@
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ocpsoft.prettyfaces.test.PrettyFacesTestBase;
import org.ocpsoft.prettyfaces.test.PrettyFacesTest;

@RunWith(Arquillian.class)
public class QueryParameterTest extends PrettyFacesTestBase
public class QueryParameterTest extends PrettyFacesTest
{

@Deployment(testable = false)
Expand All @@ -24,22 +24,19 @@ public static WebArchive getDeployment()
@Test
public void testQueryParameterBinding() throws Exception
{
String page = getPageAsString("/page?q=christian");
assertTrue(page.contains("Query Parameter = [christian]"));
assertTrue(get("/page?q=christian").getResponseContent().contains("Query Parameter = [christian]"));
}

@Test
public void testMissingQueryParameterValue() throws Exception
{
String page = getPageAsString("/page");
assertTrue(page.contains("Query Parameter = []"));
assertTrue(get("/page").getResponseContent().contains("Query Parameter = []"));
}

@Test
public void testMultipleQueryParameterValues() throws Exception
{
String page = getPageAsString("/page?q=abc&q=123");
assertTrue(page.contains("Query Parameter = [abc]"));
assertTrue(get("/page?q=abc&q=123").getResponseContent().contains("Query Parameter = [abc]"));
}

}
Expand Up @@ -3,21 +3,17 @@
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ocpsoft.prettyfaces.annotation.basic.validate.EvenLengthValidator;
import org.ocpsoft.prettyfaces.test.PrettyFacesTestBase;
import org.ocpsoft.prettyfaces.test.PrettyFacesTest;

@RunWith(Arquillian.class)
public class QueryParameterValidationTest extends PrettyFacesTestBase
public class QueryParameterValidationTest extends PrettyFacesTest
{

@Deployment(testable = false)
Expand All @@ -32,26 +28,21 @@ public static WebArchive getDeployment()
@Test
public void testValidQueryParameter() throws Exception
{
String page = getPageAsString("/page?q=abcd");
assertTrue(page.contains("Query Parameter = [abcd]"));
assertTrue(get("/page?q=abcd").getResponseContent().contains("Query Parameter = [abcd]"));
}

@Test
public void testInvalidQueryParameter() throws Exception
{
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(getFullUrl("/page?q=abc"));
HttpResponse response = client.execute(get);
assertEquals(404, response.getStatusLine().getStatusCode());
assertEquals(404, get("/page?q=abc").getStatusCode());
}

@Test
@Ignore
// doesn't work for some reason
public void testMissingQueryParameter() throws Exception
{
String page = getPageAsString("/page");
assertTrue(page.contains("Query Parameter = []"));
assertTrue(get("/page").getResponseContent().contains("Query Parameter = []"));
}

}
Expand Up @@ -36,9 +36,8 @@ public void testValidationSuccess() throws Exception
public void testValidationFailed() throws Exception
{
HttpAction<HttpGet> action = get("/validate/abc");
String responseContent = action.getResponseContent();
Assert.assertEquals(404, action.getStatusCode());
Assert.assertTrue(responseContent.contains("404"));
Assert.assertTrue(action.getResponseContent().contains("404"));
}

}
Expand Up @@ -52,8 +52,6 @@ public static WebArchive getBaseDeployment()
.setWebXML("jetty-web.xml")
.addAsWebInfResource("faces-config.xml", "faces-config.xml");

System.out.println(deployment.toString(true));

return deployment;

}
Expand Down

0 comments on commit 8a897a6

Please sign in to comment.