Java 8 on Raspberry Pi

 Development, general, Java  Comments Off on Java 8 on Raspberry Pi
May 192013

This is more of a reminder to myself. But others may find it useful.

Make sure ssh is enabled on your raspberry pi and set the memory split down to 16 for the gui.

ssh into the raspberry pi

cd /tmp
tar zxf jdk-8-ea-b36e-linux-arm-hflt-29_nov_2012.tar.gz
rm jdk-8-ea-b36e-linux-arm-hflt-29_nov_2012.tar.gz
sudo mv ./jdk1.8.0/ /opt/
sudo chown root:root -R /opt/jdk1.8.0/
sudo ln -s /opt/jdk1.8.0/ /opt/jdk8

Then just add it to your path.


and your done. I went on and install jetty 9

Spring MVC 3 testing RESTful api

 Java, Spring MVC  Comments Off on Spring MVC 3 testing RESTful api
Jul 102012

While there are lots of articles around testing spring mvc, it took me a while to find all the info I needed to get my tests up and running, so I wanted to put down here for others to gain from and also for me to lookup when I inevitably forget something in the future.

My project is using maven and these dependencies are used by my tests:

<!-- Test -->
<!-- Jackson convertors -->

Then the method under test: MissingPersonsController

@RequestMapping(method=RequestMethod.GET, value={"/missing"})
public ResponseEntity list(@RequestParam(value="limit",required=false) Integer limit ) {
        List missing = mpDao.listAll();
	return this.responseHandler(missing);
    catch(Exception e){
	return this.responseHandler(new ArrayList(), HttpStatus.INTERNAL_SERVER_ERROR);

And now finally the Test:

@ActiveProfiles(profiles = "development")
public class TestMissingPersonsController extends TestCase {
	MissingPersonsController cont;
	AnnotationMethodHandlerAdapter adapter;
	MockHttpServletRequest request;
	MockHttpServletResponse response;
	ObjectMapper mapper;
	TypeReference> type = new TypeReference>() {};

	public void setUp(){
		adapter = new AnnotationMethodHandlerAdapter();
		request = new MockHttpServletRequest();
		response = new MockHttpServletResponse();
		mapper	= new ObjectMapper();
	public void testShouldGetResponse() {
		request.addHeader("x-auth-api", "abcd1234");
		 adapter.handle(request, response, cont);
		 assertEquals(200, response.getStatus());
		 Map converted = mapper.readValue(response.getContentAsString(), type);
		 assertEquals("application/json", response.getContentType());
		}catch(Exception e){



Any questions about this give me a shout in the comments and I’ll explain anything I can.

© 2012 Craig Brookes Suffusion theme by Sayontan Sinha