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 ());