make all tests pass
git-svn-id: http://google-refine.googlecode.com/svn/trunk@945 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
eff2d95cd1
commit
ef6f03694d
@ -3,7 +3,7 @@
|
|||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="src" path="tests/server/src"/>
|
<classpathentry kind="src" path="tests/server/src"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||||
<classpathentry kind="lib" path="webapp/WEB-INF/lib/butterfly-trunk-r14.jar" />
|
<classpathentry kind="lib" path="webapp/WEB-INF/lib/butterfly-trunk.jar" sourcepath="webapp/WEB-INF/lib-src/butterfly-trunk-sources.jar"/>
|
||||||
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-codec-1.4.jar" sourcepath="webapp/WEB-INF/lib-src/commons-codec-1.4-sources.jar"/>
|
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-codec-1.4.jar" sourcepath="webapp/WEB-INF/lib-src/commons-codec-1.4-sources.jar"/>
|
||||||
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-lang-2.5.jar" sourcepath="webapp/WEB-INF/lib-src/commons-lang-2.5-sources.jar"/>
|
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-lang-2.5.jar" sourcepath="webapp/WEB-INF/lib-src/commons-lang-2.5-sources.jar"/>
|
||||||
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-fileupload-1.2.1.jar" sourcepath="webapp/WEB-INF/lib-src/commons-fileupload-1.2.1-sources.jar"/>
|
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-fileupload-1.2.1.jar" sourcepath="webapp/WEB-INF/lib-src/commons-fileupload-1.2.1-sources.jar"/>
|
||||||
@ -35,5 +35,9 @@
|
|||||||
<classpathentry kind="lib" path="webapp/WEB-INF/lib/slf4j-api-1.5.6.jar" sourcepath="webapp/WEB-INF/lib/slf4j-api-1.5.6.jar"/>
|
<classpathentry kind="lib" path="webapp/WEB-INF/lib/slf4j-api-1.5.6.jar" sourcepath="webapp/WEB-INF/lib/slf4j-api-1.5.6.jar"/>
|
||||||
<classpathentry kind="lib" path="webapp/WEB-INF/lib/slf4j-log4j12-1.5.6.jar" sourcepath="webapp/WEB-INF/lib-src/slf4j-log4j12-1.5.6-sources.jar"/>
|
<classpathentry kind="lib" path="webapp/WEB-INF/lib/slf4j-log4j12-1.5.6.jar" sourcepath="webapp/WEB-INF/lib-src/slf4j-log4j12-1.5.6-sources.jar"/>
|
||||||
<classpathentry kind="lib" path="webapp/WEB-INF/lib/log4j-1.2.15.jar" sourcepath="webapp/WEB-INF/lib-src/log4j-1.2.15-sources.jar"/>
|
<classpathentry kind="lib" path="webapp/WEB-INF/lib/log4j-1.2.15.jar" sourcepath="webapp/WEB-INF/lib-src/log4j-1.2.15-sources.jar"/>
|
||||||
|
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-collections-3.2.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-io-1.4.jar"/>
|
||||||
|
<classpathentry kind="lib" path="webapp/WEB-INF/lib/rhino-1.7R2.jar"/>
|
||||||
|
<classpathentry kind="lib" path="webapp/WEB-INF/lib/velocity-1.5.jar"/>
|
||||||
<classpathentry kind="output" path="webapp/WEB-INF/classes"/>
|
<classpathentry kind="output" path="webapp/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -18,12 +18,8 @@ public class GridworksServletStub extends GridworksServlet {
|
|||||||
//requirement of extending HttpServlet, not required for testing
|
//requirement of extending HttpServlet, not required for testing
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public void wrapDoGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
|
public void wrapService(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
|
||||||
super.doGet(request, response);
|
super.service(request, response);
|
||||||
}
|
|
||||||
|
|
||||||
public void wrapDoPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
|
|
||||||
super.doPost(request, response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String wrapGetCommandName(HttpServletRequest request){
|
public String wrapGetCommandName(HttpServletRequest request){
|
||||||
|
@ -31,18 +31,21 @@ public class GridworksServletTests extends GridworksTest {
|
|||||||
GridworksServletStub SUT = null;
|
GridworksServletStub SUT = null;
|
||||||
|
|
||||||
//variables
|
//variables
|
||||||
String TEST_COMMAND_NAME = "test-command";
|
final static private String TEST_COMMAND_NAME = "test-command";
|
||||||
String TEST_COMMAND_PATH = "/test-command/foobar";
|
final static private String TEST_COMMAND_PATH = "/command/test-command/foobar";
|
||||||
String BAD_COMMAND_PATH = "/command-does-not-exist";
|
final static private String BAD_COMMAND_PATH = "/command-does-not-exist";
|
||||||
|
|
||||||
//mocks
|
final static private String POST = "POST";
|
||||||
|
final static private String GET = "GET";
|
||||||
|
|
||||||
|
// mocks
|
||||||
HttpServletRequest request = null;
|
HttpServletRequest request = null;
|
||||||
HttpServletResponse response = null;
|
HttpServletResponse response = null;
|
||||||
Command command = null;
|
Command command = null;
|
||||||
|
|
||||||
|
|
||||||
@BeforeMethod
|
@BeforeMethod
|
||||||
public void SetUp() {
|
public void SetUp() throws ServletException {
|
||||||
request = mock(HttpServletRequest.class);
|
request = mock(HttpServletRequest.class);
|
||||||
response = mock(HttpServletResponse.class);
|
response = mock(HttpServletResponse.class);
|
||||||
command = mock(Command.class);
|
command = mock(Command.class);
|
||||||
@ -72,9 +75,10 @@ public class GridworksServletTests extends GridworksTest {
|
|||||||
@Test
|
@Test
|
||||||
public void doGetRegressionTest(){
|
public void doGetRegressionTest(){
|
||||||
whenGetCommandNameThenReturn(TEST_COMMAND_PATH);
|
whenGetCommandNameThenReturn(TEST_COMMAND_PATH);
|
||||||
|
whenGetMethodThenReturn(GET);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SUT.wrapDoGet(request, response);
|
SUT.wrapService(request, response);
|
||||||
} catch (ServletException e) {
|
} catch (ServletException e) {
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -94,9 +98,10 @@ public class GridworksServletTests extends GridworksTest {
|
|||||||
@Test
|
@Test
|
||||||
public void doGetReturnsError404WhenCommandNotFound(){
|
public void doGetReturnsError404WhenCommandNotFound(){
|
||||||
whenGetCommandNameThenReturn(BAD_COMMAND_PATH);
|
whenGetCommandNameThenReturn(BAD_COMMAND_PATH);
|
||||||
|
whenGetMethodThenReturn(GET);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SUT.wrapDoGet(request, response);
|
SUT.wrapService(request, response);
|
||||||
} catch (ServletException e) {
|
} catch (ServletException e) {
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -112,9 +117,10 @@ public class GridworksServletTests extends GridworksTest {
|
|||||||
@Test
|
@Test
|
||||||
public void doPostRegressionTest(){
|
public void doPostRegressionTest(){
|
||||||
whenGetCommandNameThenReturn(TEST_COMMAND_PATH);
|
whenGetCommandNameThenReturn(TEST_COMMAND_PATH);
|
||||||
|
whenGetMethodThenReturn(POST);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SUT.wrapDoPost(request, response);
|
SUT.wrapService(request, response);
|
||||||
} catch (ServletException e) {
|
} catch (ServletException e) {
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -134,9 +140,10 @@ public class GridworksServletTests extends GridworksTest {
|
|||||||
@Test
|
@Test
|
||||||
public void doPostReturns404WhenCommandNotFound(){
|
public void doPostReturns404WhenCommandNotFound(){
|
||||||
whenGetCommandNameThenReturn(BAD_COMMAND_PATH);
|
whenGetCommandNameThenReturn(BAD_COMMAND_PATH);
|
||||||
|
whenGetMethodThenReturn(POST);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SUT.wrapDoPost(request, response);
|
SUT.wrapService(request, response);
|
||||||
} catch (ServletException e) {
|
} catch (ServletException e) {
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -152,7 +159,7 @@ public class GridworksServletTests extends GridworksTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getCommandNameHandlesBadCommandName(){
|
public void getCommandNameHandlesBadCommandName(){
|
||||||
|
|
||||||
when(request.getPathInfo()).thenReturn("/this-command-has-no-trailing-slash");
|
when(request.getPathInfo()).thenReturn("/command/this-command-has-no-trailing-slash");
|
||||||
|
|
||||||
Assert.assertEquals("this-command-has-no-trailing-slash", SUT.wrapGetCommandName(request));
|
Assert.assertEquals("this-command-has-no-trailing-slash", SUT.wrapGetCommandName(request));
|
||||||
|
|
||||||
@ -163,8 +170,11 @@ public class GridworksServletTests extends GridworksTest {
|
|||||||
protected void whenGetCommandNameThenReturn(String commandName){
|
protected void whenGetCommandNameThenReturn(String commandName){
|
||||||
when(request.getPathInfo()).thenReturn(commandName);
|
when(request.getPathInfo()).thenReturn(commandName);
|
||||||
}
|
}
|
||||||
|
protected void whenGetMethodThenReturn(String method){
|
||||||
|
when(request.getMethod()).thenReturn(method);
|
||||||
|
}
|
||||||
protected void verifyGetCommandNameCalled(){
|
protected void verifyGetCommandNameCalled(){
|
||||||
verify(request,times(1)).getPathInfo();
|
verify(request,times(2)).getPathInfo();
|
||||||
}
|
}
|
||||||
protected void verifyError404Called(){
|
protected void verifyError404Called(){
|
||||||
try {
|
try {
|
||||||
|
BIN
main/webapp/WEB-INF/lib-src/butterfly-trunk-sources.jar
Normal file
BIN
main/webapp/WEB-INF/lib-src/butterfly-trunk-sources.jar
Normal file
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user