Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Friday, May 28, 2010

Selenium Testing articles

1) http://blogs.atlassian.com/developer/2009/06/selenium_testing_with_windows.html

2) http://www.thoughtworks-studios.com/twist-agile-test-automation/1.0/help/how_do_i_use_selenium_to_test_https_sites.html

3) http://yuce.tekol.net/2009/10/web-application-testing-with-selenium.html

Saturday, May 08, 2010

Tuesday, April 06, 2010

ETL4ALL look like a good bet for small companies

Here is a link to ETL4ALL company website.

http://www.ikan.be/

Converting XML with XSLT and Java

Here is the code in Java to do this. No external library is needed.


import java.io.*;

/**
* A simple demo of JAXP 1.1
*/
public class SimpleJaxp {

/**
* Accept two command line arguments: the name of
* an XML file, and the name of an XSLT stylesheet.
* The result of the transformation
* is written to stdout.
*/
public static void main(String[] args)
throws javax.xml.transform.TransformerException {
if (args.length != 2) {
System.err.println("Usage:");
System.err.println(" java " + SimpleJaxp.class.getName( )
+ " xmlFileName xsltFileName");
System.exit(1);
}

File xmlFile = new File(args[0]);
File xsltFile = new File(args[1]);

javax.xml.transform.Source xmlSource =
new javax.xml.transform.stream.StreamSource(xmlFile);
javax.xml.transform.Source xsltSource =
new javax.xml.transform.stream.StreamSource(xsltFile);
javax.xml.transform.Result result =
new javax.xml.transform.stream.StreamResult(System.out);

// create an instance of TransformerFactory
javax.xml.transform.TransformerFactory transFact =
javax.xml.transform.TransformerFactory.newInstance( );

javax.xml.transform.Transformer trans =
transFact.newTransformer(xsltSource);

trans.transform(xmlSource, result);
}
}

Saturday, March 20, 2010

Bash commands from Java: Good way

A string can be executed in the standard java way:
def command = """ping -c1 -W1 hostname""" // Create the String
def proc = command.execute() // Call *execute* on the string
proc.waitFor() // Wait for the command to finish

// Obtain status and output
println "return code: ${ proc.exitValue()}"
println "stderr: ${proc.err.text}"
println "stdout: ${proc.in.text}" // *out* from the external program is *in* for groovy

Wednesday, January 27, 2010

Flat file to XML Conversion

If you need to convert flat file to XML look no further. Here is the Java software that can be used for this.

http://servingxml.sourceforge.net/

Thursday, July 16, 2009

JConsole JMX to Weblogic

Hello,

We found a workaround that doesn't need to compile and run a proxy.

Just set JAVA_HOME and BEA_HOME and run:

RedHat
jconsole -J-Djava.class.path=$JAVA_HOME/lib/jconsole.jar:/usr/bea40/wlserver_10.3/server/lib/wljmxclient.jar -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote

Windows
jconsole -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar;%BEA_HOME%\wlserver_10.3\server\lib\wljmxclient.jar -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote


Connection string:
service:jmx:rmi:///jndi/iiop://localhost:7001/weblogic.management.mbeanservers.domainruntime



----------------------------------------


1. After having the same issue, it turned out that it is just a CLASSPATH issue when using jConsole from the latest SUN JVM:

a) Working for connect string starting with 'service:jmx:rmi:///jndi/iiop://...' only.
set JAVA_HOME=D:\SUN_jdk1.6.0_13
set PATH=%JAVA_HOME%\bin;%PATH%
jconsole -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar;%bea_home%\wlserver_10.3\server\lib\wljmxclient.jar

b) Working for connect string starting with 'service:jmx:rmi:///jndi/iiop://...' and 'service:jmx:iiop:///jndi/iiop://...' .

set JAVA_HOME=D:\SUN_jdk1.6.0_13
set PATH=%JAVA_HOME%\bin;%PATH%
jconsole -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar;%bea_home%\wlserver_10.3\server\lib\weblogic.jar

NOTE: The RMI or IIOP in the connect string!

c) I tried the following URLs that worked fine:

* service:jmx:rmi:///jndi/iiop://localhost:7001/weblogic.management.mbeanservers.runtime

* service:jmx:iiop:///jndi/iiop://localhost:7001/weblogic.management.mbeanservers.runtime

* service:jmx:rmi:///jndi/iiop://localhost:7001/weblogic.management.mbeanservers.domainruntime

* service:jmx:iiop:///jndi/iiop://localhost:7001/weblogic.management.mbeanservers.domainruntime

2. In addition, the parameter -J-Djmx.remote.proto.provider.pkgs=weblogic.management.remote can be set if the current version of the JVM has any issue:

jconsole -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar;%bea_home%\wlserver_10.3\server\lib\wljmxclient.jar -J-Djmx.remote.proto.provider.pkgs=weblogic.management.remote

I hope this helps a bit!

Thursday, May 21, 2009

Learn how to create Menu in Swing

import java.awt.*;import java.awt.event.*;
import javax.swing.*;import java.util.*;import java.io.*;import java.util.*;import java.lang.*;

public class JZip {

public Container createContentPane() {
//Create the content-pane-to-be.
JPanel contentPane = new JPanel(new BorderLayout());
contentPane.setOpaque(true);

//Create a scrolled text area.
JTextArea output = new JTextArea(5, 30);
output.setEditable(false);
JScrollPane scrollPane = new JScrollPane(output);

//Add the text area to the content pane.
contentPane.add(scrollPane, BorderLayout.CENTER);
return contentPane;
}

public JMenuBar createMenuBar() {
JMenuBar menuBar;
JMenuItem menuItem;
JRadioButtonMenuItem rbMenuItem;
JCheckBoxMenuItem cbMenuItem;

//Create the menu bar.
menuBar = new JMenuBar();

//Build the first menu.
JMenu fileMenu = new JMenu( "File");
JMenu editMenu = new JMenu("Edit");
JMenu exitMenu = new JMenu("Exit");

fileMenu.setMnemonic(KeyEvent.VK_F);
fileMenu.getAccessibleContext().setAccessibleDescription("This is Description");
exitMenu.setMnemonic(KeyEvent.VK_X);

JMenuItem fileNewMenuItem = new JMenuItem("New", KeyEvent.VK_N);
JMenuItem fileOpenMenuItem = new JMenuItem("Open", KeyEvent.VK_N);

fileMenu.add(fileNewMenuItem);
fileMenu.add(fileOpenMenuItem);

menuBar.add(fileMenu);
menuBar.add(editMenu);
menuBar.add(exitMenu);
return menuBar;
}

/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("Jzip");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Create and set up the content pane.
JZip mainGUI = new JZip();
frame.setJMenuBar(mainGUI.createMenuBar());
frame.setContentPane(mainGUI.createContentPane());

//Display the window.
frame.setSize(450, 260);
frame.setVisible(true);
}

public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}

Tuesday, May 19, 2009

Some other good Ant scripts

Here are some good ant scripts

http://www.java2s.com/Code/Java/Ant/CatalogAnt.htm

Good Ant Tutorial

Here is a good Ant Tutorial which teach you how to write modular build

http://i-proving.ca/space/Technologies/Ant+Tutorial