Monday, December 5, 2011

Tuesday, November 15, 2011

Eclipse class decompiler javap

Run->External Tools->External Tools Configuration
Location:
${system_path:javap}
Working directory:
${project_loc}
Arguments:
-classpath ${project_loc}\target\classes -c ${java_type_name}

Wednesday, October 26, 2011

CODE COVERAGE AND CONFIGURATION

http://www.javacodegeeks.com/2011/10/code-coverage-with-unit-integration.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+JavaCodeGeeks+%28Java+Code+Geeks%29&utm_content=Google+Reader

Thursday, October 20, 2011

PGP key Check

wget http://nginx.org/download/nginx-0.8.35.tar.gz
wget http://nginx.org/download/nginx-0.8.35.tar.gz.asc
gpg nginx-0.8.35.tar.gz.asc
gpg --keyserver pgpkeys.mit.edu --recv-key

Tuesday, September 6, 2011

Crossite Request

Sometimes it is nessesary to execute AJAX cross site request.
For Chrome

--disable-web-security --allow-file-access-from-files

Friday, August 19, 2011

WHO IS

To check who is connected to server:
qwinsta /server:SERVER_IP
To disconnect user
rwinsta /server:SERVER_IP SESSION_ID

Thursday, August 4, 2011

Friday, July 8, 2011

Java web services: performance comparison

http://www.ibm.com/developerworks/webservices/library/j-jws14/index.html?ca=drs-

Wednesday, June 22, 2011

Friday, June 10, 2011

MVC REST

Since spring v.3 provide REST WEBSERVICE features.
git@github.com:sirtoxy/mvcrest.git
Test and try yourself.

Wednesday, May 11, 2011

WS-Security with SOAP UI

KEYTOOL CERTIFICATE GENERATION

keytool -genkey -alias bookstoreclient -keypass keypassword -keystore client-keystore.jks -storepass b00k5t0r3 -dname "cn=bookstore" -keyalg RSA
keytool -selfcert -alias bookstoreclient -keystore client-keystore.jks -storepass b00k5t0r3 -keypass keypassword
keytool -export -alias bookstoreclient -file key.rsa -keystore client-keystore.jks -storepass b00k5t0r3
keytool -import -noprompt -alias bookstoreclient -file key.rsa -keystore server-keystore.jks -storepass b00k5t0r3

SERVER_SIGN.PROPERTIES

org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
org.apache.ws.security.crypto.merlin.keystore.type=jks
org.apache.ws.security.crypto.merlin.keystore.password=b00k5t0r3
org.apache.ws.security.crypto.merlin.file=C:\\certificates\\server-keystore.jks

CXF

<bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<constructor-arg>
<map>
<entry key="action" value="Timestamp Signature">
<entry key="signaturePropFile" value="server_sign.properties">
</entry>
</map>
</constructor-arg>
</bean>




RESOLVE MACHINE NAME TO HOST NAME

1. Find you ID



2. Apply patch as described here

cscript.exe //nologo %systemdrive%\inetpub\adminscripts\adsutil.vbs set W3SVC/your_website_identifier_here/SecureBindings “:443:my.publicserver.com”

3. Restart IIS

Wednesday, April 27, 2011

SOPA Styles

//DOCUMENT LITERAL WRAPPED
//DOCUMENT LITERAL BARE
//RPC ENCODED WRAPPED
//RPC LITERAL WRAPPED

Monday, April 4, 2011

Eclipse best plugins

http://download.eclipse.org/tools/ajdt/36/update
http://eclipse-cs.sourceforge.net/update
http://update.eclemma.org
http://m2eclipse.sonatype.org/sites/m2e
http://www.springsource.com/update/e3.5
http://findbugs.cs.umd.edu/eclipse

Thursday, March 31, 2011

Timezone

aptitude update tzdata
zdump -v America/Chicago | grep 2011

#epoch time 1970-01-01 00:00:00 UTC
date +%s

#epoch time of 12 Jan 2010 16:44:12 UTC
date -d "12 Jan 2010 16:44:12 UTC" +%s

#convert epoch time to readable date
date -d @371407800


//Windows
java -jar tzupdater.jar -f -bc -u

Tuesday, March 29, 2011

Java Mocking Operations

It is became common to use Mocking in java projrcts. But there are not so much examples from Mockito project. So Here is the examples how to do some test with Mockito.
Add maven dependency:
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>

First you have to specify the following:

@RunWith(MockitoJUnitRunner.class)
public class YourTest

To mock any object you can use 2 approaches:

@Mock
private YourObject yourObject;

or

YourObject yourObject = mock(YourObject.class);

Verify operations example:
when(classField.getSpecificMethod()).thenReturn(stub value);
verify(classField).getSpecificMethod();
verifyNoMoreInteractions(classField);

verify(classField, atLeast(1)).getSpecificMethod();
*atLeast(1) can be replaced with: atLeastOnce(), never()

Exception generation:
YourException yourException = mock(YourException.class);
doThrow(yourException).when(classField).getSpecificMethod();
when(classField.getSpecificMethod(any(Class.class),anyInt())).thenThrow(new YourException ());

Thursday, March 24, 2011

SMB usage

smbclient '//computername/sharefolder' --workgroup=domainname --user=user
lcd /
put or get filename

Example: copy file to you windows machine

smbclient '//computername/sharefolder' --workgroup=domainname --user=user
lcd /path/to/file
put file.name

Friday, March 11, 2011

SSL keystore

By default keystore is users directory (example: C:\Users\myname\.keystore)

%JAVA_HOME%\bin>keytool.exe -importcert -file PATH_TO_CERT.cer –v
keytool.exe –list
%JAVA_HOME%\bin>keytool.exe -printcert - file PATH_TO_CERT.cer

Friday, March 4, 2011

Constructor chain execution with overriding methods inside

Note that when the Base constructor is called from within the Sub constructor, "this" clearly refers to an instance of Sub, not Base. Even though "this" has not been completely constructed yet, the JVM knows what class it will ultimately be. This is how it's able call overriding methods from the constructor.

Tuesday, February 22, 2011

Ruby Cucumber BDD for Java devs

Nice article how to integrate cucumber into java project.
http://www.goodercode.com/wp/using-cucumber-tests-with-maven-and-java
Change cuke4duke version to 0.4.3 and picocotainer to 2.10.2
Happy BDD!

Friday, February 18, 2011

Ruby 1.9 configuration

http://ascarter.net/2011/01/02/rails-development-on-ubuntu-10.10.html

Thursday, February 10, 2011

SMTP (RFC822) testing

telnet mailhost port
EHLO
MAIL FROM: email
RCPT TO: email
DATA
Subject:
From:
To:
ENTER
message text
.

Tuesday, January 18, 2011

Regexp-Commander

From 20-04-2010
To 2010-04-20

([^0-9])([0-9][0-9])/([0-9][0-9])/([0-9][0-9][0-9][0-9])([^0-9])
\1\4-\3-\2\5