Siri
Siri
import java.io.FileOutputStream;
public class FileOutputStreamExample {
public static void main(String args[]){
try{
FileOutputStream fout=new FileOutputStream("D:\\testout.txt");
fout.write(65);
fout.close();
System.out.println("success...");
}catch(Exception e){System.out.println(e);}
}
}
import java.io.FileInputStream;
public class DataStreamExample {
public static void main(String args[]){
try{
FileInputStream fin=new FileInputStream("D:\\testout.txt");
int i=fin.read();
System.out.print((char)i);
fin.close();
}catch(Exception e){System.out.println(e);}
}
}
Serialization in Java is a mechanism of writing the state of an object into a byte-stream. It is mainly
used in Hibernate, RMI, JPA, EJB and JMS technologies.
The reverse operation of serialization is called deserialization where byte-stream is converted into
an object. The serialization and deserialization process is platform-independent, it means you can
serialize an object on one platform and deserialize it on a different platform.
For serializing the object, we call the writeObject() method of ObjectOutputStream class, and for
dese Deserialization is the process of reconstructing the object from the serialized state. It is the
reverse operation of serializationrialization we call the readObject() method
of ObjectInputStream class.
Type safety:
One of the most significant benefits of using generics in Java is that it enhances the type safety of your code. With
generics, you can specify the type of data that a class, method, or interface can work with. This ensures that only the
specified data types are passed to the code, preventing runtime errors and improving the reliability of your program.
Code reuse:
Generics in Java allow you to write code that is more reusable. By specifying a type parameter in a generic class, method,
or interface, you can create code that can work with multiple data types. This reduces code duplication, improves code
maintainability, and makes your code more efficient.
Compile-time checking:
Another significant advantage of using generics in Java is that it enables compile-time checking of your code. This
means that errors can be detected early in the development process, rather than at runtime. This not only improves the
reliability of your program but also saves time and effort in debugging.
Improved performance:
Generics in Java can also improve the performance of your program. By using generics, the compiler can optimize your
code, reducing the number of casts and improving the overall performance of your program.
Greater flexibility:
Generics in Java provide greater flexibility in your programming. By allowing you to specify the type of data that a
class, method, or interface can work with, generics make it possible to create highly adaptable and flexible code. This
can be especially useful when working with complex data structures or when you need to write code that can work with
multiple data types.
HashSet is a generic class of the Java collection framework. It extends AbstractSet and implements the Set interface.
It creates a collection that uses a hash table for storage. The hash table stores the information by using
the hashing mechanism.
Hashing uses the informational content to determine a unique value which is known as hash code. It is used as the index
in which data is stored that is associated with the key. The transformation of the key into hash code performed
automatically. The benefit of hashing is that it allows the execution time of add, contain, remove, and size operation to
remain constant even for large sets. Its time complexity for the operation search, insert, and delete is O(1).
TreeSet is a class of Java collection framework that extends AbstractSet and implements the Set, NavigableSet, and
SortedSet interface. It creates a collection that uses a tree for storage.
TreeSet is a generic class of the Java collection framework. It implements the Set interface. It uses TreeMap internally
to store the TreeSet elements. By default, it sorts the elements in natural order (ascending order). The order of sorting
depends on the Comparator that we have parsed. If no Comparator is parsed, it sorts the elements in the natural order.
Its performance is slow in comparison to HashSet because TreeSet sorts the elements after each insertion and deletion
operation.
It uses two methods comaperTo() or compare() to compare the elements. It is to be noted that the implementation of
TreeSet is not synchronized. It means that it is not thread-safe. The implementation must be synchronized externally if
multiple threads accessing a TreeSet concurrently and a thread try to modify the TreeSet.
It does not allow to store null elements. It throws NullPointerException if we try to insert a null element. It requires
more memory than TreeSet because it also maintains the comparator to sort the elements.
Its time complexity for the operation search, insert, and delete is O(log n) which is much higher than HashSet. It uses
a self-balancing BST (Red-Black Tree) to implement the TreeSet.
The java.io package contains nearly every class you might ever need to perform input and
output (I/O) in Java. All these streams represent an input source and an output destination.
The stream in the java.io package supports many data such as primitives, object, localized
characters, etc.
A stream can be defined as a sequence of data. There are two kinds of Streams −
JDBC Driver is a software component that enables java application to interact with the database. There are
1. JDBC-ODBC bridge driver
2. Native-API driver (partially java driver)
3. Network Protocol driver (fully java driver)
4. Thin driver (fully java driver)
Advantages:
o easy to use.
o can be easily connected to any database.
Disadvantages:
o Performance degraded because JDBC method call is converted into the ODBC function calls.
o The ODBC driver needs to be installed on the client machine.
2) Native-API driver
The Native API driver uses the client-side libraries of the database. The driver converts JDBC method calls
written entirely in java.
Advantage:
Disadvantage:
o No client side library is required because of application server that can perform many tasks
like auditing, load balancing, logging etc.
Disadvantages:
4) Thin driver
The thin driver converts JDBC calls directly into the vendor-specific database protocol. That is why it is kn
language.
Advantage:
Disadvantage:
The Java Generics programming is introduced in J2SE 5 to deal with type-safe objects. It makes the code
stable by detecting the bugs at compile time.
Before generics, we can store any type of objects in the collection, i.e., non-generic. Now generics force the
java programmer to store a specific type of objects.
1) Type-safety: We can hold only a single type of objects in generics. It doesn?t allow to store other
objects.
3) Compile-Time Checking: It is checked at compile time so problem will not occur at runtime. The good
programming strategy says it is far better to handle the problem at compile time than runtime
1. import java.util.*;
2. class TestGenerics1{
3. public static void main(String args[]){
4. ArrayList<String> list=new ArrayList<String>();
5. list.add("rahul");
6. list.add("jai");
7. //list.add(32);//compile time error
8.
9. String s=list.get(1);//type casting is not required
10. System.out.println("element is: "+s);
11.
12. Iterator<String> itr=list.iterator();
13. while(itr.hasNext()){
14. System.out.println(itr.next());
15. }
16. }
17. }
The Collection in Java is a framework that provides an architecture to store and manipulate the group of objects.
Java Collections can achieve all the operations that you perform on a data such as searching, sorting, insertion,
manipulation, and deletion.
Java Collection means a single unit of objects. Java Collection framework provides many interfaces (Set, List, Queue,
Deque) and classes (ArrayList, Vector, LinkedList, PriorityQueue, HashSet, LinkedHashSet, TreeSet).
o It is optional.
The Collection framework represents a unified architecture for storing and manipulating a group of objects. It has:
2. Algorithm
Describe about Annotations and its types with example
Java Annotation is a tag that represents the metadata i.e. attached with class, interface, methods or fields to indicate
some additional information which can be used by java compiler and JVM.
Annotations in Java are used to provide additional information, so it is an alternative option for XML and Java marker
interfaces.
First, we will learn some built-in annotations then we will move on creating and using custom annotations.
There are several built-in annotations in Java. Some annotations are applied to Java code and some to other annotations.
o @Override
o @SuppressWarnings
o @Deprecated
o @Target
o @Retention
o @Inherited
o @Documented
@Override
@Override annotation assures that the subclass method is overriding the parent class method. If it is not so, compile
time error occurs.
Sometimes, we does the silly mistake such as spelling mistakes etc. So, it is better to mark @Override annotation that
provides assurity that method is overridden.
Types of Annotation
1. Marker Annotation
2. Single-Value Annotation
3. Multi-Value Annotation
1) Marker Annotation
An annotation that has no method, is called marker annotation. For example:
1. @interface MyAnnotation{}
2) Single-Value Annotation
An annotation that has one method, is called single-value annotation. For example:
1. @interface MyAnnotation{
2. int value();
3. }
1. @interface MyAnnotation{
2. int value() default 0;
3. }
How to apply Single-Value Annotation
1. @MyAnnotation(value=10)
3) Multi-Value Annotation
An annotation that has more than one method, is called Multi-Value annotation. For example:
1. @interface MyAnnotation{
2. int value1();
3. String value2();
4. String value3();
5. }
6. }
Lambda expression is a new and important feature of Java which was included in Java SE 8. It provides a clear and
concise way to represent one method interface using an expression. It is very useful in collection library. It helps to
iterate, filter and extract data from collection.
The Lambda expression is used to provide the implementation of an interface which has functional interface. It saves a
lot of code. In case of lambda expression, we don't need to define the method again for providing the implementation.
Here, we just write the implementation code.
Java lambda expression is treated as a function, so compiler does not create .class file.
Functional Interface
Lambda expression provides implementation of functional interface. An interface which has only one abstract method
is called functional interface. Java provides an anotation @FunctionalInterface, which is used to declare an interface
as functional interface.
2. Less coding.
Define Servlet.
Servlet technology is used to create a web application (resides at server side and generates a dynamic web page).
Servlet technology is robust and scalable because of java language. Before Servlet, CGI (Common Gateway Interface)
scripting language was common as a server-side programming language. However, there were many disadvantages to
this technology. We have discussed these disadvantages below.
There are many interfaces and classes in the Servlet API such as Servlet, GenericServlet, HttpServlet, ServletRequest,
ServletResponse, etc.
What is a Servlet?
o Servlet is an API that provides many interfaces and classes including documentation.
o Servlet is a class that extends the capabilities of the servers and responds to the incoming requests. It can respond
to any requests.
o Servlet is a web component that is deployed on the server to create a dynamic web page.
List the advantages of servlet
There are many advantages of Servlet over CGI. The web container creates threads for handling the
multiple requests to the Servlet. Threads have many benefits over the Processes such as they share
a common memory area, lightweight, cost of communication between the threads are low. The
advantages of Servlet are as follows:
1. Better performance: because it creates a thread for each request, not process.
2. Portability: because it uses Java language.
3. Robust: JVM manages Servlets, so we don't need to worry about the memory leak, garbage
collection, etc.
4. Secure: because it uses java language
o A session is used to temporarily store the information on the server to be used across multiple pages of
the website. It is the total time used for an activity. The user session starts when he logs-in to a particular
network application and ends when the user logs out from the application or shutdowns the system.
o When we work on an application over the internet, the webserver doesn't know the user because the HTTP
protocol does not maintain the state. The information provided by the user on one page of the application (Let's
say Home) will not be transferred to another page. To remove this limitation, sessions are used. Session gets
started whenever a visitor first enters a website.
o The user information is stored in session variables, and these variables can store any type of value or data type
of an Object.
o Session values are much secured as these are stored in binary form or encrypted form and can only be decrypted
at the server. The session values are automatically removed when the user shutdowns the system or logout from
the application. To store the values permanently, we need to store them in the database.
o Each session is unique for each user, and any number of sessions can be used in an application; there is no
limitation to it.
o The user is identified with the help of sessionID, which is a unique number saved inside the server. It is saved
as a cookie, form field, or UR
o A cookie is a small text file that is stored on the user's computer. The maximum file size of a cookie is 4KB.
It is also known as an HTTP cookie, web cookie, or internet Cookie. Whenever a user visits a website for the
first time, the site sends packets of data in the form of a cookie to the user's computer.
o The cookies help the websites to keep track of the user's browsing history or cart information when they visit
their sites.
o The information stored within cookies is not secure because this information is stored in text -format on the
client-side, which can be read by anyone.
o Cookies are created and shared between the server and browser with the help of an HTTP header.
o The path where the cookies are saved is decided by the browser, as Internet explorer usually stored them
in Temporal Internet File Folder.
o When we visit YouTube channel and search for some songs, next time whenever we visit YouTube, cookies
read our browsing history and shows similar songs or last played songs.
Servlet JSP
Servlets are faster as compared to JSP, as JSP is slower than Servlets, as the first
they have a short response time. step in the JSP lifecycle is the conversion
of JSP to Java code and then the
compilation of the code.
Servlets are harder to code, as here, the JSPs are easier to code, as here Java is
HTML codes are written in Java. coded in HTML.
In an MVC architecture, Servlets act as the In MVC architectures, the JSPs act as a
controllers. view to present the output to the users.
The Servlets are capable of accepting all The JSPs are confined to accept only the
types of protocol requests. HTTP requests.
Servlets require the users to enable the JSPs provide session management by
default sessions management explicitly, as default.
Servlets do not provide default session
management.
Servlets require us to implement the JSPs give us the flexibility to separate the
business logic and presentation logic in business logic from the presentation logic
the same servlet file. using javaBeans.
Servlets can handle extensive data JSPs cannot handle data processing
processing. functions efficiently.
Servlets do not provide the facility of JSPs can provide the facility of building
writing custom tags. the JSP tags easily, which can directly call
javaBeans.
Servlets are hosted and executed on Web JSP is compiled in Java Servlets before
Servers. their execution. After that, it has a similar
lifecycle as Servlets.
We need to import all the packages at the In JSPs, we can import packages
top of the Servlets. anywhere in the file.
The scripting elements provides the ability to insert java code inside the jsp. There are three types of
scripting elements:
o scriptlet tag
o expression tag
o declaration tag
A scriptlet tag is used to execute java source code in JSP. Syntax is as follows:
The code placed within JSP expression tag is written to the output stream of the response. So you need not
write out.print() to write data. It is mainly used to print the values of variable or method.
The jsp directives are messages that tells the web container how to translate a JSP page into the
corresponding servlet.
o page directive
o include directive
o taglib directive
The page directive defines attributes that apply to an entire JSP page.
o import
o contentType
o extends
o info
o buffer
The JSP taglib directive is used to define a tag library that defines many tags. We use the TLD (Tag
Library Descriptor) file to define the tags. In the custom tag section we will use this tag so it will be
better to learn it in custom tag.
There are many JSP action tags or elements. Each JSP action tag is used to perform some specific
tasks.
The action tags are used to control the flow between pages and to use Java Bean. The Jsp action
tags are given below.
jsp:param sets the parameter value. It is used in forward and include mostly.
jsp:fallback can be used to print the message if plugin is working. It is used in jsp:plugin.
JavaBean
o It should be Serializable.
o It should provide methods to set and get the values of the properties, known as getter and setter methods.
According to Java white paper, it is a reusable software component. A bean encapsulates many objects into one object
so that we can access this object from multiple places. Moreover, it provides easy maintenance.
A JavaBean property may be read, write, read-only, or write-only. JavaBean features are accessed through two methods
in the JavaBean's implementation class:
1. getPropertyName ()
For example, if the property name is firstName, the method name would be getFirstName() to read that property. This
method is called the accessor.
2. setPropertyName ()
For example, if the property name is firstName, the method name would be setFirstName() to write that property. This
method is called the mutator.
Advantages of JavaBean
The JSTL core tag provides variable support, URL management, flow control etc. The syntax used for including JSTL
core library in your JSP is:
Tags Description
c:out It display the result of an expression, similar to the way <%=...%> tag work.
c:import It Retrives relative or an absolute URL and display the contents to either a String in 'var',a
c:remove It is used for removing the specified scoped variable from a particular scope.
c:catch It is used for Catches any Throwable exceptions that occurs in the body.
c:if It is conditional tag used for testing the condition and display the body content only if th
c:choose, c:when, c:otherwise It is the simple conditional tag that includes its body content if the evaluated condition is
c:forEach It is the basic iteration tag. It repeats the nested body content for fixed number of times o
c:redirect It redirects the browser to a new URL and supports the context-relative URLs.
The JSTL function provides a number of standard functions, most of these functions are common
string manipulation functions. The syntax used for including JSTL function library in your JSP is:
fn:contains() It is used to test if an input string containing the specified substring in a program.
fn:containsIgnoreCase() It is used to test if an input string contains the specified substring as a case insensitive
fn:endsWith() It is used to test if an input string ends with the specified suffix.
fn:trim() It removes the blank spaces from both the ends of a string.
fn:startsWith() It is used for checking whether the given string is started with a particular string value.
fn:substring() It returns the subset of a string according to the given start and end position.
fn:length() It returns the number of characters inside a string, or the number of items in a collectio
fn:replace() It replaces all the occurrence of a string with another string sequence.
Outline the advantages of MVC
• Easily Modifiable –
Using the MVC methodology allows easy modification of the entire application.
Adding/updating the new type of views is simplified in the MVC pattern (as a single section is
independent of the other sections). So, any changes in a certain section of the application will
never affect the entire architecture. This, in turn, will help to increase the flexibility and
scalability of the application.
• Easy planning and maintenance –
The MVC paradigm is helpful during the initial planning phase of the application because it gives the
developer an outline of how to arrange their ideas into actual code. It is also a great tool to help limit code
duplication, and allow easy maintenance of the application.
• Multiple Views –
In the MVC architecture, developing different view components for your model component is easily
achievable. It empowers you to develop different view components, thus limiting code duplication as it
separates data and business logic.
The web container maintains the life cycle of a servlet instance. Let's see the life cycle of the servlet:
As displayed in the above diagram, there are three states of a servlet: new, ready and end. The servlet is in
new state if servlet instance is created. After invoking the init() method, Servlet comes in the ready state. In
the ready state, servlet performs all the tasks. When the web container invokes the destroy() method, it
shifts to the end state.
The classloader is responsible to load the servlet class. The servlet class is loaded when the first request for the servlet
is received by the web container.
The web container creates the instance of a servlet after loading the servlet class. The servlet instance is created only
once in the servlet life cycle.
The web container calls the init method only once after creating the servlet instance. The init method is used to initia
javax.servlet.Servlet interface. Syntax of the init method is given below:
The web container calls the service method each time when request for the servlet is received. If servlet is not initialized,
it follows the first three steps as described above then calls the service method. If servlet is initialized, it calls the service
method. Notice that servlet is initialized only once
The web container calls the destroy method before removing the servlet instance from the service. It gives the servlet
an opportunity to clean up any resource for example memory, thread etc
Http protocol is a stateless so we need to maintain state using session tracking techniques. Each time user requests to
the server, server treats the request as the new request. So we need to maintain the state of an user to recognize to
particular user.
HTTP is stateless that means each request is considered as the new request. It is shown in the figure given below:
1. Cookies
3. URL Rewriting
4. HttpSession
Cookies in Servlet
A cookie is a small piece of information that is persisted between the multiple client requests.
A cookie has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum
age, and a version number.
By default, each request is considered as a new request. In cookies technique, we add cookie with response from the
servlet. So cookie is stored in the cache of the browser. After that if request is sent by the user, cookie is added with
request by default. Thus, we recognize the user as the old user.
2) Hidden Form Field
In case of Hidden Form Field a hidden (invisible) textfield is used for maintaining the state of an user.
In such case, we store the information in the hidden field and get it from another servlet. This approach is better if we
have to submit form in all the pages and we don't want to depend on the browser.
Here, uname is the hidden field name and Vimal Jaiswal is the hidden field value
3)URL Rewriting
In URL rewriting, we append a token or identifier to the URL of the next Servlet or the next resource. We can send
parameter name/value pairs using the following format:
url?name1=value1&name2=value2&??
A name and a value is separated using an equal = sign, a parameter name/value pair is separated from another parameter
using the ampersand(&). When the user clicks the hyperlink, the parameter name/value pairs will be passed to the server.
From a Servlet, we can use getParameter() method to obtain a parameter value.
4) HttpSession interface
In such case, container creates a session id for each user.The container uses this id to identify the particular user.An
object of HttpSession can be used to perform two tasks:
1. bind objects
2. view and manipulate information about a session, such as the session identifier, creation time, and last accessed
time.
Explain JSP implicit objects
There are 9 jsp implicit objects. These objects are created by the web container that are available to all the jsp pages.
The available implicit objects are out, request, config, session, application etc.
Object Type
out JspWriter
request HttpServletRequest
response HttpServletResponse
config ServletConfig
application ServletContext
session HttpSession
pageContext PageContext
page Object
exception Throwable
In this section, we will discuss the MVC Architecture in Java, alongwith its advantages and disadvantages and
examples to understand the implementation of MVC in Java.
o Model: It represents the business layer of application. It is an object to carry the data that can also
contain the logic to update controller if data is changed.
o View: It represents the presentation layer of application. It is used to visualize the data that the model
contains.
o Controller: It works on both the model and view. It is used to manage the flow of application, i.e. data
flow in the model object and to update the view whenever data is changed.
In Java Programming, the Model contains the simple Java classes, the View used to display the data and the
Controller contains the servlets. Due to this separation the user requests are processed as follows:
1. A client (browser) sends a request to the controller on the server side, for a page.
2. The controller then calls the model. It gathers the requested data.
3. Then the controller transfers the data retrieved to the view layer.
4. Now the result is sent back to the browser (client) by the view.
Hibernate framework is open source under the LGPL license and lightweight.
2) Fast Performance
The performance of hibernate framework is fast because cache is internally used in hibernate framework. There are two
types of cache in hibernate framework first level cache and second level cache. First level cache is enabled by default.
HQL (Hibernate Query Language) is the object-oriented version of SQL. It generates the database independent queries.
So you don't need to write database specific queries. Before Hibernate, if database is changed for the project, we need
to change the SQL query as well that leads to the maintenance problem.
Hibernate framework provides the facility to create the tables of the database automatically. So there is no need to create
tables in the database manually.
Hibernate supports Query cache and provide statistics about query and database status.
Define ORM
ORM Tool
An ORM tool simplifies the data creation, data manipulation and data access. It is a programming technique that maps
the object to the data stored in the database.
The ORM tool internally uses the JDBC API to interact with the database.
Hibernate supports almost all the major RDBMS. Following is a list of few of
the database engines supported by Hibernate −
• XDoclet Spring
• J2EE
• Eclipse plug-ins
• Maven
Hibernate Properties
1 hibernate.dialect
This property makes Hibernate generate the appropriate SQL for the chosen database.
2 hibernate.connection.driver_class
The JDBC driver class.
3 hibernate.connection.url
The JDBC URL to the database instance.
4 hibernate.connection.username
The database username.
5 hibernate.connection.password
The database password.
6 hibernate.connection.pool_size
Limits the number of connections waiting in the Hibernate database connection pool.
7 hibernate.connection.autocommit
Allows autocommit mode to be used for the JDBC connection.
If you are using a database along with an application server and JNDI, then
you would have to configure the following properties −
2 hibernate.jndi.class
The InitialContext class for JNDI.
3 hibernate.jndi.<JNDIpropertyname>
Passes any JNDI property you like to the JNDI InitialContext.
4 hibernate.jndi.url
Provides the URL for JNDI.
5 hibernate.connection.username
The database username.
hibernate.connection.password
6
The database password.
Advantage of HQL
o database independent
Session object holds the first level cache data. It is enabled by default. The first level cache data will not be available to
entire application. An application can use many session object.
SessionFactory object holds the second level cache data. The data stored in the second level cache will be available to
entire application. But we need to enable it explicitely.
EH (Easy Hibernate) Cache
o Swarm Cache
o OS Cache
o JBoss Cache
Interpret HCQL
The Hibernate Criteria Query Language (HCQL) is used to fetch the records based on the specific criteria. The Criteria
interface provides methods to apply criteria such as retreiving all the records of table whose salary is greater than 50000
etc.
Advantage of HCQL
The HCQL provides methods to add criteria, so it is easy for the java programmer to add criteria. The java programmer
is able to add many criteria on a query.
The java.sql.Statement and java.sql.PreparedStatement interfaces provide methods for batch processing.
Fast Performance
What is JPA?
The Java Persistence API (JPA) is a specification of Java. It is used to persist data between Java object and relational
database. JPA acts as a bridge between object-oriented domain models and relational database systems.
As JPA is just a specification, it doesn't perform any operation by itself. It requires an implementation. So, ORM tools
like Hibernate, TopLink and iBatis implements JPA specifications for data persistence .
JPQL is an extension of Entity JavaBeans Query Language (EJBQL), adding the following important features to it: -
JPQL Features
o It is a platform-independent query language.
o JPQL queries can be declared statically into metadata or can also be dynamically built in code
This is the high level architecture of Hibernate with mapping file and configuration file.
The SessionFactory is a factory of session and client of ConnectionProvider. It holds second level cache (optional) of
data. The org.hibernate.SessionFactory interface provides factory method to get the object of Session.
Session
The session object provides an interface between the application and data stored in the database. It is a short -lived
object and wraps the JDBC connection. It is factory of Transaction, Query and Criteria. It holds a first -level cache
(mandatory) of data. The org.hibernate.Session interface provides methods to insert, update and delete the object. It
also provides factory methods for Transaction, Query and Criteria.
Transaction
The transaction object specifies the atomic unit of work. It is optional. The org.hibernate.Transaction interface
provides methods for transaction management.
ConnectionProvider
It is a factory of JDBC connections. It abstracts the application from DriverManager or DataSource. It is optional.
TransactionFactory
Caching is important to Hibernate as well. It utilizes a multilevel caching scheme as explained below −
First-level Cache
The first-level cache is the Session cache and is a mandatory cache through which all requests must pass. The Session
object keeps an object under its own power before committing it to the database.
If you issue multiple updates to an object, Hibernate tries to delay doing the update as long as possible to reduce the
number of update SQL statements issued. If you close the session, all the objects being cached are lost and either
persisted or updated in the database.
Second-level Cache
Second level cache is an optional cache and first-level cache will always be consulted before any attempt is made to
locate an object in the second-level cache. The second level cache can be configured on a per-class and per-collection
basis and mainly responsible for caching objects across sessions.
Any third-party cache can be used with Hibernate. An org.hibernate.cache.CacheProvider interface is provided, which
must be implemented to provide Hibernate with a handle to the cache implementation.
Query-level Cache
Hibernate also implements a cache for query resultsets that integrates closely with the second-level cache.
This is an optional feature and requires two additional physical cache regions that hold the cached query results and
the timestamps when a table was last updated. This is only useful for queries that are run frequently with the same
parameters.
Object Relational Mapping (ORM) is a functionality which is used to develop and maintain a relationship between an
object and relational database by mapping an object state to database column. It is capable to handle various database
operations easily such as inserting, updating, deleting etc.
ORM Frameworks
o Hibernate
o TopLink
o ORMLite
o iBATIS
o JPOX
Mapping Directions
o Unidirectional relationship - In this relationship, only one entity can refer the properties to another. It contains
only one owing side that specifies how an update can be made in the database.
o Bidirectional relationship - This relationship contains an owning side as well as an inverse side. So here every
entity has a relationship field or refer the property to other entity.
Types of Mapping
One-to-one - This association is represented by @OneToOne annotation. Here, instance of each entity is related
to a single instance of another entity.
o Many-to-one - This mapping is defined by @ManyToOne annotation. In this relationship, multiple instances
of an entity can be related to single instance of another entity.
JPQL allows us to create both static as well as dynamic queries. Now, we will perform some basic JPQL
operations using both type of queries on the below table.
Use queries within queries FROM Employee e WHERE e.salary > (SELECT AVG(salary) FROM
Subqueries to retrieve data. Employee)
Dynamic Construct queries Using Criteria API or building JPQL strings based on
Queries dynamically at runtime. user inputs.
Use named parameters in
Named queries for better
Parameters readability and reusability. FROM Employee e WHERE e.name = :employeeName
Control database
concurrency by applying
Locking locks to entities. FROM Employee e WHERE e.id = :empId FOR UPDATE
Define IOC
The IoC container is responsible to instantiate, configure and assemble the objects. The IoC container gets
informations from the XML file and works accordingly. The main tasks performed by IoC container are:
1. BeanFactory
2. ApplicationContext
1. Web Applications:
• Spring MVC provides a robust and flexible framework for building web applications. It follows the
Model-View-Controller (MVC) design pattern and integrates seamlessly with other Spring features.
2. Enterprise Applications:
• Spring facilitates the development of enterprise-level applications by providing support for various
enterprise features, such as dependency injection, transaction management, and declarative services.
3. Microservices:
• Spring Boot, an extension of the Spring Framework, simplifies the development of microservices. It
provides an opinionated approach to microservices architecture, making it easier to build, deploy, and
scale microservices.
4. RESTful Web Services:
• Spring MVC and Spring Boot support the development of RESTful web services. Spring's integration
with Jackson for JSON processing and support for RESTful principles make it a popular choice for
building scalable and maintainable REST APIs.
5. Data Access:
• Spring provides a comprehensive data access framework that simplifies database access. It supports
JDBC, ORM frameworks like Hibernate, JPA (Java Persistence API), and provides declarative
transaction management.
6. Batch Processing:
• Spring Batch is a module within the Spring Framework that facilitates the development of batch
processing applications. It provides features for reading, processing, and writing large volumes of
data.
7. Messaging Applications:
• Spring Integration is a part of the Spring portfolio that facilitates the integration of enterprise systems
through messaging. It supports messaging patterns and provides adapters for various messaging
systems.
8. Caching:
• Spring's caching abstraction simplifies the integration of caching mechanisms into applications. It
supports different caching providers and helps improve performance by caching frequently used data.
9. Security:
• Spring Security is a powerful and customizable authentication and access control framework. It is
widely used to secure Java applications, including web applications and RESTful services.
10. Dependency Injection and IoC:
• The core concept of Spring is Inversion of Control (IoC) and Dependency Injection (DI). This makes
the code more modular, testable, and maintainable by reducing dependencies and promoting loose
coupling.
11. Testing:
• The Spring Framework supports testing through the use of the Spring TestContext Framework. It
allows for the integration of unit tests, integration tests, and end-to-end tests in a Spring environment.
1) Predefined Templates
Spring framework provides templates for JDBC, Hibernate, JPA etc. technologies. So there is no need to write too much
code. It hides the basic steps of these technologies.
Let's take the example of JdbcTemplate, you don't need to write the code for exception handling, creating connection,
creating statement, committing transaction, closing connection etc. You need to write the code of executing query only.
Thus, it save a lot of JDBC code.
2) Loose Coupling
3) Easy to test
The Dependency Injection makes easier to test the application. The EJB or Struts application require server to run the
application but Spring framework doesn't require server.
4) Lightweight
Spring framework is lightweight because of its POJO implementation. The Spring Framework doesn't force the
programmer to inherit any class or implement any interface. That is why it is said non -invasive.
5) Fast Development
The Dependency Injection feature of Spring Framework and it support to various frameworks makes the easy
development of JavaEE application.
6) Powerful abstraction
It provides powerful abstraction to JavaEE specifications such as JMS, JDBC, JPA and JTA.
7) Declarative support
o tight coupling The dependency lookup approach makes the code tightly coupled. If resource is changed, we
need to perform a lot of modification in the code.
o Not easy for testing This approach creates a lot of problems while testing the application especially in black
box testing.
In short, Spring Boot is the combination of Spring Framework and Embedded Servers.
In Spring Boot, there is no requirement for XML configuration (deployment descriptor). It uses convention over
configuration software design paradigm that means it decreases the effort of the developer.
Autowiring Modes
There are many autowiring modes:
2) byName The byName mode injects the object dependency according to name of the bean. In such
case, property name and bean name must be same. It internally calls setter method.
3) byType The byType mode injects the object dependency according to type. So property name
4) constructor The constructor mode injects the dependency by calling the constructor of the class. It calls
AOP breaks the program logic into distinct parts (called concerns). It is used to increase modularity by cross-cutting
concerns.
A cross-cutting concern is a concern that can affect the whole application and should be centralized in one location in
code as possible, such as transaction management, authentication, logging, security etc.
It provides the pluggable way to dynamically add the additional concern before, after or around the actual logic.
1. class A{
2. public void m1(){...}
3. public void m2(){...}
4. public void m3(){...}
5. public void m4(){...}
6. public void m5(){...}
7. public void n1(){...}
8. public void n2(){...}
9. public void p1(){...}
10. public void p2(){...}
11. public void p3(){...}
12. }
There are 5 methods that starts from m, 2 methods that starts from n and 3 methods that starts from p.
Understanding Scenario I have to maintain log and send notification after calling methods that starts from m.
Problem without AOP We can call methods (that maintains log and sends notification) from the methods starting with
m. In such scenario, we need to write the code in all the 5 methods.
But, if client says in future, I don't have to send notification, you need to change all the methods. It leads to the
maintenance problem.
Solution with AOP We don't have to call methods from the method. Now we can define the additional concern like
maintaining log, sending notification etc. in the method of a class. Its entry is given in the xml file.
In future, if client says to remove the notifier functionality, we need to change only in the xml file. So, maintenance is
easy in AOP.
A Spring MVC provides an elegant solution to use MVC in spring framework by the help of DispatcherServlet.
Here, DispatcherServlet is a class that receives the incoming request and maps it to the right resource such as
controllers, models, and views.
Spring Web Model-View-Controller
o Model - A model contains the data of the application. A data can be a single object or a collection of objects.
o Controller - A controller contains the business logic of an application. Here, the @Controller annotation is used
to mark the class as the controller.
o View - A view represents the provided information in a particular format. Generally, JSP+JSTL is used to create
a view page. Although spring also supports other view technologies such as Apache Velocity, Thymeleaf and
FreeMarker.
o Front Controller - In Spring Web MVC, the DispatcherServlet class works as the front controller. It is
responsible to manage the flow of the Spring MVC application.
o As displayed in the figure, all the incoming request is intercepted by the DispatcherServlet that works as the
front controller.
o The DispatcherServlet gets an entry of handler mapping from the XML file and forwards the request to the
controller.
o The DispatcherServlet checks the entry of view resolver in the XML file and invokes the specified view
component.
Advantages of Spring MVC Framework
o Separate roles - The Spring MVC separates each role, where the model object, controller, command object,
view resolver, DispatcherServlet, validator, etc. can be fulfilled by a specialized object.
o Light-weight - It uses light-weight servlet container to develop and deploy your application.
o Powerful Configuration - It provides a robust configuration for both framework and application classes that
includes easy referencing across contexts, such as from web controllers to business objects and validators.
o Rapid development - The Spring MVC facilitates fast and parallel development.
o Reusable business code - Instead of creating new objects, it allows us to use the existing business objects.
o Easy to test - In Spring, generally we create JavaBeans classes that enable you to inject test data using the setter
methods.
o Flexible Mapping - It provides the specific annotations that easily redirect the page.
Define REST
REpresentational State Transfer (REST) is a software architectural style that defines the constraints to create web
services. The web services that follows the REST architectural style is called RESTful Web Services. It differentiates
between the computer system and web services. The REST architectural style describes the six barriers.
In other types of APIs, you are limited in your choice of data formats. However, RESTful APIs support all data
formats.
In RESTful APIs, you can send an HTTP request, get JavaScript Object Notation (JSON) data in response, and parse
that data to use it on the client applications. This makes it the best choice for web browsers. Furthermore, you can
Thanks to JSON, RESTful APIs use less bandwidth as compared to other types of APIs. However, this stands true for
JSON-based web APIs only. An XML-based web API will have a similar payload to its non-RESTful counterpart
In most cases, you can get models that you can modify and use. For example, NetApp and Mailgun provide a
complete tutorial and source code for building a private API. In some cases, maybe when developing a private API,
you will need to design the API from scratch, and for that, you can get a lot of support from Stack Overflow.
RESTful APIs use HTTP methods for communication. You can use Python, JavaScript (Node.js), Ruby, C#, and a
number of other languages to develop these APIs, making them easier to work with for most developers.
The Spring Framework provides about 20 modules which can be used based on an application requirement.
Core Container
The Core Container consists of the Core, Beans, Context, and Expression Language modules the details of which are
as follows −
• The Core module provides the fundamental parts of the framework, including the IoC and Dependency
Injection features.
• The Bean module provides BeanFactory, which is a sophisticated implementation of the factory pattern.
• The Context module builds on the solid base provided by the Core and Beans modules and it is a medium to
access any objects defined and configured. The ApplicationContext interface is the focal point of the Context
module.
• The SpEL module provides a powerful expression language for querying and manipulating an object graph at
runtime.
Data Access/Integration
The Data Access/Integration layer consists of the JDBC, ORM, OXM, JMS and Transaction modules whose detail is
as follows −
• The JDBC module provides a JDBC-abstraction layer that removes the need for tedious JDBC related coding.
• The ORM module provides integration layers for popular object-relational mapping APIs, including JPA,
JDO, Hibernate, and iBatis.
• The OXM module provides an abstraction layer that supports Object/XML mapping implementations for
JAXB, Castor, XMLBeans, JiBX and XStream.
• The Java Messaging Service JMS module contains features for producing and consuming messages.
• The Transaction module supports programmatic and declarative transaction management for classes that
implement special interfaces and for all your POJOs.
Web
The Web layer consists of the Web, Web-MVC, Web-Socket, and Web-Portlet modules the details of which are as
follows −
• The Web module provides basic web-oriented integration features such as multipart file-upload functionality
and the initialization of the IoC container using servlet listeners and a web-oriented application context.
• The Web-MVC module contains Spring's Model-View-Controller (MVC) implementation for web
applications.
• The Web-Socket module provides support for WebSocket-based, two-way communication between the client
and the server in web applications.
• The Web-Portlet module provides the MVC implementation to be used in a portlet environment and mirrors
the functionality of Web-Servlet module.
Miscellaneous
There are few other important modules like AOP, Aspects, Instrumentation, Web and Test modules the details of
which are as follows −
• The AOP module provides an aspect-oriented programming implementation allowing you to define method-
interceptors and pointcuts to cleanly decouple code that implements functionality that should be separated.
• The Aspects module provides integration with AspectJ, which is again a powerful and mature AOP
framework.
• The Instrumentation module provides class instrumentation support and class loader implementations to be
used in certain application servers.
• The Messaging module provides support for STOMP as the WebSocket sub-protocol to use in applications. It
also supports an annotation programming model for routing and processing STOMP messages from
WebSocket clients.
• The Test module supports the testing of Spring components with JUnit or TestNG frameworks.
1. Separation of Concerns:
• AOP promotes the separation of cross-cutting concerns from the main business logic, leading to
cleaner and more modular code.
2. Code Reusability:
• Aspects can be reused across different modules or projects, reducing code duplication and promoting
a DRY (Don't Repeat Yourself) approach.
3. Improved Maintainability:
• AOP makes it easier to maintain and modify code by isolating cross-cutting concerns. Changes to a
concern can be made in one place, affecting all modules where the aspect is applied.
4. Enhanced Readability:
• AOP improves code readability by removing clutter related to cross-cutting concerns from the main
business logic. This makes it easier to understand and maintain the core functionality of the
application.
5. Dynamic Cross-Cutting:
• AOP allows for dynamic application of aspects at runtime. This flexibility is useful for scenarios
where you want to enable or disable certain behaviors based on configuration or runtime conditions.
6. Aspect Interoperability:
• Aspects can be developed independently and combined to achieve the desired functionality. This
promotes a modular and reusable approach to handling cross-cutting concerns.
7. Consistent Application of Policies:
• AOP enables the consistent application of policies or rules across an application. For example,
security policies, logging policies, and transaction management rules can be applied uniformly.
8. Simplified Error Handling:
• AOP can simplify error handling by separating error-handling code from the main business logic. This
leads to more focused error-handling modules that can be reused across the application.
9. Testing and Debugging:
• AOP can facilitate testing and debugging by allowing developers to focus on the core functionality
during testing, without the distraction of cross-cutting concerns.
10. Flexibility in Design:
• AOP provides flexibility in the design of applications, allowing developers to address non -functional
requirements separately from the functional requirements.
Spring Framework is a widely used Java EE Spring Boot Framework is widely used to develop
framework for building applications. REST APIs.
It aims to simplify Java EE development that makes It aims to shorten the code length and provide the
developers more productive. easiest way to develop Web Applications.
The primary feature of the Spring Framework The primary feature of Spring Boot is Autoconfiguration
is dependency injection. . It automatically configures the classes based on the
requirement.
It helps to make things simpler by allowing us to It helps to create a stand-alone application with less
develop loosely coupled applications. configuration.
It does not provide support for an in-memory It offers several plugins for working with an embedded
database. and in-memory database such as H2.
Developers manually define dependencies for the Spring Boot comes with the concept of starter in pom.xml
Spring project in pom.xml. file that internally takes care of downloading the
dependencies JARs based on Spring Boot Requirement.
2. It provides uniform build process (maven project can be shared by all the maven projects)
3. It provides project information (log document, cross referenced sources, mailing list, dependency list, unit test
reports etc.)
The Maven build follows a specific lifecycle to deploy and distribute the target project.
There are three built-in lifecycles:
A Maven phase represents a stage in the Maven build lifecycle. Each phase is responsible for a specific task.
Here are some of the most important phases in the default build lifecycle:
Maven Goal
Each phase is a sequence of goals, and each goal is responsible for a specific task.
When we run a phase, all goals bound to this phase are executed in order.
Here are some of the phases and default goals bound to them:
• compiler:compile – the compile goal from the compiler plugin is bound to the compile phase
• compiler:testCompile is bound to the test-compile phase
• surefire:test is bound to the test phase
• install:install is bound to the install phase
• jar:jar and war:war is bound to the package phase
There are many differences between ant and maven that are given below:
Ant Maven
Ant doesn't has formal conventions, so we need to Maven has a convention to place source code,
provide information of the project structure in compiled code etc. So we don't need to provide
build.xml file. information about the project structure in pom.xml file.
Ant is procedural, you need to provide information Maven is declarative, everything you define in the
about what to do and when to do through code. You pom.xml file.
need to provide order.
The ant scripts are not reusable. The maven plugins are reusable.
Element Description
modelVersion It is the sub element of project. It specifies the modelVersion. It should be set to 4.0.0.
groupId It is the sub element of project. It specifies the id for the project group.
artifactId It is the sub element of project. It specifies the id for the artifact (project). An artifact is
something that is either produced or used by a project. Examples of artifacts produced
by Maven for a project include: JARs, source and binary distributions, and WARs.
version It is the sub element of project. It specifies the version of the artifact under given group.
Element Description
scope defines scope for this maven project. It can be compile, provided, runtime, test and system.
Define POM
POM is an acronym for Project Object Model. The pom.xml file contains information of project and configuration
information for the maven to build the project such as dependencies, build directory, source directory, test source
directory, plugin, goals etc.
JUnit is a Java testing framework that makes writing reliable and efficient tests easy. It can be used for applications
made in most languages but is particularly suited for testing Java applications. JUnit can also be used to
create automated tests.
JUnit framework is one of the most popular Java testing frameworks. It offers several features that make writing tests
easy, including support for multiple test cases, assertions, and reporting. JUnit is also versatile, allowing tests to be
written in various languages.
We have various types of automation testing tools available in the market. Some of the most commonly used automation
testing tools are as follows:
o Selenium
o Watir
o QTP
o Telerik Studio
o Testim
o Applitools
Selenium
It is an open-source and most commonly used tool in automation testing. This tool is used to test web-based applications
with the help of test scripts, and these scripts can be written in any programming language such as java, python, C#, Php,
and so on
Features of Selenium
This tool is most popular because of its various features. Following are standard features of Selenium:
o Selenium supports only web-based application, which means that the application can be opened by the browser
or the URL like Gmail, Amazon, etc.
o Selenium does not support a stand-alone application, which means that the application is not opened in the
browser or URL like Notepad, MS-Word, Calculator, etc.
o Selenium web driver is the latest tool in the selenium community that removes all the drawbacks of the previous
tool (selenium-IDE).
o Selenium web-driver is powerful because it supports multiple programming languages, various browsers, and
different operating systems and also supports mobile applications like iPhone, Android.
Watir
Watir stands for web application testing in ruby which is written in the Ruby programming language. testing in ruby.
It is a web application testing tool, which is open-source and supports cross-browser testing tool and interacts with a
platform like a human that can validate the text, click on the links and fill out the forms.
Features of Watir
o It supports various browsers on different platforms like Google Chrome, Opera, Firefox, Internet Explorer, and
Safari.
o We can take the screenshots once we are done with the testing, which helps us to keep track of the intermediate
testing.
o This tool has some inbuilt libraries, which helps to check the alerts, browser windows, page-performance, etc.
QTP
QTP tool is used to test functional regression test cases of the web-based application. QTP stands for Quick Test
Professional, and now it is known as Micro Focus UFT [Unified Functional Testing]. This is very helpful for the
new test engineer because they can understand this tool in a few minutes. QTP is designed on the scripting language
like VB script to automate the application.
Features of QTP
Following are the most common features of QTP:
o QTP uses the scripting language to deploy the objects, and for analysis purposes, it provides test reporting.
o With the help of QTP, we can test both desktop and web-based applications.
Telerik Studio
It is modern web application which support functional test automation. With the help of this tool, we can test the load,
performance, and functionality of the web and mobile applications and also identify the cross-browser issues.
o This tool supports Asp.Net, AJAX, HTML, JavaScript, WPF, and Silverlight application testing.
o It supports multiple browsers like Firefox, Safari, Google Chrome, and Internet Explorer for the test execution
process.
o With the help of this tool, we can do the sentence based UI validation.
o Testim
It is another automation testing tool, which can execute the test case in very little time and run them in various web and
mobile applications. This tool will help us to enhance the extensibility and stability of our test suites. It provides the
flexibility to cover the functionalities of the platform with the help of JavaScript and HTML.
Features of Testim
o With the help of this tool, we can perform requirements-based and parameterized testing.
Applitools
This tool is used to check the look and feel and user's feedback on the application. It can easily incorporate with the
presented test instead of creating a new analysis. Applitools is a monitoring software, which provides visual application
management and AI-powered visual UI testing. It is an open-source tool that helps us to deliver a quality product.
Features of Applitools
JMeter
JMeter is one of the widely used tools in the market to perform reliability testing and automation testing. The tool is
available for free of cost and is generally used in web and FTP ApplicationsJMeter is an Apache product, which has a
good reputation for compatibility testing. The tool is highly used for measuring and analysing the performance of
programs.
Pros of Jmeter
• User-friendly
• Used for FTP Applications
• Quality Compatibility testing
Cons of Jmeter
Forecast
Forecast is one of the most popular applications, which offers a wide range of options. Therefore, it is important for
users to consider having input data in detail.A detailed set of data related to scalability testing and recovery testing
play a major role for results. Hence, Forecast provides an easy to use interface to enjoy maximum mileage.
Pros of Forecast
• Limited options
Loadrunner
The reputation of the testing tool is one of the supreme factors because it defines quality. LoadRunner is a fabulous
tool because it offers accurate results in performance testing. The tool has gained a lot of reputation in offering stress
test results with quality.LoadRunner is a Micro Focus product, which has the capacity to simulate a lot of users at the
same time. The special analyzing strategy in the tool provides a wide room to enjoy the performance.
Pros of LoadRunner
Cons of LoadRunner
• No User-friendly interface
Loadster
The modern-day tools and applications are coming with extra features to attract. Loadster is a new tool, which comes
with cloud hybrid load testing technique. The technique allows users to test large scale applications and high-
performance websites.The tool offers quality results in volume testing parameters of the software system. Loadster
allows users to improve the technique because it helps in improving stability.
Pros of Loadster
• Extra features
• New and modern set of options
• Hybrid load testing techniques
Cons of Loadster
Loadstorm
There are huge benefits of non-functional testing tools. it is vital for testers to know the actual objective of the testing
process before starting. A strong set of functional requirements enable the tool to complete the process with productive
results.Loadstorm is a powerful tool, which is available to test various program components. So, the hybrid set of
features enables testers to save time without affecting the performance.
Pros of Loadstorm
Load Complete
It is a known fact that testers prefer using a simple and efficient tool to reduce manual effort. The tools enable the user
to execute performance testing and Localization Testing.It is evident that every product requires a set of different
testing parameters. So, it is important to check for a tool, which provides an expert report after the process.
• Simple tool
• Efficiency
• Localization testing features
Loadtracer
Loadtracer is one of the most effective tools, which is generally used to test program performance. The fully
developed tool has a unique set of functionalities. The functionalities are available for testers to enhance the
performance of the program.It is evident that web applications are in need of a proper set of tools to test regularly.
Loadtracer gives a wide room for testers to perform all kinds of testing at low costs.
Pros of Loadtracer
Cons of Loadtracer
• No user-friendly Interface
Neoload
Automation Testing is a modern concept, which allows people to save a lot of money. Hence, It is obvious that testers
find automated ways to save time without compromising on productivity.NeoLoad is a fine application, which
offers Automation Options to enhance performance. The tool provides quality results while testing various kinds of
projects. Projects include APIs, web applications and so on.
Pros of Neoload
Selenium WebDriver is a web framework that permits you to execute cross-browser tests. This tool is used
for automating web-based application testing to verify that it performs expectedly.
Selenium WebDriver allows you to choose a programming language to create test scripts
Maven automatically downloads project JARs, libraries, and other files. In the pom.xml file, only
information about the version of the software and the type of dependencies must be included. Maven
can manage projects in Ruby, C#, and other languages. It is responsible for building projects, their
dependencies, and documenting them.
ANT (Another Neat Tool), another tool created by Apache Software Foundation, is used to build and
deploy projects. Maven, however, is much more potent than ANT. Maven, like ANT, has simplified the
process of building. Maven, therefore, has simplified the lives of developers.
Advantages of Maven
• Maven manages all the processes, such as building, releasing, documentation, and distribution of the
projects
• Maven automatically includes all necessary dependencies for your project after reading the pom.xml
file.
• It is very easy to create projects using jar, war, and so on as per requirements.
• Maven allows you to start projects easily in various environments, and you don't have to worry about
dependency injection, builds, processing, etc.
• The process of adding a new dependency can be extremely easy. You just need to write the code for the
dependency in the pom.xml file.
1. Local Repository
2. Central Repository
3. Remote Repository
Local Repository
Maven's local repository is a directory on your machine in which all the project components are kept.
When the Maven build is finished, Maven automatically downloads all the dependencies jars to
Maven's local repository.
Central Repository
If dependencies are not found in the local repository, Maven then searches the central repository.
Maven then downloads the dependencies to the local repository.
Apache Maven group developed the central repository, and it is hosted on the web.
Like the local repository, the path of the central repository can be modified in setting.xml.
Remote Repository
It is similar to the central repository. When Maven wants to download a dependency, it goes to a
remote repository. The remote repository is present on a web server and is widely used to host the
internal projects of an organization.
Selenium Limitations
o Selenium does not support automation testing for desktop applications.
o Selenium requires high skill sets in order to automate tests more effectively.
o Since Selenium is open source software, you have to rely on community forums to get your technical
issues resolved.
o We can't perform automation tests on web services like SOAP or REST using Selenium.
o We should know at least one of the supported programming languages to create tests scripts in
Selenium WebDriver.
o It does not have built-in Object Repository like UTF/QTP to maintain objects/elements in centralized
location. However, we can overcome this limitation using Page Object Model.
o Selenium does not have any inbuilt reportingcapability; you have to rely on plug -ins
like JUnit and TestNG for test reports.
o It is not possible to perform testing on images. We need to integrate Selenium with Sikuli for image
based testing.
o Creating test environment in Selenium takes more time as compared to vendor tools like UFT, RFT,
Silk test, etc.
o No one is responsible for new features usage; they may or may not work properly.
o Selenium does not provide any test tool integration for Test Management.
Selenium is not just a single tool but a suite of software, each with a different approach to support
automation testing. It comprises of four major components which include:
>Selenium IDE has limited scope and the generated test scripts are not very robust and portable.
3. Selenium WebDriver
Selenium WebDriver (Selenium 2) is the successor to Selenium RC and is by far the most important
component of Selenium Suite. SeleniumWebDriverprovides a programming interface to create and
execute test cases. Test scripts are written in order to identify web elements on web pages and then
desired actions are performed on those elements.
Selenium WebDriver performs much faster as compared to Selenium RC because it makes direct
calls to the web browsers. RC on the other hand needs an RC server to interact with the web browser.
4. Selenium Grid
Selenium Grid is also an important component of Selenium Suite which allows us to run our tests on
different machines against different browsers in parallel. In simple words, we can run our tests
simultaneously on different machines running different browsers and operating systems.
Selenium Grid follows the Hub-Node Architecture to achieve parallel execution of test scripts. The
Hub is considered as master of the network and the other will be the nodes. Hub controls the
execution of test scripts on various nodes of the network
ss