Posts

How to register App on Facebook

Image
Steps to create Apps on Facebook : Login to your Facebook account and then Goto https://developers.facebook.com/ and then click on Apps tab. Check below screenshot : Registration Page Enter the Display Name. This is required.  Enter Namespace. (Optional) Choose a Category and then click on Create App button. After verifying captcha It will show you the App ID and App Secret which is nothing but ClientId and ClientSecret . Check below screenshot : Select “Settings” and then click on “Advance” tab. Scroll down and enter your callback URL in “Valid Oauth redirect URIs” and then click on “Save Changes button to save your apps. Congratulation!!! You have created your Apps on Facebook.

How to setup of WSO2 Identity Server on windows

Image
What is WSO2 Identity Server ? WSO2 Identity Server is an enterprise-ready, fully-open source, lean, component-based solution for facilitating security and provides secure identity management for enterprise web applications, services, and APIs by managing identity and entitlements of the user securely and efficiently. It helps improve customer experience by reducing identity provisioning time, guaranteeing secure online interactions, and delivering a reduced single sign-on environment. WSO2 Identity Server decreases identity management, entitlement management, and administration burden by including role-based access control (RBAC) convention, fine-grained policy-based access control, and SSO bridging. Downloading the product : In your Web browser, go to http://wso2.com/products/identity-server. If you are a new user downloading WSO2 products for the first time, register and log in. Once you are logged in, click the Binary button in the upper right corner of ...

How to substitute dynamic placeholder in properties file

This blog will explain you how can you use replace placeholder with original value in properties file. To achieve this task we will you Java API MessageFormat . Suppose you have properties file named "welcome.properties" having message : welcome=Hi {0} , Welcome to {1} Sample :  import java.io.File; import java.io.FileInputStream; import java.text.MessageFormat; import java.util.Properties; /**  * @author abdul  *  */ public class DynamicPlaceholder { /** * @param args * @throws Exception  */ public static void main(String[] args) throws Exception { File propFile = new File("D:\\juno\\Practise\\src\\com\\waheed\\dynamic\\placeholder\\substitution\\welcome.properties"); Properties props = new Properties(); FileInputStream stream=new FileInputStream(propFile); props.load(stream); String message = props.getProperty("welcome");                // Here the {0} and {1} will be substi...

Junit Test with Mockito

Mockito is a testing framework for Java which allows the creation of Test Double objects called "Mock Objects" for use in automated unit testing in conjunction with framework like Junit.  For more details, Check here . This blog will show you step by step working of Mockito. Step 1 : You need mockito-all and Junit jars into you project classpath which you can download it from here . If you are using maven, add following dependency into your pom.xml file. <dependency>             <groupid>org.mockito</groupid>             <artifactid>mockito-all</artifactid>             <version>1.9.5</version> </dependency> <dependency>             <groupid>junit</groupid>             <artifactid...

Testing REST Client using MockRestServiceServer

Problem : I have a Web Application which is deployed on tomcat server and I needed to write unit test cases which can test all the controllers. Secondly It internally also hits another Web server using RestTemplate that means for the success of all unit test cases both the applications should be up and running.    Solution : After spending some time on Google, I found that Spring provide a new feature “MockRestServiceServer” by which testing a REST Client is simple. This new feature is in Spring 3.2.x but also available in Spring 3.1.x via the extra jar named “spring-test-mvc”. So, You can test your Spring MVC controllers very easy without starting any Web Application. MockRestServiceServer takes the approach of mocking the server and allowing you to specify expected behavior and responses in your junit test class. It also handles server exception classes. MockRestRequestMatchers offers many hamcrest matchers to check your request URL, headers, HTTP method, an...

How to create Spring MVC project using Maven and Eclipse

Image
This blog will show you how quickly you can  create a Spring MVC project and get it up and running, using the Maven archetype called spring-mvc-archetype . Note: First You should verify that the Maven Integration for FTP is already installed in your eclipse, If not first installed and then create a new project. Steps : In Eclipse IDE, Goto  File > New > Project Select  Maven > Maven Project and click  Next . Make sure you don’t check the option Create a simple project (skip archetype selection) , and click Next . In the next screen, Select Catalog as All Catalogs , Archetype as spring-mvc into the Filter   and select  maven-archetype-webapp in the artifact list as shown below :     In case, If you don't see the above artifact in your Archtype then Click on "Add Archetype" and Add : Archetype Group Id: co.ntier Archetype Artifact Id: spring-mvc-archetype Archetype Version: 1.0.2 Repository URL: http:...

How to do JVM Remote debugging via SSH

Image
Last week I was getting one issue which was difficult to debug as the product was on EC2 instance. We were wasting lot of time as It was difficult to test and check the actual cause of issue.  Later I decided to attach the Eclipse debugger to my target JVM which is running on some different(EC2 instance) machine with the help of PuTTy ( PuTTY is an SSH and telnet client). Lets start with the steps : 1. Make sure your target JVM is started with these args:         -agentlib:jdwp=transport=dt_socket,address=8001,server=y,suspend=n 2. Create an SSH session into your PuTTy.       Open Putty, Add :          -- IP Address : "YOUR_TARGET_JVM_ADDRESS"         -- PORT : 22         -- Saved Sessions : your session name         -- Choose 'SSH' radio button and Save it.               3. Aft...