Thursday, February 20, 2020

Moving on to advanced Java - Exploring the vast presence of Java


      The previous post look at how one should start learning Java. The syntax, constructs and the tools set that Java has on offer. Now lets dig down and see the list of technologies that build upon the Java language to understand the actual power of Java. You can view this post a road map to get learn and to exploring the  every evolving world of Java.
  • Design Patterns
    • Core Java Design Patterns
    • J2EE Design Patterns
  • Java EE - Servlets, JSPs, EJB
  • Java Messaging Service
  • Web Services
    • SOAP Web Services
    • RESTful Web Services
  • The Frameworks
    • Spring
    • Hibernate
    • Struts
    • JSF
  • Data Structures and Algorithms

Sunday, August 6, 2017

Selenium Code Snippets





Following HTML code demonstrates how to take screenshots for the tests executed using Selenium. Approach1: Use the Selenium WebDriver


 public static void captureScreenShotSelenium(WebDriver ldriver, String opFileName){
  // Take screenshot and store as a file format             
   File src=((TakesScreenshot)ldriver).getScreenshotAs(OutputType.FILE);           
  try {
   opFileName = (opFileName == null) ? "" : opFileName;
  // now copy the  screenshot to desired location using copyFile method
  FileUtils.copyFile(src, new File("C:/selenium/"+opFileName+System.currentTimeMillis()+".png"));
  System.out.println("Capture Successful!");
  } catch (IOException e)
  {
    System.out.println(e.getMessage()); 
   } 
 }
Approach2: Use Robot package

 
 public static void captureAltPrintScreenPNG(String filepathfull)
    {
     Robot robot;
     Transferable t;
     RenderedImage image;
     File opFile;
     try {
      robot = new Robot();
      robot.keyPress(KeyEvent.VK_ALT);
            robot.keyPress(KeyEvent.VK_PRINTSCREEN);
            robot.keyRelease(KeyEvent.VK_PRINTSCREEN);
            robot.keyRelease(KeyEvent.VK_ALT);
            
            Thread.sleep(1000 * 2);
            
            t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
            image = (RenderedImage)t.getTransferData(DataFlavor.imageFlavor);//UnsupportedFlavorException
            
            opFile = new File(filepathfull);
            boolean isSuccess = ImageIO.write(image, "png", opFile);

            System.out.println(isSuccess+" "+opFile.getCanonicalPath());
            
     }
     catch (AWTException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  } catch (InterruptedException e) {
   e.printStackTrace();
  } catch (UnsupportedFlavorException e) {
   e.printStackTrace();
  }
     finally
     {
      
     }
    }

Monday, April 17, 2017

Planing to Explore the World of Java


  • Java Keywords, Identifiers, Statics, Final, Abstract
  • OOPS Concepts: Abstraction (Abstract Classes & Interfaces), Encapsulation (Getters, Setters), Inheritance (Hierarchies, Casting), Polymorphism (Overloading, Overriding)
  • Operators
  • Exceptions, Assertions
  • Strings, Dates, I18N, Utilities
  • IO and Serialization
  • Collections& Generics
  • Threads & Executor Framework
  • Inner Classes
  • Compilation and Execution process and Commandline commands
  • JVM, Memory, Garbage Collection, Caching 
  • Reflection
  • RMI, Networking, Socket Programming