Mockito is an open source framework that allows you to easily create mocks (test doubles). Mocks are objects that have return values to method executions made during the test and has recorded expectations of these executions. Mocks can also throw an exception if they receive a call they don’t expect. They are checked during verification to ensure … Continue reading Mockito 101 – Unit Testing in Java Apps
Tag: Java
certs not found: Java/Spring boot in eclipse and STS exception [SOLVED]
How to solve JDK certificate error in sping MVC/Boot inside Eclipse and STS.
Context Initialization failed – Java – Spring MVC Solved!
Check which version spring MVC libraries are you using. If you re using Spring MVC 3 then prefer install Java 7 with tomcat version 7.0.92.
How to deploy your node.js web application with AWS Beanstalk?
This post will show you how we can quickly create a node.js web aplication based on express framework and how to deploy that application on AWS using AWS BeanStalk service. Now first you need to know what is AWS BeanStalk? Some information about AWS BeanStalk: AWS BeanStalk is the fastest and simplest way to deploy … Continue reading How to deploy your node.js web application with AWS Beanstalk?
Data Structures in Java: Two Sum Problem
Given an array of integers, return indices of the two numbers such that they add up to a specific target. Each input should have exactly one solution and you may not use the same element twice. Example, arr_nums = [7, 4, 2, 11, 20], target = 6 Here, arr_nums[1] + arr_nums[2] = 6 So, return … Continue reading Data Structures in Java: Two Sum Problem
Java-Spring or JavaScript-Node.js?
Spring Framework for Java has been around past 15 years since its initial release. Most of the web developers prefer spring to build enterprise level web apps. But since last 3-4 years the Javascript has become more popular not only in the client-side development(Angular and React) but also towards the server-side development, thanks to nodejs. … Continue reading Java-Spring or JavaScript-Node.js?
Web Development Trends in 2018 and for future!
Since the launch of the first website made by Tim Berners-Lee in 1991, the website development practice have come a long way and every year new web design and development trends are coming. Developers are becoming more agile in learning about these new trends. In 2018, we'll look at the new trends which are hot … Continue reading Web Development Trends in 2018 and for future!
Why Spring Framework?
Spring Framework is a powerful lightweight web application development framework used for Java Enterprise Edition (JAVAEE). Spring is described as a complete and a modular framework. The Spring Framework can be used in all layers of implementation of a real time application. It can also be used for the development of particular layer of a … Continue reading Why Spring Framework?
Tomcat: Request Header too large? Resolved!
While working on web applications, developers face common server errors and exceptions in java based web application for example java.lang.IllegalArgumentException.
Dynamic String Conversion in JAVA
Input: 2B Output: 2000000000 Code : import java.math.BigDecimal; import java.util.Scanner; public class DyanamicConversion { public static void main(String args[]){ //Scanner scan = new Scanner(System.in); String a ="2M"; String[][] conversion = {{"K","1000"},{"M","1000000"},{"B","1000000000"}}; for(int i=0;i<conversion.length;i++){ if(a.endsWith(conversion[i][0])){ BigDecimal temp = new BigDecimal(a.substring(0, a.indexOf(conversion[i][0]))); temp.multiply(new BigDecimal(conversion[i][1])); a = temp.toBigInteger().toString(); System.out.println(a); break; } } } }
Sending HTTP GET Request to a REST API in JAVA
HTTP/HTTPS Get/Post request /response using JAVA below. For detailed visit here: https://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/ Code: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import javax.net.ssl.HttpsURLConnection; public class HttpURLConnection { public static void main(String[] args) throws IOException { String response = httpGet("https://services.groupkt.com/state/get/IND/all"); } public static String httpGet(String urlStr) throws IOException { URL obj = new URL(urlStr); HttpsURLConnection con … Continue reading Sending HTTP GET Request to a REST API in JAVA