java

bracechumpInternet and Web Development

Feb 5, 2013 (4 years and 4 months ago)

206 views

Project Overview

Overview


REPortal2


Overview


Demo


Testing REPortal


jUnit


Selenium


REportal is a service
-
based reverse
engineering portal.


Users may upload code to REportal and
perform RE analysis, without needing to
install, configure and run individual tools.


REportal 1.0 was based on Java Servlets, but
the presentation layer was tightly coupled to
the tools.


The tools quickly became obsolete, and others
simply didn’t work, hindering the functionality.


Browser wars were a big problem during this
time as well.


REportal 2.0 is based on web services.
This was chosen because the architecture
decouples the interface from the tools.


Relationships between tools are based on
data via message passing in XML.


This makes it easy to


Maintain existing tools.


Add new (legacy) tools by simply turning
them into a service.


Take advantage of SOA security, automatic
binding, distributed computing, and other
features.


REportal Application Layer


Bunch Wrapper


Static Analyzer


Source Code Browser


Text Search


Aspect Instrumentation


Project Manager


Database Layer


REportal Application Layer


This is the presentation layer, where JSP
pages reside. The JSP pages invoke
services to render functionality.


Bunch Wrapper


This is used by several services, whenever
graphical data or an MDG is produced.
Bunch Wrapper clusters the graph and
returns a new graph.


Static Analyzer


This is based on the BAT Static Analyzer for
Java 1.5.


Given Java class file(s), BAT creates an
XML repository with source code
relationships that exist between the entities.


This needs to be improved to a database
model for scalability.


REportal queries the repository via
XQuery and XSLT.


Source Code Browser


This is based on the Sorcerer source code
browser tool. It provides a cross
-
referenced
source index.


Currently, REportal downloads a zip file of
web pages to the user.


Ultimately, using Ajax, we will display this
content on the fly, rendering a seamless
user interface!


Text Search


Grep


Aspect Instrumentation


Using aspects, it is possible to instrument
code to trace function calls.


Doing this, we yield an MDG graph that can
be viewed or clustered to show runtime
slices.


Project Manager and Database Layer


Using a database, tracks user logins and
projects, including their location on the file
system.


They don’t have to reside on the same
machine, but the database provides absolute
file paths on the Project Manager service’s
file system.

REPortal Demo


Create a new user


Add a project


Perform Some Analysis

Unit Testing REPortal


Reportal is configured to work with jUnit


Each service has a “test” directory


Once test files are placed in there they
can be executed by “ant test”

Testing the Web
Interface


Want to simulate a real user


Clicking buttons entering forms


Getting back feedback


Can use Selenium for this

What is Selenium?


Javascript framework that runs in your web
-
browser


Works anywhere Javascript is supported


Hooks for many other languages


Java, Ruby, Python


Can simulate a user navigating through
pages and then assert for specific marks on
the pages

Where to get it?


You can use Selenium
-
Core and customize
everything


But it is easier to just get a Firefox plug
-
in
“Selenium
-
IDE” that helps you “record” test
cases


You can record how an app is being used and
then play back those recordings followed by
asserts


Get everything at: www.openqa.org/selenium/

Selenium IDE

The root of web
application you
want to test

The list of
actions in the
actual test case
to execute

The log of the
events that were
executed,
including any
errors or warning
that may have
occurred

Selenium IDE

Execution
Commands

Try the test in
the Web based
TestRunner

Reference of the
currently selected
command

Record test
actions

Specify
commands,
including asserts

Test Creation Demo


Create test case to sign up for a
REPortal2 account

Start REPortal

Connect to the Server

Hit the Record Button

Type in Username and Password

Hit submit

Hit record
again to
stop

Right
-
clicking on
highlighted text
will bring out
more options

Add asserts on unique text
strings to make sure the
page loaded successfully

Creating a Test Suite


Selenium IDE is useful in
creating a test case, but
we want a suite of test
cases


Since we are using jUnit
already, why not use it
again

Creating a Test Suite


Selenium IDE can
produce code for
individual test cases


However, the code needs
to be slightly altered to
run

Creating a Test Suite


Need to add set
-
up
to specify what
browser to use and
where to connect

import junit.framework.*;import org.openqa.selenium.server.*;import
com.thoughtworks.selenium.*;import java.util.regex.Pattern;public
class NewTest extends TestCase { private Selenium selenium;
public void setUp() throws Exception { String url =
Environment.URL; selenium = new DefaultSelenium("localhost",


SeleniumServer.getDefaultPort(), "*firefox", url);
selenium.start(); } protected void tearDown() throws Exception {
selenium.stop(); } public void testNew() throws Exception {
selenium.open("/REportal2/home.jsp");
selenium.type("document.login.userId", "max");
selenium.type("document.login.password", "max");
selenium.click("document.login.login");
selenium.waitForPageToLoad("30000"); selenium.click("link=Add
Project"); selenium.waitForPageToLoad("30000");
assertTrue(selenium.isTextPresent("AAdding a Project (max):")); }}

Creating a Test Suite


Actual test case
from selenium

import junit.framework.*;import org.openqa.selenium.server.*;import
com.thoughtworks.selenium.*;import java.util.regex.Pattern;public
class NewTest extends TestCase { private Selenium selenium;
public void setUp() throws Exception { String url =
Environment.URL; selenium = new DefaultSelenium("localhost",


SeleniumServer.getDefaultPort(), "*firefox", url);
selenium.start(); } protected void tearDown() throws Exception {
selenium.stop(); } public void testNew() throws Exception {
selenium.open("/REportal2/home.jsp");
selenium.type("document.login.userId", "max");
selenium.type("document.login.password", "max");
selenium.click("document.login.login");
selenium.waitForPageToLoad("30000"); selenium.click("link=Add
Project"); selenium.waitForPageToLoad("30000");
assertTrue(selenium.isTextPresent("AAdding a Project (max):")); }}

Creating a Test Suite


Selenium RC acts as a HTTP
proxy server that will run the test
cases


jUnit test cases force a web
-
browser to connect through the
proxy, execute test cases, and
collect results


To execute Selenium test cases in
our environment you are provided
with a configured test suite:


start the proxy server


compile tests


run tests

java
-
jar selenium
-
server.jar

make

make run

TestRunner Demo


Execute Tests created inside Selenium
IDE