Files
uni/year4/semester2/CT414/assignments/assignment1/latex/CT414-Assignment-01.tex

123 lines
5.2 KiB
TeX

%! TeX program = lualatex
\documentclass[a4paper]{article}
% packages
\usepackage{microtype} % Slightly tweak font spacing for aesthetics
\usepackage[english]{babel} % Language hyphenation and typographical rules
\usepackage[final, colorlinks = true, urlcolor = black, linkcolor = black]{hyperref}
\usepackage{changepage} % adjust margins on the fly
\usepackage{fontspec}
\setmainfont{EB Garamond}
\setmonofont[Scale=MatchLowercase]{Deja Vu Sans Mono}
\usepackage{minted}
\usemintedstyle{algol_nu}
\usepackage{xcolor}
\usepackage{pgfplots}
\pgfplotsset{width=\textwidth,compat=1.9}
\usepackage{caption}
\newenvironment{code}{\captionsetup{type=listing}}{}
\captionsetup[listing]{skip=0pt}
\setlength{\abovecaptionskip}{5pt}
\setlength{\belowcaptionskip}{5pt}
\usepackage[yyyymmdd]{datetime}
\renewcommand{\dateseparator}{--}
\usepackage{titlesec}
% \titleformat{\section}{\LARGE\bfseries}{}{}{}[\titlerule]
% \titleformat{\subsection}{\Large\bfseries}{}{0em}{}
% \titlespacing{\subsection}{0em}{-0.7em}{0em}
%
% \titleformat{\subsubsection}{\large\bfseries}{}{0em}{$\bullet$ }
% \titlespacing{\subsubsection}{1em}{-0.7em}{0em}
% margins
\addtolength{\hoffset}{-2.25cm}
\addtolength{\textwidth}{4.5cm}
\addtolength{\voffset}{-3.25cm}
\addtolength{\textheight}{5cm}
\setlength{\parskip}{0pt}
\setlength{\parindent}{0in}
% \setcounter{secnumdepth}{0}
\begin{document}
\hrule \medskip
\begin{minipage}{0.295\textwidth}
\raggedright
\footnotesize
\begin{tabular}{@{}l l}
Name: & Andrew Hayes \\
Student ID: & 21321503 \\
E-mail: & \href{mailto://a.hayes18@universityofgalway.ie}{\texttt{a.hayes18@universityofgalway.ie}} \\
\end{tabular}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\centering
\vspace{0.4em}
\LARGE
\textsc{ct414} \\
\end{minipage}
\begin{minipage}{0.295\textwidth}
\raggedleft
\today
\end{minipage}
\medskip\hrule
\begin{center}
\normalsize
Assignment 1: Java RMI
\end{center}
\hrule
\section{Testing}
To run and test the code, I wrote a short shell script based off those provided in RMI Compute Server Example code provided on Canvas which compiles the code and launches three terminals: one running the \mintinline{shell}{rmiregistry}, one running the \mintinline{java}{ApplicationServer}, and one running the \mintinline{java}{ApplicationClient}.
\begin{code}
\inputminted[texcl, mathescape, linenos, breaklines, frame=single]{shell}{../code/src/run.sh}
\caption{\mintinline{shell}{run.sh}}
\end{code}
\begin{figure}[H]
\centering
\includegraphics[width=\textwidth]{./images/screenshot.png}
\caption{Screenshot of all four terminal windows. From left to right, top to bottom: the window running \mintinline{shell}{run.sh}, the window running the \mintinline{shell}{rmiregistry}, the window running the \mintinline{java}{ApplicationServer}, \& the window running the \mintinline{java}{ApplicationClient}}
\end{figure}
As can be seen in the \mintinline{java}{ApplicationClient} terminal window above, I tested the application by logging in with username \& password \verb|admin|, and filling in application details.
The details entered were saved into a file called \verb|Michael_D_Higgins.txt|, with the name of the file being the applicant's name with all whitespace replaced with underscores (to avoid any spaces-in-filename headaches).
\begin{figure}[H]
\centering
\includegraphics[width=\textwidth]{./images/michaeld.png}
\caption{Contents of the saved application form file}
\end{figure}
The output file contained all the questions and answers from the application form, as expected.
\subsection{\mintinline{java}{InvalidCredentialsException}}
To test that an appropriate exception was thrown when a user attempted to login with invalid credentials, I tried a few invalid logins.
The desired behaviour, as can be seen in the output screenshot below, was that the \mintinline{java}{ApplicationHandlerImpl} class would throw an \mintinline{java}{InvalidCredentialsException} when the \mintinline{java}{ApplicationClient} invoked its \mintinline{java}{ApplicationHandler.login()} method.
The \mintinline{java}{ApplicationClient} would then handle this exception gracefully, prompting the user to re-enter their login details until they entered valid details.
\begin{figure}[H]
\centering
\includegraphics[width=\textwidth]{./images/inalidcred.png}
\caption{Failed logins with invalid credentials, handled gracefully }
\end{figure}
\subsection{\mintinline{java}{InvalidSessionIDException}}
Since my \mintinline{java}{ApplicationHandlerImpl} class would reject session IDs older than 60 seconds (the low value being chosen for testing purposes, a more practical value would be, say, 10 minutes), I simply waited 60 seconds after logging in to answer the very last question, ensuring that the form submission method would be invoked with an expired session ID, the desired behaviour (as can be seen in the output below) being that the client would receive an \mintinline{java}{InvalidSessionIDException}, and gracefully terminate the program.
\begin{figure}[H]
\centering
\includegraphics[width=\textwidth]{./images/invalidsessionid.png}
\caption{Session ID expiring after 60 seconds}
\end{figure}
\end{document}