Skip to content
Snippets Groups Projects
Commit b284f304 authored by Karkalašev, F. (Filip, Student B-TCS)'s avatar Karkalašev, F. (Filip, Student B-TCS)
Browse files

The exercises 5.3 - 7.0, making the web app and testing the table

parent bd4afa60
No related branches found
No related tags found
No related merge requests found
Showing
with 331 additions and 0 deletions
<component name="ArtifactManager">
<artifact type="war" name="bookquote:war">
<output-path>$PROJECT_DIR$/target</output-path>
<properties id="maven-jee-properties">
<options>
<module>bookquote</module>
<packaging>war</packaging>
</options>
</properties>
<root id="archive" name="bookQuote.war">
<element id="artifact" artifact-name="bookquote:war exploded" />
</root>
</artifact>
</component>
\ No newline at end of file
<component name="ArtifactManager">
<artifact type="exploded-war" name="bookquote:war exploded">
<output-path>$PROJECT_DIR$/target/bookQuote</output-path>
<properties id="maven-jee-properties">
<options>
<exploded>true</exploded>
<module>bookquote</module>
<packaging>war</packaging>
</options>
</properties>
<root id="root">
<element id="directory" name="WEB-INF">
<element id="directory" name="classes">
<element id="module-output" name="bookquote" />
</element>
</element>
<element id="directory" name="META-INF">
<element id="file-copy" path="$PROJECT_DIR$/target/bookQuote/META-INF/MANIFEST.MF" />
</element>
<element id="javaee-facet-resources" facet="bookquote/web/Web" />
</root>
</artifact>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="bookquote" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="bookquote" target="11" />
</bytecodeTargetLevel>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: javax.servlet:javax.servlet-api:3.1.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: org.apiguardian:apiguardian-api:1.1.2">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: org.junit.jupiter:junit-jupiter-api:5.8.2">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.8.2/junit-jupiter-api-5.8.2.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.8.2/junit-jupiter-api-5.8.2-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.8.2/junit-jupiter-api-5.8.2-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: org.junit.platform:junit-platform-commons:1.8.2">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.8.2/junit-platform-commons-1.8.2.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.8.2/junit-platform-commons-1.8.2-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.8.2/junit-platform-commons-1.8.2-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven: org.opentest4j:opentest4j:1.2.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
package nl.utwente.di.bookQuote;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/** Example of a Servlet that gets an ISBN number and returns the book price
*/
public class BookQuote extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
private Quoter quoter;
public void init() throws ServletException {
quoter = new Quoter();
}
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String docType =
"<!DOCTYPE HTML>\n";
String title = "Book Quote";
out.println(docType +
"<HTML>\n" +
"<HEAD><TITLE>" + title + "</TITLE>" +
"<LINK REL=STYLESHEET HREF=\"styles.css\">" +
"</HEAD>\n" +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1>" + title + "</H1>\n" +
" <P>ISBN number: " +
request.getParameter("isbn") + "\n" +
" <P>Price: " +
Double.toString(quoter.getBookPrice(request.getParameter("isbn"))) +
"</BODY></HTML>");
}
}
package nl.utwente.di.bookQuote;
import java.util.HashMap;
import java.util.Map;
public class Quoter {
private Map<String, Double> inputs;
public Quoter() {
inputs = new HashMap<String, Double>();
inputs.put("1", 10.0);
inputs.put("2", 45.0);
inputs.put("3", 20.0);
inputs.put("4", 35.0);
inputs.put("5", 50.0);
inputs.put("others", 0.0);
}
double getBookPrice(String isbn) {
return inputs.get(isbn);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>di.bookQuote</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description>BookQuote Servlet</description>
<display-name>BookQuote</display-name>
<servlet-name>BookQuote</servlet-name>
<servlet-class>nl.utwente.di.bookQuote.BookQuote</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>BookQuote</servlet-name>
<url-pattern>/bookQuote</url-pattern>
</servlet-mapping>
</web-app>
\ No newline at end of file
<!DOCTYPE HTML>
<!-- Front end for the webBookQuote Servlet. -->
<html lang="en">
<head>
<title>Web Book Quote Application</title>
<link rel="stylesheet" href="styles.css">
<meta charset="UTF-8">
</head>
<body>
<h1>Web Book Quote Application</h1>
<form ACTION="./bookQuote">
<p>Enter ISBN number: <input TYPE="TEXT" NAME="isbn"></p>
<input TYPE="SUBMIT">
</form>
</body>
</html>
BODY { background-color: WHITE }
H1 { color: PURPLE;
text-align: left;
font-size: 28px;
font-family: Arial, Helvetica, sans-serif;
font-weight: normal
}
.LARGER { font-size: 120% }
.TINY { font-size: 50% }
H2 { color: #440000;
text-align: left;
font-family: Arial, Helvetica, sans-serif
}
H3 { color: #440000;
text-align: left;
font-family: Arial, Helvetica, sans-serif
}
UL { margin-top: 0;
border-top-width: 0;
padding-top: 0
}
P { color: BLACK;
text-align: left;
font-size: 20px;
font-family: Arial, Helvetica, sans-serif
}
FORM { color: BLACK;
text-align: left;
font-size: 20px;
font-family: Arial, Helvetica, sans-serif
}
PRE { font-size: 105%;
}
CODE { font-size: 105%;
}
.TOC { font-size: 90%;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif
}
TH.COLORED { background-color: #FFAD00
}
TR.COLORED { background-color: #FFAD00
}
TH.TITLE { background-color: #EF8429;
font-size: 40px;
font-family: Arial, Helvetica, sans-serif;
}
A:hover { color: red }
package nl.utwente.di.bookQuote;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/* Test the Quoter */
public class TestQuoter {
@Test
public void testBook1() throws Exception {
Quoter quoter = new Quoter();
double price = quoter.getBookPrice("1");
Assertions.assertEquals(10.0, price, 0.0, "Price of book 1");
}
}
File added
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment