Friday, November 16, 2007

MyISERN 1.3 review

Today's assignment is MyIsern-1.3-review. I'm reviewing the team orange code, which is here.


Installation

The package I downloaded was myisern-orange-1.3-1.0.1114.zip. There was no installation guide, but it installed fine using the installation process we're all using. I had to look up a few things that would have been in the installation guide, but the installation worked.

JUnit, Checkstyle, PMD, and FindBugs tasks all ran cleanly.

Code Format and Conventions

Nothing really leapt out at me as far as coding conventions, except that some of the comments are out of date.

I would recommend that they split things up into multiple ActionBeans rather than just expanding the ActionBean from StackStripes to do everything, but that's not really a coding convention.

Test Cases

Emma Coverage summary

class:14%(3/22)
method:1%(3/215)
block:1%(16/3032)
line:1%(7/773)

White Box & Black Box

There are two tests: a test that the welcome page can be retrieved and a test that is turned off and prints out the number of records loaded from XML.

From both a white box and a black box perspective, this is rather limited testing.

Breaking

  • Trying to list or edit anything causes a null pointer exception
  • Trying to add a record causes a file not found exception. I think this one is caused by looking for the files in the wrong place. The directory is supposed to named .myisern, not myisern. (It's supposed to have a period at the beginning.)

User Interface

I was able to use the interface.

It uses very little screen space and works fine with only a quarter of my (small) screen.

The one thing I would improve is the labeling of the links on the main page. The links should probably contain the name of what they do ("edit" or "add"), so you don't have to look up at the table headers to figure it out. It seems like a small thing, but it threw me off at first.

Summary and Lessons Learned

This version of MyISERN doesn't do any of the things it's supposed to, but it's a pleasant improvement over the last piece of software I reviewed.

It compiles, installs, and runs. It doesn't run correctly, but that didn't get in the way of writing a review.

It will, however, need to run correctly by Monday.

Wednesday, November 14, 2007

MyIsern 1-3

Today's assignment is MyISERN-1.3.


This assignment doesn't actually say that we're supposed to do a log entry, but I thought I'd give the reviewers an easy place to download it from.

Unfortunately, not all tasks were fully completed.

The New Group

My new partner is Randy Cox.

I was the member who had been working on the same codebase from before, and I had been working on the model (which was the part we were keeping as we switched to a Stripes webapp) so I again worked on the model in this increment and Randy handled the view and controller.

The Work

The model changes were more extensive than I had originally hoped, mostly because of the concurrency issues. In the single user version, the model was just returning a reference to an object that it continued to hold onto and give out to. Even if the methods returning the references were synchronized, the lock would be released by the time the caller started actually using the object, which could then change out from under it.

I suppose I made that part of it harder than it should have been by trying to have a solution that I liked rather than one that just did the job. I ended up with something that worked and only sort of pleased me.

I also did the installation guide and the"sanity check" report, which technically means that I did a little of the view and controller, but not really. That part was just a thin wrapper around a report generated in the model. Randy did all the username/password, ActionBeans, etc.

The Result

There are still two unfinished parts of the program:

  1. Test coverage is poor
  2. There's some kind of problem with displaying list values

The poor test coverage is largely from try-catch blocks that never catch and a large method we're not calling because we're not sure if we want to keep it or not.

The list problem has something to do with list data (years, affiliatedResearchers, and other things where you can have more than one) not showing up on the page.

Randy mentioned it while I was finishing up the "sanity check" report, and I ran a few tests. The data was getting from the model into the ActionBean but not from there to the page. At the time, the problem looked (to me) like the JSP code wasn't making any calls to retrieve the data. I'm not sure where he went from there, but I think it was left unresolved. It's definitely something we should talk about in person and try to sort out by Monday.

Monday, November 5, 2007

Web App Questions

  1. Explain in your own words the meaning of the web "request-response cycle".

    The client sends a request to the server, the server processes the request, the server sends a response, the client figures out what it wants next and sends another request, and the cycle repeats.

  2. Explain how servlets facilitate processing of the request-response cycle.

    Servlets to the server-side processing of the cycle. There's a framework that handles receiving the request and sending the response, so you can complete the server side by creating servlets.

  3. How do you login to the Tomcat Manager?

    Go to the top level page on the server and click the link.

  4. What is the Tomcat Manager used for in the StackStripes application?

    It's not really used inside the application, but the build system uses it to deploy and undeploy the application (and check that it has access to deploy and undeploy).

  5. What is the directory and file layout of an installed web application like StackStripes? (This is NOT the same as the directory and file layout of the StackStripes distribution!)

    At the top level, there are JSP pages and the WEB-INF directory. WEB-INF contains web.xml and the directories classes and lib.

  6. How do you build a war directory structure in Ant? Where is this accomplished in the StackStripes application?

    The directory structure is built by creating a WEB-INF sub-directory and putting web.xml, classes, and lib. In StackStripes, there's a web directory that already contains the complete structure and the build system copies it to create the directory used to make the war file.

  7. How do you install a war directory in a running Tomcat server? What information does the Ant task need to accomplish this?

    GET http://server:port/manager/deploy?path=servpath&war=fullpath where servpath is the path of the installed application within the server (e.g. /stackstripes) and fullpath is the full path of the war directory to install.

  8. What is the "Model2" architecture? What are its advantages?

    The design is split into a model, view, and controller. The view is what the user directly interacts with, the model stores the data, and the controller responds to what what the user does to the view by doing things to the model and view.

    The advantages are that it's fairly easy to understand and it separates three types of things that are different, allowing you to do things with just one of them at a time. For example, you can create the view using JSTL, and the controller by writing Java.

  9. What are JSP pages? How are they related to servlets?

    JSP pages are web page servlets (or parts of servlets) written in a way that directly includes the static parts of the page.

  10. Why is there a delay when retrieving a JSP page for the first time? Where is the Java code for that page stored?

    It has to be converted to Java and compiled. The Java code is stored under a long, complicated path inside the directory where Tomcat is installed.

  11. What are JSTL tags? Why are they useful? What is an example JSTL tag from the StackStripes system?

    JSTL is an extension to JSP that adds a lot of tags to take the place of inline Java, making it more of a templating system. For example, the forEach tag is used to iterate through the stack.

  12. What are Stripes tags? Why are they useful? What is an example Stripes tag from the StackStripes system?

    Additional tags defined by Stripes. They're useful because they hook in to Stripes. For example the stripes form tag sets up a form that is also connected to an "action bean" by Stripes.

  13. What is HttpUnit? How is it different from JUnit? Why is it useful? What is an example use of HttpUnit from the StackStripes system?

    HttpUnit is a library for doing HTTP requests and responses. JUnit is a unit testing framework. HttpUnit is useful because it lets you do HTTP requests and responses from inside the JUnit tests, so that that the tests pass or fail based on the HTTP results. For example, some of our JUnit tests use HttpUnit to retrieve pages and check the contents of the table which displays the stack.

  14. What needed to be changed in order to implement the Double It button? What didn't need to be changed? What did you learn about the MVC design pattern from this exercise?

    Added doubleIt to the model, doubleIt to the controller (action bean), and added DoubleItForm to the view (JSP). If your framework isn't very smart, you can find yourself doing everything three times.

  15. What are the equivalence classes that need to be tested for the Double It button?

    Empty stack and non-empty stack. You might also divide non-empty stack into one element and many elements.

  16. Provide two screen images of your new StackStripes application with the Double It button, one showing the page before and one showing the page after hitting the "Double It" button.

  17. What is the singleton design pattern? What is an example of its use in StackStripes? Why is it needed?

    Only one instance of a class can ever be created. The StackStripes model is a singleton because we want all users to share one stack.

  18. Some of the StackStripes tests exercise code on the "server side", while others exercise code on the "client" side. Which test classes exercise code on the "server", and which exercise code on the "client"? How does Emma deal with this to create appropriate coverage data?

    TestStackActionBean tests code while it is deployed, and TestStackModel tests code while it is not deployed. Emma records the results in two files and then combines them.

  19. Running 'ant -f junit.build.xml' results in the following target invocations: tomcat.check, tomcat.undeploy, compile, war, tomcat.deploy, junit.tool, junit.report, junit. Explain what each of these targets do.

    • tomcat.check checks that the server is up and we can log in
    • tomcat.undeploy undeploys the application
    • compile runs javac
    • war creates a war file
    • tomcat.deploy deploys the application to the server
    • junit.tool runs the JUnit tests
    • junit.report generates a report on the JUnit tests
    • junit depends on junit.tool and junit.report (rather pointless if you ask me -- junit.report could, and probably should, depend on junit.tool and be the default)

Sunday, November 4, 2007

Stack Stripes Extension

Today's assignment is StackStripesExtension. My extended stack is here.


All tasks completed.

Difficulties

Nothing was particularly difficult. I ran into the problem that John Hauge brought up, but I had already seen Shaoxuan Zhang's reply, so I just started tomcat from the project directory.

I also had to add $CATALINA_HOME/bin to my PATH so that emma.build.xml could find it.

Coverage

Emma Coverage summary
class:   100% (2/2)
method:  100% (18/18)
block:   97%  (142/146)
line:    94%  (39.6/42)

When I did Task 4, adding an HTTPUnit test, I noticed that the isEmpty model method wasn't being called anywhere in the controller. That pretty much ruled out 100% method coverage via HTTPUnit, so I settled for ninety-something.

In Task 5, I added tests of isEmpty to the non-HTTPUnit tests at the same time that I added tests for my new doubleIt method, so method coverage did end up at 100%.

Lessons Learned

Being told to shoot for 100% method coverage kills any desire to do black box testing. The tests we did for MyISERN-1.2 were much better, even though Emma reported less coverage.