Latest Headlines

JMocking for SIP testing.

Part of my current project to implement a fully JEE IP Telephony stack is to obviously take the time to brainstorm designs and to come up with proof of concepts. I am currently did a bit of coding writing an abstracted media facade layer to wrap libraries like JSR390 for instance. I spend time to implement the following JMock Expectation for SIP interaction.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
 
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.sip.Address;
import javax.servlet.sip.ServletParseException;
import javax.servlet.sip.SipApplicationSession;
import javax.servlet.sip.SipFactory;
import javax.servlet.sip.SipServlet;
import javax.servlet.sip.SipServletRequest;
import javax.servlet.sip.SipServletResponse;
import javax.servlet.sip.SipSession;
 
import org.jmock.Expectations;
import org.jmock.api.Invocation;
import org.jmock.integration.junit3.MockObjectTestCase;
import org.jmock.lib.action.CustomAction;
 
public class SipExpectations extends Expectations {
 
	private SipServletRequest sipRequest;
	private SipSession sipSession;
	private ServletConfig servletConfig;
	private ServletContext servletContext;
	private SipFactory sipFactory;
	private SipApplicationSession sipApplicationSession;
	private SipServletResponse sipResponse;
	private Address sipAddress;
 
	private String sipMethod;
	private String contentValue;
	private String contentType;
 
	private Map sessionValues = new HashMap();
	private Map requestValues = new HashMap();
 
	public SipExpectations(MockObjectTestCase mockTest) throws IOException, ServletParseException {
		sipRequest = mockTest.mock(SipServletRequest.class);
		sipSession = mockTest.mock(SipSession.class);
		servletConfig = mockTest.mock(ServletConfig.class);
		servletContext = mockTest.mock(ServletContext.class);
		sipFactory = mockTest.mock(SipFactory.class);
		sipApplicationSession = mockTest.mock(SipApplicationSession.class);
		sipResponse = mockTest.mock(SipServletResponse.class);
		sipAddress = mockTest.mock(Address.class);
 
		allowing(sipSession).createRequest(with(any(String.class))); will(returnValue(sipRequest));
 
		allowing(servletConfig).getServletContext(); will(returnValue(servletContext));
		allowing(servletContext).getAttribute(SipServlet.SIP_FACTORY); will(returnValue(sipFactory));
 
		allowing(sipFactory).createApplicationSession(); will(returnValue(sipApplicationSession));
		allowing(sipFactory).createRequest(with(any(SipApplicationSession.class)), with(any(String.class)), with(any(String.class)), with(any(String.class))); will(returnValue(sipRequest));
 
		allowing(sipSession).setAttribute(with(any(String.class)), with(any(Object.class))); will(new CustomAction("session.setAttribute") {
			@Override
			public Object invoke(Invocation invocation) throws Throwable {
				sessionValues.put(invocation.getParameter(0).toString(), invocation.getParameter(1));
				return null;
			}
		});
 
		allowing(sipSession).getAttribute(with(any(String.class))); will(new CustomAction("session.getAttribute") {
			@Override
			public Object invoke(Invocation invocation) throws Throwable {
				return sessionValues.get(invocation.getParameter(0));
			}
		});
 
		allowing(sipRequest).setAttribute(with(any(String.class)), with(any(Object.class))); will(new CustomAction("request.setAttribute") {
			@Override
			public Object invoke(Invocation invocation) throws Throwable {
				requestValues.put(invocation.getParameter(0).toString(), invocation.getParameter(1));
				return null;
			}
		});
 
		allowing(sipRequest).getAttribute(with(any(String.class))); will(new CustomAction("request.getAttribute") {
			@Override
			public Object invoke(Invocation invocation) throws Throwable {
				return requestValues.get(invocation.getParameter(0));
			}
		});
		allowing(sipRequest).createResponse(with(any(Integer.class))); will(returnValue(sipResponse));
		allowing(sipRequest).setContent(with(any(Object.class)), with(any(String.class)));
		allowing(sipRequest).send(); will(new CustomAction("sipRequest.send") {
 
			@Override
			public Object invoke(Invocation invocation) throws Throwable {
				System.out.println("\nSip Request Send\nContent Type: " + contentType + "\nContent Value: " + contentValue+"\n");
				return null;
			}
		});
		allowing(sipRequest).getSession(); will(returnValue(sipSession));
 
		allowing(sipResponse).getMethod(); will(new CustomAction("sipResponse.getMethod") {
 
			@Override
			public Object invoke(Invocation invocation) throws Throwable {
				return getSipMethod();
			}
		});
		allowing(sipResponse).getContent(); will(new CustomAction("sipResponse.getContent") {
 
			@Override
			public Object invoke(Invocation invocation) throws Throwable {
				return getContentValue();
			}
		});
		allowing(sipResponse).getContentType(); will(new CustomAction("sipResponse.getContentType") {
 
			@Override
			public Object invoke(Invocation invocation) throws Throwable {
				return getContentType();
			}
		});
		allowing(sipResponse).getStatus(); will(returnValue(SipServletResponse.SC_OK));
 
		allowing(sipResponse).getSession(); will(returnValue(sipSession));
		allowing(sipResponse).createAck(); will(returnValue(sipRequest));
		allowing(sipResponse).getTo(); will(returnValue(sipAddress));
		allowing(sipResponse).send();
 
		allowing(sipAddress).getParameter("tag"); will(returnValue(UUID.randomUUID().toString()));
 
	}
 
	public SipSession getSipSession() {
		return sipSession;
	}
 
	public ServletConfig getServletConfig() {
		return servletConfig;
	}
 
	public ServletContext getServletContext() {
		return servletContext;
	}
 
	public SipFactory getSipFactory() {
		return sipFactory;
	}
 
	public SipServletRequest getSipRequest() {
		return sipRequest;
	}
 
	public SipApplicationSession getSipApplicationSession() {
		return sipApplicationSession;
	}
 
	public SipServletResponse getSipResponse() {
		return sipResponse;
	}
 
	public Map getSessionValues() {
		return sessionValues;
	}
 
	public Map getRequestValues() {
		return requestValues;
	}
 
	public String getContentValue() {
		return contentValue;
	}
 
	public void setContentValue(String contentValue) {
		this.contentValue = contentValue;
	}
 
	public String getContentType() {
		return contentType;
	}
 
	public void setContentType(String contentType) {
		this.contentType = contentType;
	}
 
	public String getSipMethod() {
		return sipMethod;
	}
 
	public void setSipMethod(String sipMethod) {
		this.sipMethod = sipMethod;
	}
 
}

Not complete though it is good enough to simple functional test relying on SIP communication to another server. For example:

public class MockTest extends MockObjectTestCase {
 
	public void testMockInvoke() {
 
		try {
 
			SipExpectations sipExp = new SipExpectations(this);
			checking(sipExp);
 
			SipServletRequest request = sipExp.getSipSession().createRequest("INFO");
			request.setContent("Hallo", "sip/text");
			request.send();
 
			sipExp.setContentType("sip/text");
			sipExp.setContentValue("Bye");
			sipExp.setSipMethod("INFO");
			YourSipServletImplementationInstance.doResponse(sipExp.getSipResponse());
 
		} catch (Exception e) {
			e.printStackTrace();
		}
 
	}
 
}

Social Media and Mind Reading

The other day I was chatting with someone about what Facebook and Twitter and the sort is all about. During our discussion I got a bit of brainwave why people actually choose to do it, and what social media is all about. And it all came down to opinion.

No person in his/her life did not wish if they could read someone else’s mind. Either at work, a relationship or a friend. The reoccurring question of “What is he thinking?”. A concept that most people want to be able to do, especially the government. But conspiracy theories aside, what if we can get thoughts out of people’s minds without brain probing them. Enter social media… Everyday people are just blurting there every though in that comes to mind onto social media services, and these mainly consists of opinion and perceptions. What better way to read someones thought by simply going through all his twitter updates. Mind reading is obsolete, now that the mindset has been embedded into to world to share your mind with it. If you have been a member of one of these services for while, think back of all the updates you made over the last few years and how many of it has come to be as personal thoughts.

So will Facebook and Twitter like service be as phenomenal if they only consist of pure factual information and statements (like a news feed), and not out of opinions and perceptions. It is almost like asking someone what would he rather read? an Encyclopedia volume or someone’s personal diary.

JSR309 Implementation attempt.

Part of a process to redesign our IP Telephony offering is to try and implement a JSR309 container for the current media server we are using. With the main goal to follow standards to be more adaptable and modular, these unfortunately has not exactly gone to plan.

JSR309 is currently in its final state in the JCP. In the last couple of days I made an attempt implement the JSR309 specification for a particular media server which utilizes SIP/MSML as its controlling interface. It came apparent very early that the model behind JSR309 is simply just to broad. The current available media servers in the market has such a wide array of communication protocols and controlling interfaces, try to wrap it all in a single standard interface is definitely not an easy task. Unfortunately I am of the opinion that the JSR309 spec is simply too broad. It took me less than 1 day to design a simply, effective and extendable framework to wrap my media dialog implementation for a particular media server. And another 3 days to develop a simple configurable IVR implementation on top of it.

The short of it is that JSR309 will only become the de facto standard once the actually media server vendors start implementing it. And I do not see this actually to start happening within the next 5 years unfortunately, since most media vendors are aggressively driving their particular controlling interface to promote more and more features on there servers.

Work vs. Education

This is the year is my centenary in software development. I can fairly say I have reached a level to been seen as capably and respected professional lead software developer. With the this solid weight of working experience I have learned a hell of a lot of lessons and have not failed to continuously apply them. This year I am as well halfway through my second year of doing my Bsc. IT Software Engineering degree. This as well has been very interesting, frustrating and educational. Take note that I am self taught, and only started doing my degree part-time 4 years ago. Probably one of the biggest frustration of working while studying is that you keep asking “How will this apply in my work in the near future?”.

To thus far I can divide my experience in three phases (almost in line with the 3 year curriculums) . The first being the introduction phase as with most things in life. Simple and interesting, getting back to basics. At this time you know these are the fundamentals of the computer science field, everything else is based of this stuff, although you might not use it directly….ever. Personally I think this is still very important education, as it more so creates the train of thought to better understand the higher level problems and solutions. Having working experience, a lot of this first level information is very forthcoming, sometimes to a point of complete boredom.

Now since being an Ubuntu user, doing course practicals that ‘requires Windows’ has not been a real issue. For first year course you can get away with Dia (diagrams), Eclipse/BlueJ (Java), CodeLite(C/C++), SquirreL (SQL on any DB).

The second phase is where turn out to be more labouring, studying and practising algorithms and designs. These studies thus far have proven more difficult as I have anticipated, for multiple situations. Commonly is when you are overconfident about your prepration for a particular study and fail it. Secondly your get frustrated with the amount of proof you need to provide for solutions, where you know you know it… unfortunately you still have to prove it to your examinators. Hence you can find yourself rushing through work and lose points.

The third phase…well not sure yet. I am still in my second year curriculum, and not sure if my perspective and attitude will or will not stay the same about my studies. On thing is for certain, working and studying is actually very difficult. Not because of the difficulty of the information you have to study, but because of the already set perspective, understanding and approach to the information obtained through years of working in the field. These challenges are very mental and you have to overcome it almost with every new study module at start. But doing ok so far.

Funny programming blog comment

Thought this was bit funny…

“Agile is for hippies.”

That is classic. Actually it’s for hippies w/ego issues and don’t want to be the “fall guy” of a project.

Anyway the list sounds about right, problem is I’ve never found, seen, or heard a “good programmer”, especially the ones that boast about being a great programmer–software always costs more than it should be. That why: a. we’re s/w developers, and b. we’re all crappy programmers.

With AIX, DNS comes first.

Today i struggled on an issues i experienced running load on a Websphere system with a DB2 backend on AIX. No matter  what i did, the container will start accumulating hung threads. Looking at the Java stack traces, they all point to code within the DB2 drivers where it is trying to retrieve the hostname. Similar to ‘InetAddress.getLocalHost‘ in any normal Java application. After some discussion with my peers it came down to a suspicion that the DNS lookup on the hostname was timing out. My thoughts firstly was why the hell is the DB2 drivers doing DNS lookups, but actually it was AIX’s default configuration that name resolutions should be done on bind first and then host files. This can easily be corrected in /etc/netsvc.conf file or set the environment variable ‘NSORDER=local,bind‘. Only question i have left is why AIX by default will force application to do DNS resolutions on host names before looking at the host file?

Quote of the day

Too little abstraction causes frustration, too much abstraction causes insanity.

Java Religion

A fellow technical lead made a comment during a discussion about the design of one our solutions. Being a .Net developer he simply just said “…there is way to many religions in the Java space”. This particular though has been in the back of mind for several weeks now. His aim with this was to point out how there are lots of strong opinions about Java design and implementation out in the world and how technical staff bash heads trying to get their's chosen. I have without doubt participated in these discussion during my career, but lately all I am focused at this point is to deliver solutions that WORKS. I could not care less which standards and practices are follow, as long as it is simple and functions well.

It does pose the question, how should these type of 'heated' discussion be handled. People who are passionate about their work, easily takes offence if their design approached are shot down. They then quickly get despondent and disruptive in the project/company, being sometimes very difficult to work with. People who do things buy the book…well will keep throwing the book at you. In turn they will start throwing the book to your/their superiors and so on until they feel they have acquired the desired attention. These situation has a habit of turning in your classic political games within project/company structures.

Methodologies followings these days also seem to more like religion than ever before. Agile, Domain Driven, Test Driven, RUP and so on. What i do find ironic about this, is that most of these development methodologies started out by intelligent professionals that felt existing methodologies did not work for them, so they came up with their own that fit their way of software development. The next logical step…sell it of as the best thing since slice bread. Now where these guys took their intellect and did something that worked the best for them, so why don't everyone one do it. Instead every software developer will meet a person whom swears by his chosen methodology and refuses to change or adapt it. Why the strict following? Is it because to deem yourself an “expert”, promoting yourself about your peers? Or is it the blind devotion in a manner of doing things, with the expectation that everything will work no matter what solution your implementing.

At the end of the day is usually comes to two outcomes, everything works and everyone is happy…or the solution does not work, and the finger pointing and book throwing starts. What no one seems to realise, is there is no silver bullet way of building software solutions in the Java space. The only thing that a sane Java professional can do is to select frameworks and components in their solutions that give the most benefit for the current requirements. More importantly realise that as requirements change, that certain frameworks and components might fall out of favor and is simple not the best option for the updated requirements. Personally for me a good architect must always design for change, expect the unexpected and design solutions that can adapt with changing requirements and environments. Not to code into a framework, but keep a level of abstraction so that frameworks can be replaced with the least amount of effort and time.

Karmic Release

Karmic is on its way, and people seem to be itching for it. I have loaded the BETA on a workstation at work so far is seems very smooth. Some people have nit-picked on the BETA state of the Gnome installation but myself not worried about this.

One thing that people have been against is the exclusion of Pidgin, which is replaced by Empathy. I for one do not mind chat clients that much as long it works, but Empathy has annoyed me already. There is no proxy support within Empathy, and this an issue for people especially working within corporate environments. Would not be surprise if they switch back to Pidgin in the 10.04 release.

Linux with a Crunchbang!

I recently reloaded my Acer Aspire One with CrunchBang (#!) Linux. Being a very light weight distro with OpenBox Window Manager, it seems like the perfect fit. With the Kuki Linux kernel it really does work well. I have played with several distros lately on my Aspire One, still looking for the perfect fit. Kuki Linux is a distro target for the Aspire One, I might that a go next.


Concerning Crunchbang, it as basic as it comes and i like it. One browser app, one media app, one terminal app…what more do you need. The nice thing about the default media player (VLC) is that they have already most of the media en DVD codecs pre-installed. All hardware seems to work out of the box, there are some write ups on the tuning the cpu fan controls but i have not noticed anything funny yet. With all this reinstalls of distros I am finally experiencing the pro's and cons of the SSD drive, and what effect the performance tuning settings makes to it.