Thursday

SOAPUI : java.lang.Exception: Failed to load url

BUG:
When i try to import the WSDL in SoapUI-5.2.1, i got an error.
Detailed error log in C:\Program Files\SmartBear\SoapUI-5.2.1\bin\error.log is below:

java.lang.Exception: Failed to load url; https://10.xxx.xxx.xxx:xxxx/../../..?wsdl, 0 -
                at com.eviware.soapui.impl.wsdl.support.wsdl.UrlWsdlLoader.load(UrlWsdlLoader.java:171)
                at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlLoader.readCleanWsdlFrom(WsdlLoader.java:123)
                at com.eviware.soapui.impl.wsdl.support.wsdl.WsdlLoader.loadXmlObject(WsdlLoader.java:101)
                at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:488)
                at com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils.getDefinitionParts(SchemaUtils.java:477)
                at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionCache.update(AbstractDefinitionCache.java:94)
                at com.eviware.soapui.impl.support.definition.support.AbstractDefinitionContext$Loader.construct(AbstractDefinitionContext.java:209)
                at com.eviware.soapui.support.swing.SwingWorkerDelegator.construct(SwingWorkerDelegator.java:46)
                at com.eviware.soapui.support.swing.SwingWorker$2.run(SwingWorker.java:131)
                at java.lang.Thread.run(Unknown Source)

Also when i open the url in the browser, i see the following certificate error which says that the connection uses TLS 1.2.

























FIX:
It means that the service has configured only for TLS1.2 and SSL has not allowed.
You should add the following parameter to the SOAPUI vmoptions file (C:\Program Files\SmartBear\SoapUI-5.2.1\bin\SoapUI-5.2.1.vmoptions) and restart SOAPUI.

-Dsoapui.https.protocols=TLSv1.2,SSLv3

Tuesday

Clearcase unable to contact albd_server on host 'remote server'

BUG:
I got following error when i attempt to open/start view.
  • clearcase unable to contact albd_server on host 
FIX:
Open Clearcase properties as following:
  • Windows Start >> Run  >> type  cc.cpl >> Service Startup tab
  • You will see "Status of the ALBD Service" as Stopped. Then click "Start Clearcase".




Wednesday

CSS table row coloring >> tr:nth-child get 2nd, 3rd, 6th and 7th children at once?














<html>
           <head>
                   <style>
                         caption {
                                text-align: center;
                           }
                            tr:nth-child(4n+1):not(:first-child), tr:nth-child(4n) {
                                  background: #EAEAEA;
                             }
                             tr:nth-child(4n-1), tr:nth-child(4n-2) {
                                 background: #E7F2FC;
                            }
                            </style>
                </head>
               
    <body topmargin=0 leftmargin=0>
      <table >
        <caption><b><br>HEADER</b></caption>
        <tr>
          <td height="21"><b>column 1</b></td>
          <td height="21"><b>column 2</b></td>
          <td height="21"><b>column 3</b></td>
          <td height="21"><b>column 4</b></td>
        </tr>
        <tr>
          <td>row 1.1</td>
          <td>row 1.2</td>
          <td>row 1.3</td>
          <td>row 1.4</td>
        </tr>
        <tr>
          <td colspan="4">row 2</td>
        </tr>
        <tr>
          <td>row 3.1</td>
          <td>row 4.2</td>
          <td>row 4.3</td>
          <td>row 4.4</td>
        </tr>
        <tr>
          <td colspan="4">row 4</td>
        </tr>
        <tr>
          <td>row 5.1</td>
          <td>row 5.2</td>
          <td>row 5.3</td>
          <td>row 5.4</td>
        </tr>
        <tr>
          <td colspan="4">row 6</td>
        </tr>
      </table>
     </body>
</html>

Clearcase error: Checkout is currently disabled for element | An update must be performed on the element to enable a checkout.

BUG:
While i tried to checkout a folder, it failed with the following error:
Error adding the file D:\myview\myvob\parentdir\myfile.xls to source control.
Checkout is currently disabled for element D:\myview\myvob\parentdir.
An update appears to have been aborted or errors were encountered during an update.  An update must be performed on the element to enable a checkout.

FIX:
Update your view from the root.
clearcase explorer >> your snapshot >> right click >> update view

Friday

Ant scp error: com.jcraft.jsch.JSchException: reject HostKey: 10.xx.xx.xx

BUG:
I got the following error in scp task when run ant.
my build file:

<scp todir="${username}:${password}@${ip}:${dir}" >
       <fileset dir="${parentDir}/">
            <include name="**/${dirToCopy}"/>
         </fileset>
</scp>

ERROR:
com.jcraft.jsch.JSchException: reject HostKey: 10.xx.xx.xx

FIX:
Add trust attribute.
<scp todir="${username}:${password}@${ip}:${dir}" trust="true" >
         <fileset dir="${parentDir}/">
            <include name="**/${dirToCopy}"/>
         </fileset>
</scp>

Regex date format validation (11_digit_identification_number date_of_birth_with_following_format_dd.mm.yyyy)

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test {

       public static void main( String args[] ) {

              String line[] = {"96325587410 10.01.1980", "96325587410 8.4.1988",
                          "96325587410 31.12.2000", "96325587410 70.01.2000",                                  "96325587410 1-01-1980", "216235456242334458 10.01.1980"
                          "21652334458 10.01.2980"};

              String pattern = "\\A\\s*\\d{11}\\s*(0?[1-9]|[12][0-9]|3[01])\\.(0?[1-9]|1[012])\\.((19|20)\\d\\d)\\s*\\Z";
              String parameters  = "\\A\\s*(\\d{11})\\s*((0?[1-9]|[12][0-9]|3[01]).(0?[1-9]|1[012]).((19|20)\\d\\d))\\s*\\Z";

              for(int i = 0; i< line.length ; i++) {
                     Pattern r = Pattern.compile(pattern);
                     Matcher m = r.matcher(line[i]);
                     System.out.println("KEYWORD: " + line[i]);
                    
                     if (m.find( )) {
                           Pattern cno = Pattern.compile(parameters);
                           Matcher m1 = cno.matcher(line[i]);
                           if(m1.find( )) {
                                  System.out.println("--> identityno: " + m1.group(1));
                                  System.out.println("--> dateofbirth: " + m1.group(2) );
                           }
                          
                     } else {
                           System.out.println("---> NO MATCH");
                     }
                    
                     System.out.println("---------------------------------------");
              }

       }
}


OUTPUT:

KEYWORD: 96325587410 10.01.1980
--> identityno: 96325587410
--> dateofbirth: 10.01.1980
---------------------------------------------
KEYWORD: 96325587410 8.4.1988
--> identityno: 96325587410
--> dateofbirth: 8.4.1988
---------------------------------------------
KEYWORD: 96325587410 31.12.2000
--> identityno: 96325587410
--> dateofbirth: 31.12.2000
---------------------------------------------
KEYWORD: 96325587410 70.01.2000
---> NO MATCH
---------------------------------------------
KEYWORD: 96325587410 1-01-1980
---> NO MATCH
---------------------------------------------
KEYWORD: 216235456242334458 10.01.1980
---> NO MATCH
---------------------------------------------
KEYWORD: 21652334458 10.01.2980
---> NO MATCH
---------------------------------------------

Join ArrayList String elements into a single String with a separator

Download commons-lang3-3.0.1.jar.

https://mvnrepository.com/artifact/
org.apache.commons/commons-lang3/3.0.1
For maven:

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>3.0.1</version>
</dependency>

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

public class Test {
      
       public static void main(String[] args) {
              List<String> list = new ArrayList<String>();
              list.add("less");
              list.add("talk");
              list.add("more");
              list.add("code");

              System.out.println(StringUtils.join(list, ", "));
       }
}

OUTPUT:
less, talk, more, code

Thursday

JFreeChart example - create charts in Java and save them as jpeg

Download jcommon-1.0.16.jar and add to the build path.

https://mvnrepository.com/artifact/jfree/jcommon/1.0.16

For maven:
<dependency>
    <groupId>jfree</groupId>
    <artifactId>jcommon</artifactId>
    <version>1.0.16</version>
</dependency>
Download jfreechart-1.0.13.jar and add to the build path.

https://mvnrepository.com/artifact/jfree/jfreechart/1.0.13
For maven:
<dependency>
    <groupId>jfree</groupId>
    <artifactId>jfreechart</artifactId>
    <version>1.0.13</version>
</dependency>

import java.io.IOException;

public class Main {

       public static void main(String[] args) throws IOException {

              PieChart3D pieChart3D = new PieChart3D("Comparison", "Which operating system are you using?");
              pieChart3D.pack();
              pieChart3D.setVisible(true);

              PieChart pieChart = new PieChart("Comparison", "Which operating system are you using?");
              pieChart.pack();
              pieChart.setVisible(true);

              XYAreaChart xyAreaChart = new XYAreaChart("Comparison", "Sample XY Area Chart");
              xyAreaChart.pack();
              xyAreaChart.setVisible(true);

              XYLineChart xyLineChart = new XYLineChart("Comparison", "Sample XY Line Chart");
              xyLineChart.pack();
              xyLineChart.setVisible(true);

              XYStepAreaChart xyStepAreaChart = new XYStepAreaChart("Comparison", "Sample XY Step Area Chart");
              xyStepAreaChart.pack();
              xyStepAreaChart.setVisible(true);

              //We will save the following chart to a file named chart.jpg
              VerticalBarChart3D verticalBarChart3D = new VerticalBarChart3D("Comparison", "Sample Vertical Bar Chart");
       }
}


import javax.swing.JFrame;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
import org.jfree.util.Rotation;


public class PieChart extends JFrame {

    private static final long serialVersionUID = 1L;

    public PieChart(String applicationTitle, String chartTitle) {
        super(applicationTitle);
        PieDataset dataset = createDataset();
        JFreeChart chart = createChart(dataset, chartTitle);

        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        setContentPane(chartPanel);
    }

    private  PieDataset createDataset() {
        DefaultPieDataset result = new DefaultPieDataset();
        result.setValue("Linux", 29);
        result.setValue("Mac", 20);
        result.setValue("Windows", 51);
        return result;
    }

    private JFreeChart createChart(PieDataset dataset, String title) {
        JFreeChart chart = ChartFactory.createPieChart(
            title,                  // chart title
            dataset,                // data
            true,                   // include legend
            true,
            false
        );


        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setStartAngle(290);
        plot.setDirection(Rotation.CLOCKWISE);
        plot.setForegroundAlpha(0.5f);
        return chart;
    }
}



import javax.swing.JFrame;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
import org.jfree.util.Rotation;


public class PieChart3D extends JFrame {

    private static final long serialVersionUID = 1L;

    public PieChart3D(String applicationTitle, String chartTitle) {
        super(applicationTitle);
        PieDataset dataset = createDataset();
        JFreeChart chart = createChart(dataset, chartTitle);

        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        setContentPane(chartPanel);
    }

    private  PieDataset createDataset() {
        DefaultPieDataset result = new DefaultPieDataset();
        result.setValue("Linux", 29);
        result.setValue("Mac", 20);
        result.setValue("Windows", 51);
        return result;
    }

    private JFreeChart createChart(PieDataset dataset, String title) {
        JFreeChart chart = ChartFactory.createPieChart3D(
            title,                  // chart title
            dataset,                // data
            true,                   // include legend
            true,
            false
        );

        PiePlot3D plot = (PiePlot3D) chart.getPlot();
        plot.setStartAngle(290);
        plot.setDirection(Rotation.CLOCKWISE);
        plot.setForegroundAlpha(0.5f);
        return chart;
    }
}



import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;


public class VerticalBarChart3D extends JFrame {

    private static final long serialVersionUID = 1L;

    public VerticalBarChart3D(String applicationTitle, String chartTitle) throws IOException {
        super(applicationTitle);
        DefaultCategoryDataset dataset = createDataset();
        JFreeChart chart = createChart(dataset, chartTitle);

        BufferedImage image = chart.createBufferedImage(500,300);
        JLabel lblChart = new JLabel();
        lblChart.setIcon(new ImageIcon(image));
        ChartUtilities.saveChartAsJPEG(new File("chart.jpg"), chart, 500, 300);
    }

    private  DefaultCategoryDataset createDataset() {
        DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset();
        categoryDataset.setValue(6,"Marks" ,"Aditi" ); 
        categoryDataset.setValue(3,"Marks" ,"Pooja" ); 
        categoryDataset.setValue(10,"Marks" ,"Ria" ); 
        categoryDataset.setValue(5,"Marks" ,"Twinkle" ); 
        categoryDataset.setValue(20,"Marks" ,"Rutvi" );

        return categoryDataset;
    }

    private JFreeChart createChart(DefaultCategoryDataset dataset, String title) {

        JFreeChart chart = ChartFactory.createBarChart(
            title,                  // chart title
            "Students",              // X-Axis label
            "Marks",                 // Y-Axis label,
            dataset,
            PlotOrientation.VERTICAL,      //Plot orientation 
            false,                // Show legend 
            true,                // Use tooltips 
            false                // Generate URLs 
        );

        chart.getTitle().setPaint(Color.BLUE);    // Set the colour of the title 
        chart.setBackgroundPaint(Color.WHITE);    // Set the background colour of the chart
        CategoryPlot cp = (CategoryPlot ) chart.getPlot();
        cp.setBackgroundPaint(Color.CYAN);      
        cp.setRangeGridlinePaint(Color.RED);

        return chart;
    }
}



import javax.swing.JFrame;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;


public class XYAreaChart extends JFrame {

    private static final long serialVersionUID = 1L;

    public XYAreaChart(String applicationTitle, String chartTitle) {
        super(applicationTitle);

        XYSeries series = createDataset();
        XYDataset xydataset = new XYSeriesCollection(series);
        JFreeChart chart = createXYAreaChart(xydataset, chartTitle);
        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        setContentPane(chartPanel);
    }

    private  XYSeries createDataset() {
        XYSeries result = new XYSeries ("Average Size");
        result.add(20, 29);
        result.add(40, 20);
        result.add(78, 51);

        return result;
    }

    private JFreeChart createXYAreaChart(XYDataset xydataset, String title) {
 
        JFreeChart chart = ChartFactory.createXYAreaChart(
            title,                  // chart title
            "Height",           // X-Axis label
            "Weight",           // Y-Axis label
            xydataset,          // Dataset
            PlotOrientation.VERTICAL,
            true,            // include legend
            true,            // tooltips
            true             // urls
        );

        XYPlot plot = (XYPlot) chart.getXYPlot();
        plot.setForegroundAlpha(0.5f);
        return chart;
    }
}



import javax.swing.JFrame;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;


public class XYLineChart extends JFrame {

    private static final long serialVersionUID = 1L;

    public XYLineChart(String applicationTitle, String chartTitle) {
        super(applicationTitle);

        XYSeries series = createDataset();
        XYDataset xydataset = new XYSeriesCollection(series);
        JFreeChart chart = createXYLineChart(xydataset, chartTitle);
        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        setContentPane(chartPanel);
    }

    private  XYSeries createDataset() {
        XYSeries result = new XYSeries ("Average Size");
        result.add(20, 29);
        result.add(40, 20);
        result.add(78, 51);

        return result;
    }

    private JFreeChart createXYLineChart(XYDataset xydataset, String title) {

        JFreeChart chart = ChartFactory.createXYLineChart(
            title,                  // chart title
            "Height",           // X-Axis label
            "Weight",           // Y-Axis label
            xydataset,          // Dataset
            PlotOrientation.VERTICAL,
            true,            // include legend
            true,            // tooltips
            true             // urls
        );

        XYPlot plot = (XYPlot) chart.getXYPlot();
        plot.setForegroundAlpha(0.5f);
  
        return chart;
    }
}



import javax.swing.JFrame;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;


public class XYStepAreaChart extends JFrame {

    private static final long serialVersionUID = 1L;

    public XYStepAreaChart(String applicationTitle, String chartTitle) {
        super(applicationTitle);

        XYSeries series = createDataset();
        XYDataset xydataset = new XYSeriesCollection(series);

        JFreeChart stepAreaChart = createXYStepAreaChart(xydataset, chartTitle);
        ChartPanel stepAreaChartPanel = new ChartPanel(stepAreaChart);
        stepAreaChartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        setContentPane(stepAreaChartPanel);
    }

    private  XYSeries createDataset() {
        XYSeries result = new XYSeries ("Average Size");

        result.add(20, 29);
        result.add(40, 20);
        result.add(78, 51);
  
        return result;
    }

    private JFreeChart createXYStepAreaChart(XYDataset xydataset, String title) {
        JFreeChart chart = ChartFactory.createXYStepAreaChart(
            title,                  // chart title
            "Height",           // X-Axis label
            "Weight",           // Y-Axis label
            xydataset,          // Dataset
            PlotOrientation.VERTICAL,
            true,            // include legend
            true,            // tooltips
            true             // urls
        );

        XYPlot plot = (XYPlot) chart.getXYPlot();
        plot.setForegroundAlpha(0.5f);
        return chart;
    }
}