Thursday, October 14, 2010

New website

Just finished off putting together a new landscaping website for a good friend of a friend. seascapeslandscaping.com.au

Tuesday, September 28, 2010

New workout music shop 10minutetracks.com

Lately I have been following the "The 10-Minute Total Body Breakthrough" which is a very good book in getting into shape with a minimal amount of time.

My friend Jeremy asked me to help him create this website to sell the music he and his friend created follows the books workout pattern.


10 Minute Tracks

Thursday, September 09, 2010

Wednesday, August 04, 2010

maven, ant, ivy where should we all go?

well at work I've been working on making our chopped up monolithic application more manageable.

the problem is that we use to have 1 project, now we have around 11 or so. each has their on library folder. At this point in time its an easy thing to deal with, in a years time when we start getting jars updated, its going to be a big pain in the a#se.

so I've been learning alot about maven and have started to implement it into our small applications and now I'm up to the corner stone of the project.

pull all the artifacts together and make an install script.

as its a custom piece of code that users ant and bash with uuencode and many other bits and pieces, i was not going to even try making a maven plugin to make my install.sh file.

i looked into ivy and found that it does not use the same local repository structure as maven but can use nexus.. so not good.

but then i found http://ptrthomas.wordpress.com/2009/03/08/why-you-should-use-the-maven-ant-tasks-instead-of-maven-or-ivy/

it seems you can pull in maven dependency's into ant and use them there.

my current thinking is to use the maven ant task to extract all the war's and config files in the maven local or remote repository and let ant/bash do its magic to make my custom install.sh file :)

Friday, April 16, 2010

Code To test internal generic methods with user code in them

How does one test this code

public String SendMessage(String request) throws JMSException {

TextMessage reply = (TextMessage) jmsTemplate.execute(new ProducerCallback() {
public Object doInJms(Session session,MessageProducer producer) throws JMSException {
TemporaryQueue queue = session.createTemporaryQueue();
TextMessage message = session.createTextMessage();
message.setText("Some Text");
message.setJMSReplyTo(queue);
producer.send(message);
return session.createConsumer(queue).receive(10000);
}
});

if (reply != null){
// System.err.println("Message recieved");
} else{
// System.err.println("*** NOT received");
}

return reply.getText();

}


here is my junit mockito 1.8 test


import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.TemporaryQueue;
import javax.jms.TextMessage;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;

import static org.mockito.Mockito.*;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.ProducerCallback;

import com.sun.messaging.jms.Session;

public class PrivateMessageSenderTest {

PrivateMessageSender classUnderTest;
JmsTemplate mockJmsTemplate;
Session mockSession;
MessageProducer mockMessageProducer;
TemporaryQueue mockTemporaryQueue;
TextMessage mockTextMessage;
@Before
public void setUp() throws Exception {
classUnderTest = new OpenMQPrivateMessageSender();

mockJmsTemplate = mock(JmsTemplate.class);
mockSession = mock(Session.class);
mockMessageProducer = mock(MessageProducer.class);
mockTemporaryQueue = mock(TemporaryQueue.class);
mockTextMessage = mock(TextMessage.class);

/** Boiler plate mock code to inject mock session and messageProducer into
* Generic Spring ProducerCallback class which has our internal code
* To test
**/
when(mockJmsTemplate.execute((ProducerCallback)anyObject())).thenAnswer(
new Answer() {
public Object answer(InvocationOnMock invocation) throws JMSException {
Object[] args = invocation.getArguments();
//Object mock = invocation.getMock();
return ((ProducerCallback)args[0]).doInJms(mockSession, mockMessageProducer);
}
});

when(mockSession.createTemporaryQueue()).thenReturn(mockTemporaryQueue);
when(mockSession.createTextMessage()).thenReturn(mockTextMessage);



its missing the tests for it, but this pretty much sets it up to set mocks into the internal method.

Monday, January 25, 2010

best ssh code snippet

This code snippet ssh's into the account you want to add your public key to.

The usual way to do that is to copy the key over then follow the key to the server and append it to the end.

e.g.

scp ~/.ssh/id_dsa.pub user@host:.
ssh user@host 'cat id_dsa.pub >> ~/.ssh/authorized_keys'

You can do it all in one line.

ssh user@host 'mkdir ~/.ssh;echo '`cat ~/.ssh/id_dsa.pub`' >> ~/.ssh/authorized_keys'

Be careful with the >> if you accidently do a single >, then bye bye original file. You will be able to log in but everyone else who had their key in it cant as your key is now only in that file.

this snippet came from http://snippets.dzone.com/posts/show/2335