@@ -25,7 +24,6 @@
Title |
Author |
Price |
-
In Stock |
Add Book |
@@ -34,11 +32,8 @@
${ item.getTitle() } |
${ item.getAuthor() } |
|
-
10 |
Edit
Delete |
- <%--
Edit
- Delete | --%>
diff --git a/src/main/webapp/BookForm.jsp b/src/main/webapp/BookForm.jsp
index 353c2a51..c71ce22d 100644
--- a/src/main/webapp/BookForm.jsp
+++ b/src/main/webapp/BookForm.jsp
@@ -11,37 +11,19 @@
diff --git a/src/main/webapp/BookList.jsp b/src/main/webapp/BookList.jsp
index ad0950cb..ac40509a 100644
--- a/src/main/webapp/BookList.jsp
+++ b/src/main/webapp/BookList.jsp
@@ -14,7 +14,6 @@
@@ -25,16 +24,15 @@
Title |
Author |
Price |
-
|
-
+
+
diff --git a/src/main/webapp/ShoppingCart.jsp b/src/main/webapp/ShoppingCart.jsp
deleted file mode 100644
index fab13b4b..00000000
--- a/src/main/webapp/ShoppingCart.jsp
+++ /dev/null
@@ -1,45 +0,0 @@
-<%@ page language="java" contentType="text/html; charset=UTF-8"
- pageEncoding="UTF-8"%>
-<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
-<%@ taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt" %>
-
-
-
-
Codestin Search App
-
-
-
-
-
-
-
-
-
-
- List of Books
-
- | Title |
- Author |
- Price |
- In Stock |
- Add Book |
-
-
-
-
- | ${ item.getTitle() } |
- ${ item.getAuthor() } |
- |
- 10 |
- Edit Delete |
-
-
-
-
-
-
-
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index dc5c5392..449850f0 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -8,23 +8,11 @@
Archetype Created Web Application
- LoginServlet
- LoginServlet
-
- com.pluralsight.LoginServlet
-
-
- LoginServlet
- /LoginServlet
-
-
-
- ControllerServlet
- com.pluralsight.ControllerServlet
+ ControllerServlet
+ com.pluralsight.ControllerServlet
-
- ControllerServlet
- /books/*
+ ControllerServlet
+ /books/*
diff --git a/src/test/java/com/pluralsight/module1/Module1_Task1_IT.java b/src/test/java/com/pluralsight/module1/Module1_Task1_IT.java
index 2be2c318..0144e088 100644
--- a/src/test/java/com/pluralsight/module1/Module1_Task1_IT.java
+++ b/src/test/java/com/pluralsight/module1/Module1_Task1_IT.java
@@ -1,4 +1,5 @@
-package com.pluralsight;
+package com.pluralsight.module1;
+import com.pluralsight.*;
import org.junit.After;
import org.junit.Before;
@@ -34,7 +35,7 @@ public void tearDown() {
// Verify the edit and delete hrefs, in BookAdmin.jsp contain the id
@Test
- public void module1_task1() {
+ public void _task1() {
url_contains_id("Delete");
url_contains_id("Edit");
}
diff --git a/src/test/java/com/pluralsight/module1/Module1_Task2_IT.java b/src/test/java/com/pluralsight/module1/Module1_Task2_IT.java
deleted file mode 100644
index 67f38d61..00000000
--- a/src/test/java/com/pluralsight/module1/Module1_Task2_IT.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.pluralsight;
-
-import static org.junit.Assert.*;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-
-import org.junit.BeforeClass;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-import org.powermock.reflect.Whitebox;
-import java.lang.reflect.Method;
-
-import java.io.*;
-
-public class Module1_Task2_IT {
-
- private ControllerServlet controllerServlet;
-
- // @Before
- // public void setUp() throws Exception {
- // controllerServlet = new ControllerServlet();
- // }
-
- // Verify the deleteBook() method exists in ControllerServlet
- @Test
- public void module1_task2() throws Exception {
- Method method = null;
- try {
- method = Whitebox.getMethod(ControllerServlet.class,
- "deleteBook", HttpServletRequest.class, HttpServletResponse.class);
- } catch (Exception e) {}
-
- String errorMsg = "private void deleteBook() does not exist in ControllerServlet";
- assertNotNull(errorMsg, method);
- }
-}
diff --git a/src/test/java/com/pluralsight/module1/Module1_Task2_and_3_IT.java b/src/test/java/com/pluralsight/module1/Module1_Task2_and_3_IT.java
new file mode 100644
index 00000000..422a4075
--- /dev/null
+++ b/src/test/java/com/pluralsight/module1/Module1_Task2_and_3_IT.java
@@ -0,0 +1,79 @@
+package com.pluralsight.module1;
+import com.pluralsight.*;
+
+import static org.junit.Assert.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+
+import org.junit.BeforeClass;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import org.junit.runner.RunWith;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.reflect.exceptions.*;
+
+import org.powermock.reflect.Whitebox;
+import java.lang.reflect.Method;
+
+import java.io.*;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(ControllerServlet.class)
+public class Module1_Task2_and_3_IT {
+
+ private ControllerServlet controllerServlet;
+ private Method method = null;
+
+ @Before
+ public void setUp() throws Exception {
+ try {
+ method = Whitebox.getMethod(ControllerServlet.class,
+ "deleteBook", HttpServletRequest.class, HttpServletResponse.class);
+ } catch (Exception e) {}
+ }
+
+ // Verify the deleteBook() method exists in ControllerServlet
+ @Test
+ public void _task2() throws Exception {
+ String errorMsg = "private void deleteBook() does not exist in ControllerServlet";
+ assertNotNull(errorMsg, method);
+ }
+
+ @Test
+ public void _task3() throws Exception {
+ String tempID = "0";
+ String errorMsg = "private void deleteBook() does not exist in ControllerServlet";
+ assertNotNull(errorMsg, method);
+
+ ControllerServlet controllerServlet = PowerMockito.spy(new ControllerServlet());
+ boolean called_deleteBook = false;
+ HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+ HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
+
+ try {
+ Mockito.when(request.getPathInfo()).thenReturn("/delete");
+ //PowerMockito.doNothing().when(controllerServlet, "deleteBook", request, response);
+ Mockito.when(request.getParameter("id")).thenReturn(tempID);
+ } catch (MethodNotFoundException e) {}
+
+ try {
+ controllerServlet.doGet(request, response);
+ try {
+ PowerMockito.verifyPrivate(controllerServlet)
+ .invoke("deleteBook", request, response);
+ called_deleteBook = true;
+ } catch (Throwable e) {}
+ } catch (Exception e) {}
+
+ errorMsg = "After action \"" + "/delete" +
+ "\", did not call deleteBook().";
+ assertTrue(errorMsg, called_deleteBook);
+ }
+}
diff --git a/src/test/java/com/pluralsight/module1/Module1_Task3_IT.java b/src/test/java/com/pluralsight/module1/Module1_Task3_IT.java
deleted file mode 100644
index fd1217b1..00000000
--- a/src/test/java/com/pluralsight/module1/Module1_Task3_IT.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.pluralsight;
-
-import static org.junit.Assert.*;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-
-import org.junit.BeforeClass;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-import org.junit.runner.RunWith;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-import org.powermock.reflect.exceptions.*;
-
-import java.io.*;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(ControllerServlet.class)
-public class Module1_Task3_IT extends Mockito{
- static String tempID = "0";
-
- // Verify the deleteBook() method exists in ControllerServlet
- // Since it's private need to verify the lines of code get called
- // through the /delete action in doGet()
- @Test
- public void module1_task3() throws Exception {
- ControllerServlet controllerServlet = PowerMockito.spy(new ControllerServlet());
- boolean called_deleteBook = false;
- HttpServletRequest request = mock(HttpServletRequest.class);
- HttpServletResponse response = mock(HttpServletResponse.class);
-
- try {
- when(request.getPathInfo()).thenReturn("/delete");
- //PowerMockito.doNothing().when(controllerServlet, "deleteBook", request, response);
- when(request.getParameter("id")).thenReturn(tempID);
- } catch (MethodNotFoundException e) {}
-
- // try {
- // controllerServlet.doGet(request, response);
- // try {
- // PowerMockito.verifyPrivate(controllerServlet)
- // .invoke("deleteBook", request, response);
- // called_deleteBook = true;
- // } catch (Throwable e) {}
- // } catch (Exception e) {}
-
- String errorMsg = "After action \"" + "/delete" +
- "\", did not call deleteBook().";
- assertTrue(errorMsg, called_deleteBook);
- }
-}
diff --git a/src/test/java/com/pluralsight/module1/Module1_Task4_IT.java b/src/test/java/com/pluralsight/module1/Module1_Task4_IT.java
index e07fb726..cc51128e 100644
--- a/src/test/java/com/pluralsight/module1/Module1_Task4_IT.java
+++ b/src/test/java/com/pluralsight/module1/Module1_Task4_IT.java
@@ -1,4 +1,5 @@
-package com.pluralsight;
+package com.pluralsight.module1;
+import com.pluralsight.*;
import static org.junit.Assert.*;
import org.junit.Test;
@@ -10,7 +11,7 @@ public class Module1_Task4_IT {
// Verify the deleteBook() method exists in BookDAO
@Test
- public void module1_task4() throws Exception {
+ public void _task4() throws Exception {
Method method = null;
try {
diff --git a/src/test/java/com/pluralsight/module1/Module1_Task5_IT.java b/src/test/java/com/pluralsight/module1/Module1_Task5_IT.java
index 24d973ad..e271b466 100644
--- a/src/test/java/com/pluralsight/module1/Module1_Task5_IT.java
+++ b/src/test/java/com/pluralsight/module1/Module1_Task5_IT.java
@@ -1,4 +1,5 @@
-package com.pluralsight;
+package com.pluralsight.module1;
+import com.pluralsight.*;
import static org.junit.Assert.*;
import java.sql.Connection;
@@ -22,9 +23,9 @@
@PrepareForTest({DriverManager.class, PreparedStatement.class, BookDAO.class})
public class Module1_Task5_IT {
- // Verify the deleteBook() method exists in BookDAO
+ // Verify the deleteBook() in BookDAO calls prepareStatement()
@Test
- public void module1_task5() throws Exception {
+ public void _task5() throws Exception {
Method method = null;
String sql = "DELETE FROM book WHERE id = ?";
Connection mockConnection = Mockito.mock(Connection.class);
diff --git a/src/test/java/com/pluralsight/module1/Module1_Task6_IT.java b/src/test/java/com/pluralsight/module1/Module1_Task6_IT.java
index 488c858d..7cf42715 100644
--- a/src/test/java/com/pluralsight/module1/Module1_Task6_IT.java
+++ b/src/test/java/com/pluralsight/module1/Module1_Task6_IT.java
@@ -1,4 +1,5 @@
-package com.pluralsight;
+package com.pluralsight.module1;
+import com.pluralsight.*;
import static org.junit.Assert.*;
import java.sql.Connection;
@@ -24,7 +25,7 @@ public class Module1_Task6_IT {
// Verify the deleteBook() method exists in BookDAO
@Test
- public void module1_task6() throws Exception {
+ public void _task6() throws Exception {
Method method = null;
String sql = "DELETE FROM book WHERE id = ?";
Connection spyConnection = Mockito.mock(Connection.class);
diff --git a/src/test/java/com/pluralsight/module1/Module1_Task7_and_8_IT.java b/src/test/java/com/pluralsight/module1/Module1_Task7_and_8_IT.java
index 56c83fa4..1461c702 100644
--- a/src/test/java/com/pluralsight/module1/Module1_Task7_and_8_IT.java
+++ b/src/test/java/com/pluralsight/module1/Module1_Task7_and_8_IT.java
@@ -1,4 +1,5 @@
-package com.pluralsight;
+package com.pluralsight.module1;
+import com.pluralsight.*;
import static org.junit.Assert.*;
import javax.servlet.http.HttpServletRequest;
@@ -56,17 +57,18 @@ public void setUp() throws Exception {
"deleteBook", HttpServletRequest.class, HttpServletResponse.class);
} catch (Exception e) {}
- String errorMsg = "private void deleteBook() does not exist in ControllerServlet";
- assertNotNull(errorMsg, deleteMethod);
-
- try {
- controllerServlet.doGet(request, response);
- } catch (Exception e) {}
+ // String errorMsg = "private void deleteBook() does not exist in ControllerServlet";
+ // assertNotNull(errorMsg, deleteMethod);
+ if (deleteMethod != null) {
+ try {
+ controllerServlet.doGet(request, response);
+ } catch (Exception e) {}
+ }
}
// Verify deleteBook() in ControllerServlet is complete
@Test
- public void module1_task7() throws Exception {
+ public void _task7() throws Exception {
String errorMsg = "private void deleteBook() does not exist in ControllerServlet";
assertNotNull(errorMsg, deleteMethod);
@@ -78,7 +80,8 @@ public void module1_task7() throws Exception {
for (Invocation anInvocation : invocations) {
methodsCalled.add(anInvocation.getMethod().getName());
}
- assertTrue(methodsCalled.contains("deleteBook"));
+ errorMsg = "The ControllerServlet deleteBook() method was not called.";
+ assertTrue(errorMsg, methodsCalled.contains("deleteBook"));
try {
verify(request, atLeast(1)).getParameter("id");
@@ -91,7 +94,7 @@ public void module1_task7() throws Exception {
}
@Test
- public void module1_task8() throws Exception {
+ public void _task8() throws Exception {
String errorMsg = "private void deleteBook() does not exist in ControllerServlet";
assertNotNull(errorMsg, deleteMethod);
try {
diff --git a/src/test/java/com/pluralsight/module2/Module2_Task11_thru_14_IT.java b/src/test/java/com/pluralsight/module2/Module2_Task11_thru_14_IT.java
index 8d3c3206..23ee70d1 100644
--- a/src/test/java/com/pluralsight/module2/Module2_Task11_thru_14_IT.java
+++ b/src/test/java/com/pluralsight/module2/Module2_Task11_thru_14_IT.java
@@ -1,4 +1,5 @@
-package com.pluralsight;
+package com.pluralsight.module2;
+import com.pluralsight.*;
import org.junit.After;
import org.junit.Before;
@@ -25,6 +26,7 @@ public class Module2_Task11_thru_14_IT {
HtmlPage firstPage = null;
HtmlPage nextPage = null;
HtmlForm form = null;
+ String formErrorMsg = "We can’t find a