Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.uiconf; import java.awt.Desktop; import java.awt.event.MouseEvent; import java.io.File; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.Iterator; import java.util.Vector; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.xssf.usermodel.XSSFCell; import com.gargoylesoftware.htmlunit.xml.XmlUtil; import com.kaltura.client.KalturaApiException; import com.kaltura.client.KalturaLogger; import com.utils.SeleniumUtils; import com.utils.XmlUtils; /** * * @author oleg.sigalov */ @SuppressWarnings("serial") public class MainWindow extends javax.swing.JFrame { private KalturaLogger logger = KalturaLogger.getLogger(MainWindow.class); public static String projectPath = System.getProperty("user.dir"); public static TestMeConnector prodTestMe = new TestMeConnector(); public static TestMeConnector onPremTestMe = new TestMeConnector(); public static Vector<?> uiConfVectorHolder; public static UiConfContainer uiConfContainer = new UiConfContainer(); public static HashMap<Integer, FailedUiConf> failedUiConfMap = new HashMap<Integer, FailedUiConf>(); public static SeleniumUtils seleniumUtils = null; public static boolean fileIsLoaded = false; public static boolean isConnected = false; public static int uiConfCounter = 0; public Thread threadStart = null; public static boolean threadStopBoolean = false; public static final int BAR_MINIMUM = 0; public static final int BAR_MAXIMUM = 100; public static int uiConfListSize, barSizeUnit = 0; public static ResponseLog responseLog; public static XmlOutput xmlOutput; //Apache machine credentials: public static final String LINUX_HOSTNAME = "extqa3.kaltura.dev"; public static final String LINUX_USERNAME = "root"; public static final String LINUX_PASSWORD = "pepsi69"; public static final String LINUX_PATH = "/opt/lampp/htdocs/uiconf/"; public static final String LINUX_URL = "http://" + MainWindow.LINUX_HOSTNAME + MainWindow.LINUX_PATH.replace("/opt/lampp/htdocs", ""); /** * Creates new form MainWindow */ @SuppressWarnings("rawtypes") public MainWindow() { initComponents(); setControlButtons(false); uiConfVectorHolder = new Vector(); responseLog = new ResponseLog(); // seleniumUtils = new SeleniumUtils(); xmlOutput = new XmlOutput(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); btnStart = new javax.swing.JButton(); btnCancel = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); txtProdPath = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); txtProdSecret = new javax.swing.JTextField(); txtProdPartnerId = new javax.swing.JTextField(); jScrollPane1 = new javax.swing.JScrollPane(); txtConsole = new javax.swing.JTextArea(); jPanel3 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); txtTestPath = new javax.swing.JTextField(); jLabel8 = new javax.swing.JLabel(); txtTestSecret = new javax.swing.JTextField(); jLabel9 = new javax.swing.JLabel(); txtTestPartnerId = new javax.swing.JTextField(); jPanel4 = new javax.swing.JPanel(); btnConnect = new javax.swing.JButton(); btnLoad = new javax.swing.JButton(); lblConnect = new javax.swing.JLabel(); lblLoadFile = new javax.swing.JLabel(); prgsBar = new javax.swing.JProgressBar(); btnClear = new javax.swing.JButton(); btnShowDiff = new javax.swing.JToggleButton(); txtInnerId = new javax.swing.JTextField(); jLabel5 = new javax.swing.JLabel(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); jMenuItem1 = new javax.swing.JMenuItem(); jmnExit = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); jmnOpenAllPlayers = new javax.swing.JMenuItem(); jmnOpenAllKCW = new javax.swing.JMenuItem(); jmnOpenHtmlPlayer = new javax.swing.JMenuItem(); jmnTestMe = new javax.swing.JMenuItem(); jMenu3 = new javax.swing.JMenu(); jMenuItem4 = new javax.swing.JMenuItem(); jMenuItem3 = new javax.swing.JMenuItem(); jMenuItem2 = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Hello " + System.getProperty("user.name") + ", welcome to UiConf Tester"); setResizable(false); btnStart.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N btnStart.setText("Start"); btnStart.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnStartActionPerformed(evt); } }); btnCancel.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N btnCancel.setText("Cancel"); btnCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCancelActionPerformed(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout .setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(btnStart, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(btnCancel) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] { btnCancel, btnStart }); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnStart).addComponent(btnCancel)) .addContainerGap())); jLabel1.setIcon(new javax.swing.ImageIcon("C:\\work\\ws\\UiConfTester\\resources\\kaltura120x96.png")); // NOI18N jLabel3.setIcon( new javax.swing.ImageIcon("C:\\work\\ws\\UiConfTester\\resources\\UiConfTesterLogo165x107.png")); // NOI18N txtProdPath.setText("http://www.kaltura.com/"); jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel4.setText("Prod Path:"); jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel6.setText("Secret:"); jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel7.setText("Partner ID:"); txtProdSecret.setText("46d899681d7ca424e044df69cbac689d"); txtProdPartnerId.setText("1756201"); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout .createSequentialGroup().addContainerGap().addGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(txtProdSecret, javax.swing.GroupLayout.DEFAULT_SIZE, 276, Short.MAX_VALUE) .addComponent(txtProdPartnerId))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup().addGap(12, 12, 12).addComponent( txtProdPath, javax.swing.GroupLayout.PREFERRED_SIZE, 274, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(14, Short.MAX_VALUE))); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtProdPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel6).addComponent(txtProdSecret, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel7).addComponent(txtProdPartnerId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(17, Short.MAX_VALUE))); txtConsole.setColumns(20); txtConsole.setRows(5); jScrollPane1.setViewportView(txtConsole); jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel2.setText("Test Path:"); txtTestPath.setText("http://onprem-falcon9.kaltura.dev/"); txtTestPath.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtTestPathActionPerformed(evt); } }); jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel8.setText("Secret:"); txtTestSecret.setText("b60dad13d29aa080d1c80abcf7a5e777"); jLabel9.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel9.setText("Partner ID:"); txtTestPartnerId.setText("103"); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout .setHorizontalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtTestSecret, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtTestPartnerId, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtTestPath, javax.swing.GroupLayout.PREFERRED_SIZE, 274, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(22, Short.MAX_VALUE))); jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] { txtTestPartnerId, txtTestPath, txtTestSecret }); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtTestPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel8).addComponent(txtTestSecret, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel9).addComponent(txtTestPartnerId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); btnConnect.setText("Connect"); btnConnect.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnConnectActionPerformed(evt); } }); btnLoad.setText("Load File"); btnLoad.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnLoadActionPerformed(evt); } }); lblConnect.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N lblConnect.setText("*Start new session and get KS from both environments"); lblLoadFile.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N lblLoadFile.setText("*Load UiConf configuration excel file"); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblConnect).addComponent(btnConnect)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 141, Short.MAX_VALUE) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(btnLoad).addComponent(lblLoadFile)) .addGap(128, 128, 128))); jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] { btnConnect, btnLoad }); jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnConnect).addComponent(btnLoad)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblConnect).addComponent(lblLoadFile)))); btnClear.setText("Clear"); btnClear.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnClearActionPerformed(evt); } }); btnShowDiff.setText("Show Diff"); btnShowDiff.setEnabled(false); btnShowDiff.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseReleased(java.awt.event.MouseEvent evt) { //btnShowDiffMouseReleased(evt); } }); btnShowDiff.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnShowDiffActionPerformed(evt); } }); txtInnerId.setEnabled(false); jLabel5.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N jLabel5.setText("Enter Inner ID:"); jMenu1.setText("File"); jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.SHIFT_MASK)); jMenuItem1.setText("Extended Log"); jMenuItem1.setEnabled(false); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jMenu1.add(jMenuItem1); jmnExit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.ALT_MASK)); jmnExit.setText("Exit"); jmnExit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jmnExitActionPerformed(evt); } }); jMenu1.add(jmnExit); jMenuBar1.add(jMenu1); jMenu2.setText("Tools"); jmnOpenAllPlayers.setText("Open all players in one HTML page"); jmnOpenAllPlayers.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jmnOpenAllPlayersActionPerformed(evt); } }); jMenu2.add(jmnOpenAllPlayers); jmnOpenAllKCW.setText("Open all KCW types in one HTML page"); jmnOpenAllKCW.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jmnOpenAllKCWActionPerformed(evt); } }); jMenu2.add(jmnOpenAllKCW); jmnOpenHtmlPlayer.setText("Open each player in seperated windows"); jmnOpenHtmlPlayer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jmnOpenHtmlPlayerActionPerformed(evt); } }); jMenu2.add(jmnOpenHtmlPlayer); jmnTestMe.setText("Opne TestMe"); jmnTestMe.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jmnTestMeActionPerformed(evt); } }); jMenu2.add(jmnTestMe); jMenu3.setText("Open Diff Site"); jMenuItem4.setText("diffchecker.com"); jMenuItem4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem4ActionPerformed(evt); } }); jMenu3.add(jMenuItem4); jMenuItem3.setText("text-compare.com"); jMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem3ActionPerformed(evt); } }); jMenu3.add(jMenuItem3); jMenuItem2.setText("quickdiff.com"); jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem2ActionPerformed(evt); } }); jMenu3.add(jMenuItem2); jMenu2.add(jMenu3); jMenuBar1.add(jMenu2); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap(19, Short.MAX_VALUE).addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3).addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(layout.createSequentialGroup().addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(prgsBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout .createSequentialGroup().addGap(0, 0, Short.MAX_VALUE) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtInnerId, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18).addComponent(btnShowDiff) .addGap(33, 33, 33).addComponent(btnClear)))) .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 932, javax.swing.GroupLayout.PREFERRED_SIZE))))); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] { jPanel2, jPanel3 }); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] { btnClear, btnShowDiff }); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup().addContainerGap() .addGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 472, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout .createSequentialGroup() .addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnClear).addComponent(btnShowDiff) .addComponent(txtInnerId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE) .addComponent(prgsBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(12, Short.MAX_VALUE))); pack(); }// </editor-fold>//GEN-END:initComponents @SuppressWarnings("deprecation") private void btnStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStartActionPerformed if (UiConfContainer.getUiConfList().size() > 0) { uiConfListSize = UiConfContainer.uiConfList.size(); barSizeUnit = 100 / uiConfListSize; } if (threadStart != null) { threadStart.stop(); } threadStopBoolean = false; btnStart.setEnabled(false); btnCancel.setEnabled(true); prgsBar.setMinimum(BAR_MINIMUM); prgsBar.setMaximum(BAR_MAXIMUM); prgsBar.setValue(0); threadStart = new Thread() { @Override public void run() { String prodXml = null; String onpremXml = null; UiConf uiConfProd = null; UiConf uiConfOnPrem = null; boolean prodSucc = false; boolean success = true; String host = null; failedUiConfMap.clear(); logger.info("\nStarting to compare XMLs:\n"); for (UiConfEntry uiConfEntry : UiConfContainer.uiConfList) { if (threadStopBoolean)//Cancel button can interrupt { break; } try { success = true; prodSucc = false; uiConfProd = new UiConf(prodTestMe.getClient(), uiConfEntry.getUiConfId(), uiConfEntry.getUiConfType()); //To know on which env we don't get the uiconf prodSucc = true; uiConfOnPrem = new UiConf(onPremTestMe.getClient(), uiConfEntry.getUiConfId(), uiConfEntry.getUiConfType()); if (!uiConfProd.getKalturaUiConf().assertEquals(uiConfOnPrem.getKalturaUiConf())) { logger.info("\n[" + uiConfEntry.getInnerId() + "] Mismatch in UiConf params: " + uiConfEntry.toString());//TODO add counter : inner id success = false; //Add to fails list - will be used for http://www.diffchecker.com/ with Selenium prodXml = uiConfProd.getKalturaUiConf().toParams().toString(); onpremXml = uiConfOnPrem.getKalturaUiConf().toParams().toString(); failedUiConfMap.put(uiConfEntry.getInnerId(), new FailedUiConf(prodXml, onpremXml)); //XmlUtils.computeDiff(prodXml, onpremXml);//TODO need to complete: show diff in extended log } btnShowDiff.setEnabled(true); txtInnerId.setEnabled(true); if (!threadStopBoolean) { //Progress Bar if (uiConfEntry.equals(UiConfContainer.uiConfList.get(uiConfListSize - 1))) { prgsBar.setValue(BAR_MAXIMUM); } else { prgsBar.setValue(prgsBar.getValue() + barSizeUnit); } if (success) { logger.info("[" + uiConfEntry.getInnerId() + "] " + "Extensoin: " + uiConfEntry.getExtension() + " - " + uiConfEntry.getDescription() + "(ID: " + uiConfEntry.getUiConfId() + "): PASSED!\n"); } else { logger.info("[" + uiConfEntry.getInnerId() + "] " + "Extensoin: " + uiConfEntry.getExtension() + " - " + uiConfEntry.getDescription() + "(ID: " + uiConfEntry.getUiConfId() + "): FAILED!\n"); } } } catch (KalturaApiException e) { //Progress Bar if (uiConfEntry.equals(UiConfContainer.uiConfList.get(uiConfListSize - 1))) { prgsBar.setValue(BAR_MAXIMUM); } else { prgsBar.setValue(prgsBar.getValue() + barSizeUnit); } if (prodSucc) { host = MainWindow.txtTestPath.getText(); } else { host = MainWindow.txtProdPath.getText(); } logger.error("[" + uiConfEntry.getInnerId() + "] UiConf DOES NOT EXIST: " + uiConfEntry.toString() + "on " + host + "\n"); e.printStackTrace(); } catch (Exception e) { logger.error(e.getMessage()); e.printStackTrace(); } } if (threadStopBoolean) { logger.info("\nCanceled.\n"); prgsBar.setValue(0); } else { logger.info("\nDone.\n"); } btnStart.setEnabled(true); btnCancel.setEnabled(false); threadStopBoolean = true; threadStart = null; } }; threadStart.start(); }//GEN-LAST:event_btnStartActionPerformed public class FileTypeFilter extends FileFilter { private String extension; private String description; public FileTypeFilter(String extension, String description) { this.extension = extension; this.description = description; } public boolean accept(File file) { if (file.isDirectory()) { return true; } return file.getName().endsWith(extension); } public String getDescription() { return description + String.format(" (*%s)", extension); } } private void btnLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadActionPerformed JFileChooser c = new JFileChooser(); FileFilter xlsFilter = new FileTypeFilter(".xlsx", "Microsoft Excel Documents"); c.addChoosableFileFilter(xlsFilter); c.showOpenDialog(MainWindow.this); File file = c.getSelectedFile(); //Load and parse from xls uiConf list configuration uiConfVectorHolder.clear(); uiConfVectorHolder = XmlUtils.importExcelSheet(file); lblLoadFile.setText(c.getCurrentDirectory().toString() + "\\" + c.getSelectedFile().getName()); lblLoadFile.repaint(); //Create List of UiConfEntry (From xls file) Vector<?> vcell; XSSFCell cell; String extension; String uiConfId; String description; String uiConfType; Iterator<?> it = uiConfVectorHolder.iterator(); while (it.hasNext()) { vcell = (Vector<?>) it.next(); cell = (XSSFCell) vcell.get(0); //extension cell.setCellType(Cell.CELL_TYPE_STRING); extension = cell.getRichStringCellValue().getString(); //Discard first entry if (extension.equals("extension")) { continue; } uiConfCounter++; cell = (XSSFCell) vcell.get(1); //uiConfId cell.setCellType(Cell.CELL_TYPE_STRING); uiConfId = cell.getRichStringCellValue().getString(); cell = (XSSFCell) vcell.get(2); //description cell.setCellType(Cell.CELL_TYPE_STRING); description = cell.getRichStringCellValue().getString(); cell = (XSSFCell) vcell.get(3); //type cell.setCellType(Cell.CELL_TYPE_STRING); uiConfType = cell.getRichStringCellValue().getString(); UiConfContainer.uiConfList.add(new UiConfEntry(uiConfCounter, extension, Integer.valueOf(uiConfId), description, UiConfTypeEnum.getUiConfTypeEnumFromString(uiConfType))); } if (!UiConfContainer.uiConfList.isEmpty()) { fileIsLoaded = true; } if (fileIsLoaded && isConnected) { btnStart.setEnabled(true); jmnOpenHtmlPlayer.setEnabled(true); jmnOpenAllKCW.setEnabled(true); jmnOpenAllPlayers.setEnabled(true); } //Run in new thread - Create HTML test pages Thread thread = new Thread() { @Override public void run() { logger.info("Creating HTML test pages..."); uiConfContainer.preparePlayerHTMLfiles(); logger.info("DONE creating HTML test pages\n"); } }; thread.start(); }//GEN-LAST:event_btnLoadActionPerformed public void setControlButtons(boolean state) { btnStart.setEnabled(state); btnCancel.setEnabled(state); jmnOpenHtmlPlayer.setEnabled(state); jmnOpenAllKCW.setEnabled(state); jmnOpenAllPlayers.setEnabled(state); } private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConnectActionPerformed // String ks; //Connect to TEST environment onPremTestMe = connect(Integer.valueOf(txtTestPartnerId.getText()), txtTestSecret.getText(), txtTestPath.getText()); //Connect to PROD environment prodTestMe = connect(Integer.valueOf(txtProdPartnerId.getText()), txtProdSecret.getText(), txtProdPath.getText()); if (prodTestMe != null && onPremTestMe != null) { isConnected = true; } if (fileIsLoaded && isConnected) { setControlButtons(true); } }//GEN-LAST:event_btnConnectActionPerformed private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed btnStart.setEnabled(true); threadStopBoolean = true; // threadStart.stop(); // threadStart = null; btnCancel.setEnabled(false); }//GEN-LAST:event_btnCancelActionPerformed private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed responseLog.setVisible(true); }//GEN-LAST:event_jMenuItem1ActionPerformed private void jmnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmnExitActionPerformed System.exit(0); }//GEN-LAST:event_jmnExitActionPerformed private void jmnOpenHtmlPlayerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmnOpenHtmlPlayerActionPerformed Thread threadCreate = new Thread() { @Override public void run() { //uiConfContainer.preparePlayerHTMLfiles(); //Open page in Browser try { for (UiConfEntry uiConfEntry : UiConfContainer.getUiConfList()) { if (Desktop.isDesktopSupported() && uiConfEntry.getUiConfType().equals(UiConfTypeEnum.PLAYER)) { { Desktop.getDesktop().browse(new URI(uiConfEntry.getUiConfURL())); } } } } catch (URISyntaxException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); } } }; threadCreate.start(); }//GEN-LAST:event_jmnOpenHtmlPlayerActionPerformed private void jmnTestMeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmnTestMeActionPerformed if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI("https://www.kaltura.com/api_v3/testme/#")); } catch (URISyntaxException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); } } }//GEN-LAST:event_jmnTestMeActionPerformed private void jmnOpenAllPlayersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmnOpenAllPlayersActionPerformed Thread thread = new Thread() { @Override public void run() { //Open page in Browser try { Desktop.getDesktop().browse(new URI(MainWindow.LINUX_URL + UiConf.HTML_PAGE_NAME_ALL_PLAYERS)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; thread.start(); }//GEN-LAST:event_jmnOpenAllPlayersActionPerformed private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearActionPerformed txtConsole.setText(""); }//GEN-LAST:event_btnClearActionPerformed private void txtTestPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTestPathActionPerformed // TODO add your handling code here: }//GEN-LAST:event_txtTestPathActionPerformed private void jmnOpenAllKCWActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmnOpenAllKCWActionPerformed Thread thread = new Thread() { @Override public void run() { //Open page in Browser try { Desktop.getDesktop().browse(new URI(MainWindow.LINUX_URL + UiConf.HTML_PAGE_NAME_ALL_KCW)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; thread.start(); }//GEN-LAST:event_jmnOpenAllKCWActionPerformed private void btnShowDiffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnShowDiffActionPerformed Thread thread = new Thread() { @SuppressWarnings("static-access") @Override public void run() { String text1 = MainWindow.failedUiConfMap.get(Integer.valueOf(txtInnerId.getText())) .getProdUiConfText().replaceAll("\\s{3,}", "\n"); String text2 = MainWindow.failedUiConfMap.get(Integer.valueOf(txtInnerId.getText())) .getOnPremUiConfText().replaceAll("\\s{3,}", "\n"); xmlOutput.setVisible(true); xmlOutput.txtLeft.setText(text1); xmlOutput.txtLeft.repaint(); xmlOutput.txtRight.setText(text2); xmlOutput.txtRight.repaint(); } }; thread.start(); }//GEN-LAST:event_btnShowDiffActionPerformed private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI("http://www.diffchecker.com")); } catch (URISyntaxException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); } } }//GEN-LAST:event_jMenuItem4ActionPerformed private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI("http://text-compare.com")); } catch (URISyntaxException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); } } }//GEN-LAST:event_jMenuItem3ActionPerformed private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI("http://www.quickdiff.com")); } catch (URISyntaxException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); } } }//GEN-LAST:event_jMenuItem2ActionPerformed /** * Connect to environment - get a KalturaClient object */ private TestMeConnector connect(int partnerId, String secret, String path) { TestMeConnector testMeConnector; try { testMeConnector = new TestMeConnector(partnerId, secret, path); //TODO DEBUG //KalturaUiConf kalturaUiConf = testMeConnector.getClient().getUiConfService().get(15333782); } catch (Exception e) { logger.error( "Couldn't connect to " + path + "\nCheck secret: " + secret + "\nAnd Partner ID: " + partnerId); e.printStackTrace(); return null; } logger.info( "Connected Successfully to: " + path + "\nSession ID: \n" + testMeConnector.getSessionId() + "\n"); return testMeConnector; } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MainWindow().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnCancel; private javax.swing.JButton btnClear; private javax.swing.JButton btnConnect; private javax.swing.JButton btnLoad; private javax.swing.JToggleButton btnShowDiff; private javax.swing.JButton btnStart; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JMenu jMenu1; private javax.swing.JMenu jMenu2; private javax.swing.JMenu jMenu3; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuItem jMenuItem2; private javax.swing.JMenuItem jMenuItem3; private javax.swing.JMenuItem jMenuItem4; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JMenuItem jmnExit; private javax.swing.JMenuItem jmnOpenAllKCW; private javax.swing.JMenuItem jmnOpenAllPlayers; private javax.swing.JMenuItem jmnOpenHtmlPlayer; private javax.swing.JMenuItem jmnTestMe; private javax.swing.JLabel lblConnect; private javax.swing.JLabel lblLoadFile; private javax.swing.JProgressBar prgsBar; public static javax.swing.JTextArea txtConsole; private javax.swing.JTextField txtInnerId; private javax.swing.JTextField txtProdPartnerId; public static javax.swing.JTextField txtProdPath; private javax.swing.JTextField txtProdSecret; private javax.swing.JTextField txtTestPartnerId; public static javax.swing.JTextField txtTestPath; private javax.swing.JTextField txtTestSecret; // End of variables declaration//GEN-END:variables }