Thursday, April 28, 2011

J2EE Part 1

J2EE - Java 2 Enterprise Edition is one of the 3 java platforms, the other being J2SE and J2ME. It is set of specifications or standards consisting of many APIs useful for building java based enterprise applications. At such it is not some software to be installed but is just a bundle of many technologies having set of APIs.

J2EE applications are java applications that span over LAN, WAN and broader. They are used when it comes to distributed environment and disparate systems and also when in need to make use of its technologies.

J2EE technologies are broadly classified into two categories:
1. Component technologies
2. Service technologies

Kinds of J2EE Components:
Client Side Comonents -> includes applets.
Web Components -> includes servelets and JSPs
Business Components -> includes EJB
Web components and Business components run on Server Side...

Kinds of J2EE Services:
JNDI -> Java Naming and Directory service
JMS -> java Messaging Service
JTA -> Java Transaction API
JAAS -> Java Authentication and Authorization Service
Java Mail

J2EE is meant for building the 3 layers of java based enterprise application. The layers being:
1. Presentation Layer
2. Service/Business Layer
3. Data Access Layer


We have been talking on java based enterprise application... To clear you on it:
A computer application used to manage business services of an enterprise is called enterprise application and if the application is coded in java and is deployed into J2EE compliant application server then it becomes java based. :)
Any enterprise application generally covers 4 main tasks:
1. providing user interface(UI) to the user.
2. processing of data according to some business logic(rules)
3. interacting with database(data access)
4. storing of data
These tasks are logically divided into 4 layers
                                     A. Presentation layer
                                     B. Business/Service layer
                                     C. Data Access Layer
                                     D. Data Layer


J2EE developers are responsible for the first 3 layers while the data layer is the responsibility of database administrator(DBA).
Hope you are clear on the layers... Remember they are just the logical division. Now coming to actual or physical division...
The physical partition of enterprise application is known as 'tier'. The enterprise application can be single-tier, two-tier, three-tier, n-tier or distributed-tier depending on number of computing systems on which the layers are installed.

Lets talk more on layers... 
Presentation Layer is the user interface part of the application. If the app is web based then Servelets and JSPs are used to build it on server side. The main design patterns used in this layer are Front Controller, Model-View-Controller(MVC), Composite View.
Business/Service Layer is nothing but a code that processes data according to business logic(rules). Some important design patterns used in this layer are Service Locator, Business Delegate, Session Facade. Job of service layer is to receive the business request from presentation layer or some other service layer, communicate with data access layer to get the enterprise data, process that data using defined business rules, return the result to the requested component
Data Access layer is again a code which communicates with the database. It performs CRUD(Create, Read, Update, Delete). Therefore it is just a code communicating with database specific APIs such as JDBC. The design patterns used are Data Access Object(DTO), Data Transfer Object(DTO), Value Object. Can you guess what its job is??? It receives request from service layer, communicates with the database to perform the requested operations and sends the result back to service layer. 

So now you clear on J2EE basics :)

Let me tell you more on business/service layer and then you can have your coffee break :)
We already know what is the job of service layer but in order for it to implement it, it needs some capabilities... like transactional capability, distributed computing capability, security implementation capability.    
To have these capabilities we make use of J2EE technologies(both components and services). Just scroll up and read the first three paragraphs... This should make it clear for you. 

Coffee Break
J2EE is not a software but is a set of standards/specifications having APIs to make java enterprise app.
Provides a standard for developing multi-tier enterprise services.
It is useful for building apps that span over LAN and needs to make use of its technologies.
It is platform independent.
J2EE technologies include components and services.
Business logic is organized into reusable components... so J2EE is helpful.
Layers are logical divisions of J2EE while tiers are physical partitions depending on number of computing systems used.
The J2EE platform uses a multitiered distributed application model. Application logic is divided into components according to function, and the various application components that make up a J2EE application are installed on different machines depending on the tier in the multitiered J2EE environment to which the application component belongs.

Wednesday, April 20, 2011

HTTP - More...

We already are familiar with the basic idea and structure of HTTP. Well now lets move ahead... with gear 1 so no worries :)

Remember HTTP is a request/response protocol... !!! If 'no' then read the earlier post - 5 minutes of basics !!!

The key elements of HTTP request are:
> HTTP method
> Form parameters

HTTP method is nothing but the action the client wants to perform. The client may want to get something from the server or to post something to it - some data that the server can use for responding accordingly or can save it in a database for further utility. HTTP method specifies what 'action' the client performs. Basic HTTP methods are GET, POST, PUT, DELETE.

URL of course is for accessing the page the client wishes to... of the server !!!

Form parameters are some data that the client wishes to send to the server.

The key elements of HTTP response are:
> Status code
> Content - type
> Content

Status code for example can be something like 301, 302, etc... or something like 'not found', 'ok', etc...
This is information about the status of the request whether it was successful or not. So the response will tell the client the status of the request.

Content - type can be 'text', 'picture', 'html', etc... Just to specify the type of content to the client so that it can accordingly display it.

Finally the content - this is the actual text file, image or html that the server sends to the client for the request it has made.

Sunday, April 17, 2011


The term 'middleware' is generally used in the context of distributed systems. It is a software that helps two software components talk and share data. When the software components on both sides are applications, then we refer to this type of middleware as Enterprise Application Integration(EAI). Actually it acts like a glue between software components or software component and a network. It could glue application to database managers. A better way to define is to say that it 'mediates' between an application and network or between software components and software facilities as required in heterogeneous computing platform.
A simple example of middleware is Object Request Broker(ORB) that manges communication between objects. 
Middleware is used in context with High Level Architecture(HLA) that applies to many distributed systems. It is sometimes called 'plumbing' because it connects two applications and passes data between them. 
It was intended basically for following purposes:
1. For linking newer applications to older systems or applications.
2. Connecting multiple applications over a network and hence facilitating distributed processing.
3. To provide interaction between network and application or service
4. To provide interaction on network transparently.
5. To be independent of network services and always available

You could think of more uses but these are the basic ones...

A typical example of Middleware can be TCP/IP stack for telecommunications.

Some basic types of middleware are:
1. Message Oriented Middleware: Transactions or event notifications are sent between disparate systems via messages
2. Object Middleware: Consists of Object Request Brokers for communication between the objects. It is possible for applications to send objects and request services in object oriented system.
3. Remote Procedure Call(RPC) Middleware: used to call procedures on remote system. It can be synchronous or asynchronous.

There are many others... 

Coffee Break
Middleware is a glue between software components and network.
Software components can be service or application.
When glued between two applications it is called EAI
It is also called 'plumbing'
It is used in context with distributed systems.
Mainly needed for disparate applications/systems.
Serves message passing, data sharing and interaction between disparate disparate applications/systems.

HTTP - Getting Started

HTTP - HyperText Transfer Protocol
It is a request response oriented protocol which defines the way how a client and server talk to each other. By protocol we mean some set of rules. The client is typically a web browser.

So how it works?
Well, the client sends a request for some resource to a server and the server sends it back a response corresponding to the resource requested for. This is the basic idea.

 The request is also called as 'query'. The server generally makes use of a database to find the resource that the client has requested for.

Clients and Servers both know HTTP and communicate over it. For this the client (web browser) must know  
html. If the response of a server to client's request is an html document then it needs to send it using HTTP protocol.

Bottom line is: A web server uses HTTP to talk to client.

HTTP runs on top of TCP/IP protocol to ensure that the files that are being sent as a response are received at destination as a complete file although it is broken up into chunks when sent. Anyways thats all going into networking and transport layer protocol so we wont talk more on it. :) Just remember that HTTP is an application layer protocol.

Basic structure of HTTP conversation is an easy guess now !!! - request/response sequence : client requests and server responds...

Coffee Break
HTTP is the protocol clients and servers use on the web to communicate.
The server uses HTTP to send html to client. So html is a part of HTTP response. :)
html tells the client (browser) how to display contents to the user.
HTTP is an application layer protocol.

Friday, April 15, 2011

Whitebox Testing

Hope you have already read about blackbox testing. Whitebox testing, as the name suggests :) is a test design where focus is primarily on internal details of the software. Internal structure of the application is checked to see HOW the implementation is done. The tester therefore can know if you have used the correct logic (so you dont get to hardcode or use redundancy). This is essential because it guarantees that the output is the expected result over a larger set of valid inputs as compared to in blackbox testing where it is practically impossible to test over so many inputs (imagine running the software thousand times if the input is supposed to be name of employees in the company having 1000 employees !!!).

Now you are already getting the idea, so lets move further.

Since internal details are focussed upon, the tester needs to know the programming language used. The tester chooses inputs and then checks paths through the source code to know if it is implemented correctly rather than just checking the output.

You must be wondering why blackbox testing is required if whitebox testing can cover its purpose. Does it? Really??? If your answer is yes then i suggest you to continue reading.

In whitebox testing, the internal structure of code, implementation part is focussed upon to see HOW the software works but it doesn't focus on the specification and requirement details. Whitebox testing can uncover many errors but then again unimplemented part cannot be detected. Whether any specification or requirement is missing or not is found by blackbox testing only.

While white-box testing can be applied at the unit, integration and system levels of the software testing process, it is usually done at the unit level. Synonyms for whitebox testing: Glassbox testing, openbox testing.

For a complete software testing process, both blackbox and whitebox testing is required.
Advantages of whitebox testing are: helps in optimizing code, extra lines of code can be removed (hidden defects)
Disadvantages of whitebox testing are: Tester needs to know the programming language used, he needs to know the internal structure too, hidden implementation cannot be detected.

Coffee Break
Characteristics of whitebox testing:
Internal Structure
Tester should know programming language
Paths in code are checked
Implementation logic is checked
Statements, Paths and Decisions in the code is checked

Blackbox Testing

Here the testing is done from the viewpoint of user and not the software developer. Therefore only the functionalities of the software is checked to see if the software is doing what it was initially intended to do. In this way one can know if the aim of the software is achieved or not.
Blackbox test design treats the system as a black box... :) how obvious!!! well treating as black box implies that it doesn't explicitly use knowledge about system's internal structure. Black-box test design is usually described as focusing on testing functional requirements. Synonyms for blackbox include:  behavioral, functional, opaque-box, and closed-box.

The Primary focus of the tester is to find out WHAT the software is doing, whether it complies to its intended aim and whether it gives the expected results... and all this without caring HOW the software is doing it. Therefore, he never looks at the programming code. He only makes use of the software specifications and requirements. 
The tester determines valid and invalid input and checks if corresponding results are the expected results or not.

Sometimes blackbox testing is used for 'behavioral testing' but there is a slight difference between them. While blackbox testing strictly forbids use of internal details of the system, behavioral testing only discourages it.

Now you are clear with the basic concept of blackbox testing .

Also blackbox testing occurs throughout the software development and Testing life cycle i.e in Unit, Integration, System, Acceptance and regression testing stages. Lets look at some benefits of blackbox testing. The software designer and tester are independent of each other. Therefore the test is unbiased.Tester need not have knowledge of any programming language. Testing is done from the viewpoint of the user.Testing can be done as soon as specifications are complete.
Some disadvantages could be: Test cases are difficult to design.Test can be redundant if the designer has already run a test case Testing for all inputs is unrealistic. It consumes a lot of time and there is a possibility of missing some inputs. Also it is difficult to identify all inputs for the software.

Coffee Break 
Characteristics of blackbox testing:
No Internal Detail
Does system meet business requirements
Tester and Designer independent
User point of view
Blackbox testing focuses on application externals. We can call it requirement based or specification based.