Nino Martinez’s Weblog

TechBlog about Wicket, Persistence, IOC and Java

Eclipse 3.2 And Subversive

Seems like gremlins in my machine, first time we at work did a branch the branch received changes from trunk. But did not push stuff back to trunk. Merging was simple since the branch always was up to date with trunk and only had a few changes..

Some time passed and we tried doing a new branch, a few problems, but at last we finally made the branch. Worked with it, but now subversive and tortoise refuses to merge the branch back again! I’ve tried a million things. In the end I checked out trunk removed the affected parts and added the ones from the branch and commitet those again. Just to get our system into working order..

My primary suspicion now are that doing branches are very affected by which svn provider you chose, nothings confirmed, but I know we’ve switched providers since the first successful branching.

Any other experiencing troubles with this ancient version of eclipse & subversive?

July 3, 2009 Posted by ninomartinez | JAVA, Nortel SCE | | No Comments Yet

WicketStuff Artwork new release

Ever tired of using endless hours of css’ing just to find out that what you did breaks in IE.. WicketStuff Artwork is all about making your wicket site turn into art, easy. It’s a package consisting of two modules

  1. Liquid
  2. NiftyCornersCube

Both modules will let you do round corners on containers simple and easy, just add a behavior to your wicket component or your page and thats it.
Liquid will let you do all sorts of advanced stuff with your markup containers, for example add a shadowed border, see this screenshot:

Liquid Examples

Liquid Examples

NiftyCornersCube are really quick to render and requires less cpu processing so it has some advantages but are also very limited in effects. See here:

Nifty Examples

Nifty Examples

You can grab the latest snapshot release here:
http://wicketstuff.org/maven/repository/org/wicketstuff/artwork/1.4-SNAPSHOT/

And see howto checkout the examples here:
http://wicketstuff.org/confluence/display/STUFFWIKI/Wiki

Basically it’s just this svn url:
http://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicketstuff-core/artwork-parent/artwork-examples
But you should check out the whole wicketstuff core in order to build dependencies.

Now please come with more ideas and JS libs to add to the Artwork package :) I want to see some comments on how to improve it :)

Regards Nino

May 26, 2009 Posted by ninomartinez | Uncategorized | | No Comments Yet

Cloning Ubuntu installation

Hi you might want to upgrade your disk from time to time, so you either need to clone or ghost it. Heres how I do it.

First prepare the disk with the GUI tool gparted. I like to have a few partitions, one for winblows, one for winblows games, one for ubuntu and one ext3 for storage.

Then copy your system (remember not to have too many apps open at this time wierd stuff could happen once you start up the other disk)
Open a terminal and write:

sudo rsync -a -x --exclude /media/newdisk / /media/newdisk

Make grub active on the new disc, in the same terminal or another write:

grub> setup (hd0) (hd0,0)

Which installs grub into the MBR of hd0 (hda) using the boot files that were already in /boot on hd0,0 (hda1).

Now you can do "kernel (hd0," and then tab in the grub command line to find partitions. Once you identify your drive you should also be able to do the math for the partition.

Okay almost done, now we have to go edit the grub menu.list located under the /boot folder of the new disk, ubuntu are using uuids to identify partitions. So it’s time to open gparted again, remember that we did it the last time from a terminal, we do the same thing again “sudo gparted”, and find the partition where you copied the system to and then right click and press info now theres a field called uuid, copy paste those into the appropriate of the menulist like here :

example

title Ubuntu 9.04, kernel 2.6.28-11-generic
uuid 49753240-3c10-4fdb-a624-6b07b5071d09
kernel /boot/vmlinuz-2.6.28-11-generic root=UUID=49753240-3c10-4fdb-a624-6b07b5071d09 ro quiet splash
initrd /boot/initrd.img-2.6.28-11-generic
quiet

title Windows XP Home
uuid 4D9D89C529CA8435
makeactive
chainloader +1

So before wiping the old disk I suggest that you try booting the new one, just in case something went wrong. I had no troubles with it, but it’s always nice to have a backup.. Most motherboards today have a option to boot from different disks.

I’ve used this blog here as source http://encodable.com/tech/blog/2006/10/30/Ubuntu_Linux_Hard_Drive_Upgrade
as well as this one http://samuelcheng.wordpress.com/2009/02/04/transferring-ubuntu-to-new-harddrive/

April 26, 2009 Posted by ninomartinez | ubuntu | | 1 Comment

Adjust Webcam settings ubuntu

My solution was to run this small tool :

luvcview -f yuv -l

I have a creative live im ultra.. Works like a charm.. Now if I could only get my twin display working when I play games!

April 8, 2009 Posted by ninomartinez | General, ubuntu | | 1 Comment

Integration Testing With Nortel SCE / Part 1

So you are developing with the Nortel SCE and want todo integration testing. Theres no support for it in the framework itself. So we think and think. The SCE communicates via voicexml or VXML towards the MPS. This happens over http protocol, that means the we can use Jmeter to sniff the communication between MPS and SCE (JBOSS / struts). So in practice to make this work you need to setup the http proxy on jmeter and then go into the SBClient.cfg located here : C:\Program Files\Nortel Networks\SelfService\PERIvxml\config\ on a standard installation , edit these two lines:


client.inet.proxyServer VXIString localhost
client.inet.proxyPort VXIInteger 9000

Proxy server are the machine where you have jmeter running and port are the one you specified when setting up the proxy, id recommend using 9000 since the default 8080 clashes with the SCE Jboss port. After changing the parameters you need to restart the MPS service.

So there are two was of recording, on your local machine using the mock interface provided with SCE / eclipse ( execution view / WVADS ). Or on your test facility where you actually can dial in as normal, and record the scenarios. Just remember when you end Jmeter the proxy goes down aswell, meaning the MPS & SCE can no longer communicate, just comment out the 2 lines in sbclient.cfg to get it working again.

Tips

  1. Remember to switch recording controller in jmeter between scenarios. And one more thing this will only record the dialog between SCE and MPS, not the audio server.
  2. If you add appropriate listeners to your jmeter scenario when you replay you can even see the vxml responses.

Heres how a scenario from a very simple application looks (Just playing a couple of prompts):

SCE Jmeter Scenario

SCE Jmeter Scenario

After recording the scenarios they can now be replayed at wish for example as part of integration test. In the next part I’ll try to digest howto put in test coverage with coberatura, so we get some metrics on how much of our code actually are tested with this approach. Now sadly since SCE does a lot of auto generation I think the process will be partially manual, so we cannot employ a building server like Hudson for this:( If you have any ideas on howto run the SCE auto generation as a MOJO from maven or something please do not hesitate to write. As always comments are more than welcome :)

If you are new to jmeter you can read more here, Jmeter site

April 3, 2009 Posted by ninomartinez | Nortel SCE, VoiceXml | | 2 Comments

Apache Wicket Merchandise

In late 2008 I got the permission (by signing a contract) from ASF to create and run a Webshop that sells Wicket Merchandise, the shop donates 5% of profit to ASF the rest goes to the Wicket community. If you want to buy some merchandise go here http://www.cafepress.com/apachewicket .

The Apache Wicket Merchandise Shop has awarded these people:

  • Daan van Etten , for creating the grapichs for the merchandise, he got the mug ( http://www.cafepress.com/apachewicket.317295372 )

The idea are to continue to use profits to award people that has done something special for the wicket community, like Wicket committers or WicketStuff committers etc.

If you have someone that you would like to nominate to receive some merchandise please write it as a comment here, please write a few lines why and if you have contact information you can mail it too me. I’ll add them to the vote list.

regards Nino

February 19, 2009 Posted by ninomartinez | wicket | | 2 Comments

Wicket continues to impress me

So I wanted to put in a conditional css thing to fix a IE problem, todo this thing in wicket I just though up a way. And wrote the code, it just worked:)

Heres how:
Markup (in head):

*style wicket:id="ieStyle" type="text/css"*

*/style*


A simple webmarkupcontainer, to put in the hack (with a resource reference)::

add(new WebMarkupContainer("ieStyle"){

@Override
protected void onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag) {
super.onComponentTagBody(markupStream, openTag);
String csshoverurl=urlFor(new ResourceReference(BasePage.class,"csshover2.htc")).toString();
getResponse().write("" +
"body {" +
"behavior: url("+csshoverurl+");" +
"}");

}

}

And to finish it up make it conditional so only IE picks it up, by adding a behavior:

public class IECheckBehaviorBehavior extends AbstractBehavior {
public IECheckBehaviorBehavior() {
}
@Override
public void beforeRender(Component component) {
super.beforeRender(component);
Response response = component.getResponse();
response.write("*!--[if lt IE 7]>--*");
}
@Override
public void onRendered(Component component) {
super.onRendered(component);
Response response = component.getResponse();
response.write("*![endif]--*");
}
}

The result:

*!--[if lt IE 7]>--*
body {behavior: url(resources/zeuzgroup.web.page.BasePage/csshover2.htc;jsessionid=1pjzdpc4j8asn);}
*![endif]--*

Simple and and almost clean :)

Ps I had to substitute the less than equal and greater than equal sign with *

December 11, 2008 Posted by ninomartinez | test, ubuntu, wicket | | 7 Comments

OpenID, the challenge Attributes

So what’s the fuss about openID? Well the idea are to have one id provider for all the sites that require authentication.

And if you go a bit further and you do at sometime, you’ll want to get some details about the user, like email or full name. So the guys at openID implemented something called attribute exchange. And if you are in the java world like I am you want something simple, so I turned to openID4Java. The idea are that you let the user put in the id on your web page just something like johndoe.openid.org and then you forward the user to openid.org and lets openid.org validate your user and then openid.org will forward the user back to you using an url you specified. And if you really need some properties, you can add a sreg (OpenID Simple Registration Extension) for each property to make the user enter it at the provider ( however not all providers supports these things ).

Well onto the code :

Code for requesting the provider

// --- placing the authentication request ---
public String authRequest(String userSuppliedString,
HttpServletRequest httpReq, HttpServletResponse httpResp,
String returnToUrl) throws IOException, ServletException {
try {
// configure the return_to URL where your application will receive
// the authentication responses from the OpenID provider

// perform discovery on the user-supplied identifier
List discoveries = manager.discover(userSuppliedString);

// attempt to associate with the OpenID provider
// and retrieve one service endpoint for authentication
DiscoveryInformation discovered = manager.associate(discoveries);

// store the discovery information in the user's session
httpReq.getSession().setAttribute("openid-disc", discovered);

// obtain a AuthRequest message to be sent to the OpenID provider
AuthRequest authReq = manager.authenticate(discovered, returnToUrl);
FetchRequest fetch = FetchRequest.createFetchRequest();

//
// SRegRequest sregReq = SRegRequest.createFetchRequest();
//
// sregReq.addAttribute("fullname", true);
// sregReq.addAttribute("nickname", true);
// sregReq.addAttribute("email", true);
fetch.addAttribute("Fullname", "http://axschema.org/namePerson/",
true);
fetch.addAttribute("Email", "http://axschema.org/contact/email",
true);

// tell the email coint
fetch.setCount("Email", 1);
AuthRequest req = manager.authenticate(discovered, returnToUrl);
req.addExtension(fetch);
// authReq.addExtension(sregReq);
if (!discovered.isVersion2()) {
// Option 1: GET HTTP-redirect to the OpenID Provider endpoint
// The only method supported in OpenID 1.x
// redirect-URL usually limited ~2048 bytes
httpResp.sendRedirect(authReq.getDestinationUrl(true));
return null;

} else {
httpResp.sendRedirect(authReq.getDestinationUrl(true));
return null;
// // Option 2: HTML FORM Redirection (Allows payloads >2048
// bytes)
// RequestDispatcher dispatcher =
// httpReq.getRequestDispatcher(OpenIdSignInPage.MOUNTPATH);
// httpReq.setAttribute("parameterMap",
// authReq.getParameterMap());
// httpReq.setAttribute("destinationUrl",
// authReq.getDestinationUrl(false));
// dispatcher.forward(httpReq, httpResp);
}
} catch (OpenIDException e) {
// present error to the user
}

return null;
}

The code that recieves the response from the provider:

// --- processing the authentication response ---
public User verifyResponse(HttpServletRequest httpReq) {
try {
// extract the parameters from the authentication response
// (which comes in as a HTTP request from the OpenID provider)
ParameterList response = new ParameterList(httpReq
.getParameterMap());

// retrieve the previously stored discovery information
DiscoveryInformation discovered = (DiscoveryInformation) httpReq
.getSession().getAttribute("openid-disc");

// extract the receiving URL from the HTTP request
StringBuffer receivingURL = httpReq.getRequestURL();
String queryString = httpReq.getQueryString();
if (queryString != null && queryString.length() > 0)
receivingURL.append("?").append(httpReq.getQueryString());

// verify the response; ConsumerManager needs to be the same
// (static) instance used to place the authentication request
VerificationResult verification = manager.verify(receivingURL
.toString(), response, discovered);

// examine the verification result and extract the verified
// identifier
Identifier verified = verification.getVerifiedId();
if (verified != null) {
AuthSuccess authSuccess = (AuthSuccess) verification
.getAuthResponse();
if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
FetchResponse fetchResp = (FetchResponse) authSuccess
.getExtension(AxMessage.OPENID_NS_AX);
return filluser(fetchResp);
}

if (authSuccess.hasExtension(OPENID_NS_SREG1_1)) {
log.info("got info:"
+ authSuccess
.getParameterValue("openid.sreg.email"));
log.info("got info:"
+ authSuccess
.getParameterValue("openid.sreg.fullname"));

User user = new User();
user.setEmail(authSuccess
.getParameterValue("openid.sreg.email"));
user.setName(authSuccess
.getParameterValue("openid.sreg.fullname"));
return user;

}

// return verified; // success
}
} catch (OpenIDException e) {
// present error to the user
}

return null;
}

private User filluser(FetchResponse fetchResp) {

List emails = fetchResp.getAttributeValues("email");
String email = emails.get(0);
List names = fetchResp.getAttributeValues("name");
String name = names.get(0);

User user = new User();
user.setEmail(email);
user.setName(name);
return user;

}

So the idea are good and the authentication works, but my problem are that I cannot get the providers to provide the ax properties. So I’ll be following up on howto do this in this post. I hope I succeed at some point, because for me openid without ax are almost worthless. At this point I dont know if it’s the openID4java implementation or the openID providers. If you have any pointers on howto do this please comment

December 11, 2008 Posted by ninomartinez | Authentication, JAVA | | 3 Comments

new stuff in Wicketstuff OpenLayers integration

So I’ve added a few things and done a cleanup on the Wicketstuff OpenLayers integration.

  • We are now using JTS (http://www.vividsolutions.com/Jts/JTSHome.htm) directly.
  • You are now able to draw geometry’s using the new DrawListenerBehavior
    • Geom’s are pushed to java using JTS
  • Remove the drawControl using the RemoveDrawControl behavior.

Heres some screens :

Drawing

Drawing

FeedBack from serverside (just outputting the WKT of the geom)

interaction 01

Using a little JTS:

A little JTS power

And if you’re wondering why is this cool? Well because above interactions are passed to server side, using the Wicketstuff Openlayers integration requires no knowledge of javascript, its wrapped nicely for you.

Heres the link to a little more about the library:

http://wicketstuff.org/confluence/display/STUFFWIKI/wicket-contrib-openlayers

And if you combine this with hibernate spatial, you can since hibernate spatial supports JTS.. You have a really cool simple GIS system :)

December 9, 2008 Posted by ninomartinez | JAVA, wicket | | 5 Comments

testalicious testing

Test Mashup, TDD / BDD

So these days test driven or behavior driven development are hot around my coordinates. Im going to write a bit about pratical usage of BDD using selenium & jBehave. With backup tools such as maven, cobertura and selenium.

We all hate to maintain large code bases of tests, tests are nice ( and necessary ) but sometimes you just get cluttered by them.

Introducing jBehave

So what if you could have a minimal amount of code and write something like this:

When user goes to homepage
homepage are rendered

Taking it a bit further:


Given a user nino with password dummy
When user goes to homepage and does a login
Then user are logged in and shown profilepage

That would be nice right? In jBehave you archive this by a blend of things, i’ll only cover a subset.

Steps
In your steps class you something like the below code, notice that I put in selenium. So the steps are sort of a mini test framework which the scenarios can utilize.


@When("a user visits $page")
public void visits(String page) {
selenium.open("http://localhost:8080/" + page);
}
@Then("$page are rendered")
public void seesPage(String page) {
Ensure.ensureThat(selenium.getLocation().compareToIgnoreCase(
"http://localhost:8080/" + page) == 0);
Ensure.ensureThat(!selenium.isTextPresent("HTTP ERROR: 404"));
}

Scenario
The scenario are a plain text test, which utilizes the steps above. Something like this:

When a user visits homepage
Then home are rendered
When a user visits errorpage
Then errorpage are rendered

As you can see you could actually put in use cases, and things suddenly got a lot easier to discuss with customers, your tests are readable by non technical eyes and of course it’s not limited to web development. And your maintenance code base got smaller since what you need to write in java have shrunken, you are only building a small framework for the scenarios to utilize. Really really cool!

As you can see jBehave fit’s both for unit testing and the more obvious integration testing.

Introducing Cobertura

While you test it’s still nice to know your code coverage, cobertura’s nice for this as it gives you simple readable reports and it’s transparent to use. Just include a small mojo in your parent pom:

In your parent pom

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>
net.sourceforge.cobertura.datafile
</name>
<value>
target/cobertura/cobertura.ser
</value>
</property>
</systemProperties>
</configuration>
</plugin>

And in the project pom using it

<plugins>

<reporting>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<formats>
<format>html</format>
</formats>
</configuration>
</plugin>

</plugins>
</reporting>
</project>

You will then get reports looking like this:

Cobertura report

Cobertura report

And you can even see which lines are touched in your code:

See what lines are touched by tests

See what lines are touched by tests

Introducing Selenium

Automatic independent browser tests, if your doing web development this is almost a must have, unless you like to do manual tests a lot. However if you are using code coverage which are using byte code instrumentation, you could loose track of what’s tested and what not. A way around this are perhaps to start a embedded jetty server as part of your test, then in theory you should be back on track. Since byte code instrumentation should be able to track again…

November 3, 2008 Posted by ninomartinez | JAVA, test | | No Comments Yet