Posts

Showing posts from May, 2012

SoapUI 4.5.0 Project XML File Encoding Problem

Image
I' ve been already using SoapUI Pro 3.6.1 since license expires. Previous migrations to soapUI newer versions had not caused problems but when starting using SoapUI 4.5.0(free) version resulted destroying existing projects. I checked log file ("C:\...\SmartBear\soapUI-4.5.0\bin\soapui.log") and realised that something went wrong about encoding of soapUI project XMLs. Turkish language characters in wsdl files are located in soapUI project XMLs and they are violating cp1254 character convention and causes below exception log.  java.io.CharConversionException: Malformed UTF-8 character: 0xc5 0x3f at org.apache.xmlbeans.impl.piccolo.xml.UTF8XMLDecoder.decode(UTF8XMLDecoder.java:80) at org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader$FastStreamDecoder.read(XMLStreamReader.java:762) at org.apache.xmlbeans.impl.piccolo.xml.XMLStreamReader.read(XMLStreamReader.java:162) at org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yy_refill(PiccoloLexer.java:3474) at org.apac

Groovy Script for Runing Processes & Commands

Groovy is bringing power and flexibility of Java to its script environment, and making development simpler. Starting a command and runing a new process in groovy is much more pragmatic than java . String class in groovy has execute method to run content of string as in command line. For example: "mspaint".execute() I implemented a groovy script to run 7-Zip to compress eclipse workspaces into a backup file at specified output path. Path list of workspaces is kept in a *.properties file to easily gather them with using java.util.ResourceBundle ; then use output file path and workspace path list as parameter to 7z program. In order to use ResourceBundle without problem, *.properties file must be located in the same directory with groovy script. // TIMESTAMP OF SCRIPT START def timestamp = System.currentTimeMillis() def outputDir = "D:\\Projects\\Backups\\" if(this.args.size() > 0) { //////////////////////////////////////// println "\nOUTPUT PATH:

Mutable and Immutable Classes in Java

"In object-oriented and functional programming, an immutable object is an object whose state cannot be modified after it is created. This is in contrast to a mutable object , which can be modified after it is created." In Java, String is popular with being immutable class that had forced me understand what certainly immutable class is. The definition of being immutable object depends on its state; but what does state depend on or how can we protect an object's state? Lets look at the following class: public class Immutable { private long createdTime = System.currentTimeMillis(); @Override public String toString() { return "Immutable:" + this.createdTime; } } The state of a class refers to keeping instance variables(attributes) constant. As in the example; this class has a single attribute that holds the created time-stamp in primitive long type and has no public method that can change any attribute( createdTime ) of this class. So far, this

Dead Code Elimination in Java 1.6

"Dead code" is part of source code that compiler infers that its result is not used and does not affect output of program. Obvious dead code inferences can be difficult to evaluate for compiler, since it requires longer time for detailed code analysis. Thus, it might be impossible to decide on whether a part of code is dead or not. Compilers avoid from detailed analysis for sake of precise and faster throughput. int unusedVariables() { int x = 5 * 5; // unused variable = dead code = dead variable // compiler warning occurs in JDK 1.6.0.30 return 5 * 5; } The definition is mentioning about a part of source code, but exactly how many lines of source code, or how many expressions should be evaluated in compile time to detect dead code. Eliminating dead code problem challenge becomes more complex while considering multiple lines of code evaluation. int unusedVariables() { int x1, x2 = 0; x1 = x2; x2 = x1; // both x1 and x2 is dead and doesn'