Skip to content

Java servlet used to parse phone numbers using google's libphonenumber library.

License

Notifications You must be signed in to change notification settings

PatMB30/ParsePNum

 
 

Repository files navigation

ParsePNum

Java servlet used to parse phone numbers using google's libphonenumber library.

What is it?

This is a Java servlet created with Eclipse Java EE IDE for Web Developers version Oxygen. 2 Release (4.7.2). The servlet's main page contains 2 web forms to receive input either as a string or a file. Once the input is received, the servlet will output a JSON string containing all Canadian phone numbers found from the input.

Quick Links

How to deploy?

What you will need:

Instructions for Windows deployment:

  1. Install the eclipse IDE into any folder
  2. Install the Apache Tomcat into any folder
  3. Start the eclipse IDE.
  4. Select a workspace.
  5. Once inside eclipse, choose File -> Import -> Web -> WAR file
  6. Import the WAR file you downloaded from "How to deploy?" Link Here to WAR file picture
  7. Use "ParsePNum" as name of the web project and set Target Runtime to Apache Tomcat v7.0. Choose Finish. picture

To create a new Apache Server:

  1. Go to Server window with Window -> Show View -> Server
  2. Click on link to create a new server picture
  3. Choose Tomcat v7.0 Server, and set host name as localhost. Select Next. picture
  • Note: If this is your first time, you may need to tell the IDE where the Tomcat installation directory is. Use Browse button and search for your Apache Tomcat installation folder.
    picture
  1. Right click the newly created server, choose "Add and Remove..." picture
  2. Add the servlet ParsePNum from "Available" to "Configured".
  3. The server is ready to be deployed. Read below for usage.

Usage

The first thing to do is to start the apache server.

Simply go to Window -> Show View -> Server

Next start the server from the server menu. Here's a screenshot:

picture

After the server is running, to access the servlet's main page, go to http://localhost:8080/ParsePNum/phonenumberparse.jsp. This assumes you started server on port 8080.

Here's a screenshot of the main page: picture

Currently, there are 3 ways to use ParsePNum.

  1. GET from servlet page

    • Simply type text into the GET textbox and click submit.
  2. POST from servlet page

    • Select a file to upload and click submit.
  3. GET by editting URL on address bar

    • Edit the address bar as per screenshot below.

    picture

Unit testing

The tests are in src/PhonenumbersTest.java. They are written using JUnit and Mockito libraries. Currently, the only method being tested is doGet() method.

To start a unit test:

  • Open PhonenumbersTest.java
  • Select Run from main menu -> Run As -> JUnit Test

picture

To add more test cases, simply create a new test# method, and add that test method onto the main method.

To Do

  • Unit testing for doPost()
    • Ideally using Spring Test Framework or JUnit with Mockito
  • Include more test cases
  • Automated testing using Travis CI
  • Parsing PDF or MS Word files
  • Add instructions to deploy in other OS (linux, macOS)

License

This license is under BSD-2 clause. You can find out more at BSD

Also, IANAL.

About

Java servlet used to parse phone numbers using google's libphonenumber library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%