Skip to content

Instantly share code, notes, and snippets.

@kodiyan
kodiyan / AuthFilter.java
Created March 26, 2015 21:20
Primefaces Login Example with Database
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@kodiyan
kodiyan / DetectOS
Created August 7, 2014 18:46
Detect Operating System using Java
public static String OSDetector () {
String os = System.getProperty("os.name").toLowerCase();
if (os.contains("win")) {
return "Windows";
} else if (os.contains("nux") || os.contains("nix")) {
return "Linux";
}else if (os.contains("mac")) {
return "Mac";
}else if (os.contains("sunos")) {
@kodiyan
kodiyan / hp alm update script
Created July 30, 2014 18:57
HP ALM Update VB Script that Run from Java Class
############################################CallVBS.java##########################################
package com.resp.util;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
@kodiyan
kodiyan / Selenium Screenshot & Save to SQL
Last active August 29, 2015 14:04
Get Screen Shot Using Selenium and Save into MS SQL Database
package com.main;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
@kodiyan
kodiyan / Maven JUnit Test Run
Last active August 29, 2015 14:04
Run Junit Test from Maven and Main Class
Project Structure:
TestDemo
|-src/main/java
|--com.main
|---Cal.Java
|-src/test/java
|--com.test
|---CalcAdd.java
|---CalTUnit.java
|---RunTest.java
@kodiyan
kodiyan / BrowserVersionSelenium
Last active August 29, 2015 14:03
Get Browser and Version
package com.main;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
public class BrowserVersion {
private static WebDriver browserDriver;
@kodiyan
kodiyan / Run CukeJVM from Java
Created June 11, 2014 14:48
How to Run Cucmber JVM Run File from another Jav aClass
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
public static void main(String[] args) {
JUnitCore junit = new JUnitCore();
Result result = junit.run(CucmberJVMRun.class);
}
@kodiyan
kodiyan / imagetobyte
Last active August 29, 2015 14:02
Converting Picture to Byte from Local Folder and Printe in Console
package com.main;
import javax.imageio.ImageIO;
import org.apache.commons.io.IOUtils;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
public class ImageUtil {
@kodiyan
kodiyan / DB_iterate
Created April 8, 2014 14:06
Connect MSSQL with property file and Iterate Random value from DB
import java.util.Properties;
import java.util.Random;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@kodiyan
kodiyan / Call SOAP_XML
Created April 7, 2014 15:54
Call SOAP URL and send the Request XML and Get Response XML back
/* Call SOAP URL and send the Request XML and Get Response XML back */
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;