See the output from MockMvc.peform()

Lets say you have a unit test on a Spring MVC controller like this:

/**
 * Tests RESTController.getPostcode() with a false postcode and building number
 */
@Test
public void PostcodeAndBuilding_FalsePostcodeIsNotGot_Passes() throws Exception {

    mockMvc.perform(get("/postcode/" + test3PostcodeRequest + "/" + test3BuildingNumberRequest))
            .andExpect(status().isOk())
            .andExpect(content().contentType(contentType))
            .andExpect(jsonPath("$.status", is(404)));

}

The test is failing, so you want to grab the response for whatever reason.  The simply way of doing this is to return the response of the MockMvc.perform into an MvcResult and run getResponse and getContentAsString on it to turn it into a String:

/**
 * Tests RESTController.getPostcode() with a false postcode and building number
 */
@Test
public void PostcodeAndBuilding_FalsePostcodeIsNotGot_Passes() throws Exception {

    MvcResult result = mockMvc.perform(get("/postcode/" + test3PostcodeRequest + "/" + test3BuildingNumberRequest));
            //.andExpect(status().isOk())
            //.andExpect(content().contentType(contentType))
            //.andExpect(jsonPath("$.status", is(404)));

    String content = result.getResponse().getContentAsString();

}

You now have the content stored as String to do with what you wish.

Facebooktwittergoogle_plusredditmail

Darcula for NetBeans IDE

Someone has released a Darcula theme for NetBeans.

Netbeans with the Darcula Theme

Netbeans with the Darcula Theme

I don’t use NetBeans myself, but its one of the IDE’s that I’ve been wanting to take a look at in the future as I’m booked on a Java training course that will use it. When I do get to use it, I’ll be using this theme. Darcula much less stressing on the eye when you are coding all day.

Facebooktwittergoogle_plusredditmail

Java Programming: Solving Problems with Software

I’ve passed another Java course on Coursera today.  This course was   Java Programming: Solving Problems with Software.  Overall the course was good.

Java Programming: Solving Problems with Software

Java Programming: Solving Problems with Software

One think I didn’t like was the the way the course was run with an expectation that the student would use BlueJ.  While there is a need for IDE’s like BlueJ the course content was at a level that the student should really be using a real IDE such as Eclipse or IntelliJ IDEA.

You can complete the course using Eclipse with no issues though,  just add the apache-csv.jar and courserajava.jar file to your project build path libraries:

Adding Libraries

Then import the packages at the start of your code:

import edu.duke.*;

You can grab the code in an Eclipse project from my GitHub page.

Facebooktwittergoogle_plusredditmail

C#

I’ve worked through Microsoft’s DEV204x Programming in C#  course.   I have to say, its a very good course.  Probably the highest quality course that I’ve sat through on Coursera or EdX.  Equal to any course Microsoft would give at official training centres.

My only complaint is that the labs are peer reviewed.  I think the testing should be automated, sure add a peer review component to include in the overall grade if needed, but automated testing should be what decides if your code is right or wrong.

I’m happy to say that I passed with a high mark.

DEV204x

I’ll be finishing off the Bootstrap course next (the Bootstrap course is nowhere near as high quality as the C# course!) then possibly look at the XAML course Microsoft has on EdX.

 

 

Facebooktwittergoogle_plusredditmail

Java

I’ve had a bit of a poor history with Java.

I first tried programming in Java back when Borland JBuilder 3 was on the cover of nearly every PC magazine, this must have been around 2000.  I thought I’d like the IDE as Borland Delphi was so good, but I couldn’t get on with JBuilder at all.  I suppose one of the real problems was that I didn’t really understand OOP back then.  It was only when I started writing software for BeOS (now Haiku OS) in C++ that I really got to grips with OOP.

EdX had a Java course starting around about the time I’d finished the Scratch course so I enrolled and I’m glad to say that I’ve passed!

Certificate

The course itself was really good.  It covered all the basics right up to object oriented programming using interfaces and abstract classes.  The programming assignments were challenging and enjoyable at the same time.

I’m really looking forward to Part 2, which has been announced but there isn’t a start date yet.  In the mean time I’m working through some C# and Bootstrap courses Microsoft have on EdX.

Facebooktwittergoogle_plusredditmail

Scratch That!

I’ve been getting back into software development recently.  I started taking a look around the different places you can go to for online courses, namely Coursera, EdX, Pluralsight and Udemy.  There is a whole set of courses about Java and Android development on Coursera so I thought I’d give Coursera a try.

Initially I wanted to see how Coursera worked and I didn’t have too much time spare so I just took the first course that looked fun.  This happened to be Code Yourself! An Introduction to Programming.  The course is for people new to programming and aims to teach them to think programmatically.  It does this using the Scratch programming language, which is a GUI based drag and drop web based tool.

The course was fun and I would probably be the perfect introduction for early teenagers or people who are completely new to programming.  I enjoyed the course and have to say it appeared to have a high production value.  The lecture was engaging and everything you needed to go through the course could be done a £150 Chromebook (my desktop was out of action at the time, so I used the Chromebook for everything) so as far as accessibility goes its pretty good.

Code Yourself! An Introduction to Programming Certificate

Code Yourself! An Introduction to Programming Certificate

I passed the course with a distinction and while I doubt I’ll use Scratch for much in the future I did have some ideas about using it to put something fun together with my children when they get a bit older.  I imagine they would find it really funny if we took pictures of their bodies and used them as sprites :).

Next up is a higher level Java course on EdX.

Facebooktwittergoogle_plusredditmail