diff --git a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java
index 7efed546d8..749cabc757 100644
--- a/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java
+++ b/RestEasy Example/src/main/java/com/baeldung/client/ServicesInterface.java
@@ -14,7 +14,7 @@ public interface ServicesInterface {
@GET
@Path("/getinfo")
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
- Movie movieByImdbID(@QueryParam("imdbID") String imdbID);
+ Movie movieByImdbId(@QueryParam("imdbId") String imdbId);
@GET
@@ -37,7 +37,7 @@ public interface ServicesInterface {
@DELETE
@Path("/deletemovie")
- Response deleteMovie(@QueryParam("imdbID") String imdbID);
+ Response deleteMovie(@QueryParam("imdbId") String imdbID);
diff --git a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java
index 052ba081c1..a2b2bd5250 100644
--- a/RestEasy Example/src/main/java/com/baeldung/model/Movie.java
+++ b/RestEasy Example/src/main/java/com/baeldung/model/Movie.java
@@ -13,7 +13,7 @@ import javax.xml.bind.annotation.XmlType;
"country",
"director",
"genre",
- "imdbID",
+ "imdbId",
"imdbRating",
"imdbVotes",
"language",
@@ -36,7 +36,7 @@ public class Movie {
protected String country;
protected String director;
protected String genre;
- protected String imdbID;
+ protected String imdbId;
protected String imdbRating;
protected String imdbVotes;
protected String language;
@@ -173,27 +173,27 @@ public class Movie {
}
/**
- * Recupera il valore della propriet� imdbID.
+ * Recupera il valore della propriet� imdbId.
*
* @return
* possible object is
* {@link String }
*
*/
- public String getImdbID() {
- return imdbID;
+ public String getImdbId() {
+ return imdbId;
}
/**
- * Imposta il valore della propriet� imdbID.
+ * Imposta il valore della propriet� imdbId.
*
* @param value
* allowed object is
* {@link String }
*
*/
- public void setImdbID(String value) {
- this.imdbID = value;
+ public void setImdbId(String value) {
+ this.imdbId = value;
}
/**
@@ -540,7 +540,7 @@ public class Movie {
", country='" + country + '\'' +
", director='" + director + '\'' +
", genre='" + genre + '\'' +
- ", imdbID='" + imdbID + '\'' +
+ ", imdbId='" + imdbId + '\'' +
", imdbRating='" + imdbRating + '\'' +
", imdbVotes='" + imdbVotes + '\'' +
", language='" + language + '\'' +
@@ -564,14 +564,14 @@ public class Movie {
Movie movie = (Movie) o;
- if (imdbID != null ? !imdbID.equals(movie.imdbID) : movie.imdbID != null) return false;
+ if (imdbId != null ? !imdbId.equals(movie.imdbId) : movie.imdbId != null) return false;
return title != null ? title.equals(movie.title) : movie.title == null;
}
@Override
public int hashCode() {
- int result = imdbID != null ? imdbID.hashCode() : 0;
+ int result = imdbId != null ? imdbId.hashCode() : 0;
result = 31 * result + (title != null ? title.hashCode() : 0);
return result;
}
diff --git a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java
index 18366e2faa..29226aa0e0 100644
--- a/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java
+++ b/RestEasy Example/src/main/java/com/baeldung/server/MovieCrudService.java
@@ -22,7 +22,7 @@ public class MovieCrudService {
@GET
@Path("/getinfo")
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
- public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){
+ public Movie movieByImdbID(@QueryParam("imdbId") String imdbID){
System.out.println("*** Calling getinfo for a given ImdbID***");
@@ -40,12 +40,12 @@ public class MovieCrudService {
System.out.println("*** Calling addMovie ***");
- if (null!=inventory.get(movie.getImdbID())){
+ if (null!=inventory.get(movie.getImdbId())){
return Response.status(Response.Status.NOT_MODIFIED)
.entity("Movie is Already in the database.").build();
}
- inventory.put(movie.getImdbID(),movie);
+ inventory.put(movie.getImdbId(),movie);
return Response.status(Response.Status.CREATED).build();
}
@@ -58,11 +58,11 @@ public class MovieCrudService {
System.out.println("*** Calling updateMovie ***");
- if (null==inventory.get(movie.getImdbID())){
+ if (null==inventory.get(movie.getImdbId())){
return Response.status(Response.Status.NOT_MODIFIED)
.entity("Movie is not in the database.\nUnable to Update").build();
}
- inventory.put(movie.getImdbID(),movie);
+ inventory.put(movie.getImdbId(),movie);
return Response.status(Response.Status.OK).build();
}
@@ -70,7 +70,7 @@ public class MovieCrudService {
@DELETE
@Path("/deletemovie")
- public Response deleteMovie(@QueryParam("imdbID") String imdbID){
+ public Response deleteMovie(@QueryParam("imdbId") String imdbID){
System.out.println("*** Calling deleteMovie ***");
diff --git a/RestEasy Example/src/main/webapp/WEB-INF/web.xml b/RestEasy Example/src/main/webapp/WEB-INF/web.xml
index ab3bc1aa83..f70fdf7975 100644
--- a/RestEasy Example/src/main/webapp/WEB-INF/web.xml
+++ b/RestEasy Example/src/main/webapp/WEB-INF/web.xml
@@ -5,47 +5,12 @@
RestEasy Example
-
-
- org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
-
-
-
- RestEasy Example
-
-
- webAppRootKey
- RestEasyExample
-
-
-
-
+
resteasy.servlet.mapping.prefix
/rest
-
- resteasy-servlet
-
- org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
-
-
- javax.ws.rs.Application
- com.baeldung.server.RestEasyServices
-
-
-
-
- resteasy-servlet
- /rest/*
-
-
-
-
- index.html
-
-
\ No newline at end of file
diff --git a/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java b/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java
new file mode 100644
index 0000000000..b474b3d4f8
--- /dev/null
+++ b/RestEasy Example/src/test/java/baeldung/client/RestEasyClient.java
@@ -0,0 +1,7 @@
+package baeldung.client;
+
+/**
+ * Created by Admin on 29/01/2016.
+ */
+public class RestEasyClient {
+}
diff --git a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java
index fb4205bcd7..b6a2e2a0c1 100644
--- a/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java
+++ b/RestEasy Example/src/test/java/com/baeldung/server/RestEasyClientTest.java
@@ -1,7 +1,7 @@
package com.baeldung.server;
-import com.baeldung.model.Movie;
import com.baeldung.client.ServicesInterface;
+import com.baeldung.model.Movie;
import org.apache.commons.io.IOUtils;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
@@ -9,7 +9,6 @@ import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
import javax.naming.NamingException;
@@ -23,22 +22,13 @@ import java.util.Locale;
public class RestEasyClientTest {
-
Movie transformerMovie=null;
Movie batmanMovie=null;
ObjectMapper jsonMapper=null;
- @BeforeClass
- public static void loadMovieInventory(){
-
-
-
- }
-
@Before
public void setup() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NamingException {
-
jsonMapper=new ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
jsonMapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH);
@@ -57,133 +47,102 @@ public class RestEasyClientTest {
batmanMovie = jsonMapper.readValue(batmanMovieAsString, Movie.class);
} catch (Exception e) {
- e.printStackTrace();
throw new RuntimeException("Test is going to die ...", e);
}
-
}
-
@Test
public void testListAllMovies() {
- try {
- ResteasyClient client = new ResteasyClientBuilder().build();
- ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest"));
- ServicesInterface simple = target.proxy(ServicesInterface.class);
+ ResteasyClient client = new ResteasyClientBuilder().build();
+ ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest"));
+ ServicesInterface simple = target.proxy(ServicesInterface.class);
- Response moviesResponse = simple.addMovie(transformerMovie);
- moviesResponse.close();
- moviesResponse = simple.addMovie(batmanMovie);
- moviesResponse.close();
+ Response moviesResponse = simple.addMovie(transformerMovie);
+ moviesResponse.close();
+ moviesResponse = simple.addMovie(batmanMovie);
+ moviesResponse.close();
- final List movies = simple.listMovies();
- System.out.println(movies);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
+ List movies = simple.listMovies();
+ System.out.println(movies);
}
-
@Test
- public void testMovieByImdbID() {
+ public void testMovieByImdbId() {
String transformerImdbId="tt0418279";
- try {
- ResteasyClient client = new ResteasyClientBuilder().build();
- ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest"));
- ServicesInterface simple = target.proxy(ServicesInterface.class);
+ ResteasyClient client = new ResteasyClientBuilder().build();
+ ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest"));
+ ServicesInterface simple = target.proxy(ServicesInterface.class);
- Response moviesResponse = simple.addMovie(transformerMovie);
- moviesResponse.close();
+ Response moviesResponse = simple.addMovie(transformerMovie);
+ moviesResponse.close();
- final Movie movies = simple.movieByImdbID(transformerImdbId);
- System.out.println(movies);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
+ Movie movies = simple.movieByImdbId(transformerImdbId);
+ System.out.println(movies);
}
@Test
public void testAddMovie() {
- try {
- ResteasyClient client = new ResteasyClientBuilder().build();
- ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest"));
- ServicesInterface simple = target.proxy(ServicesInterface.class);
+ ResteasyClient client = new ResteasyClientBuilder().build();
+ ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest"));
+ ServicesInterface simple = target.proxy(ServicesInterface.class);
- Response moviesResponse = simple.addMovie(batmanMovie);
- moviesResponse.close();
- moviesResponse = simple.addMovie(transformerMovie);
+ Response moviesResponse = simple.addMovie(batmanMovie);
+ moviesResponse.close();
+ moviesResponse = simple.addMovie(transformerMovie);
- if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) {
- //System.out.println(moviesResponse.readEntity(String.class));
- System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus());
- }
- moviesResponse.close();
-
- } catch (Exception e) {
- e.printStackTrace();
+ if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) {
+ System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus());
}
+
+ moviesResponse.close();
+ System.out.println("Response Code: "+Response.Status.OK.getStatusCode());
}
@Test
- public void testDeleteMovie() {
+ public void testDeleteMovi1e() {
- String transformerImdbId="tt0418279";
+ ResteasyClient client = new ResteasyClientBuilder().build();
+ ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest"));
+ ServicesInterface simple = target.proxy(ServicesInterface.class);
- try {
- ResteasyClient client = new ResteasyClientBuilder().build();
- ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest"));
- ServicesInterface simple = target.proxy(ServicesInterface.class);
+ Response moviesResponse = simple.addMovie(batmanMovie);
+ moviesResponse.close();
+ moviesResponse = simple.deleteMovie(batmanMovie.getImdbId());
- Response moviesResponse = simple.addMovie(batmanMovie);
- moviesResponse.close();
- moviesResponse = simple.deleteMovie(transformerImdbId);
- moviesResponse.close();
-
- if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) {
- System.out.println(moviesResponse.readEntity(String.class));
- throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus());
- }
-
- moviesResponse.close();
-
- } catch (Exception e) {
- e.printStackTrace();
+ if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) {
+ System.out.println(moviesResponse.readEntity(String.class));
+ throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus());
}
+
+ moviesResponse.close();
+ System.out.println("Response Code: "+Response.Status.OK.getStatusCode());
}
@Test
public void testUpdateMovie() {
- try {
+ ResteasyClient client = new ResteasyClientBuilder().build();
+ ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://127.0.0.1:8080/RestEasyTutorial/rest"));
+ ServicesInterface simple = target.proxy(ServicesInterface.class);
- ResteasyClient client = new ResteasyClientBuilder().build();
- ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/RestEasyTutorial/rest"));
- ServicesInterface simple = target.proxy(ServicesInterface.class);
+ Response moviesResponse = simple.addMovie(batmanMovie);
+ moviesResponse.close();
+ batmanMovie.setImdbVotes("300,000");
+ moviesResponse = simple.updateMovie(batmanMovie);
- Response moviesResponse = simple.addMovie(batmanMovie);
- moviesResponse.close();
- batmanMovie.setImdbVotes("300,000");
- moviesResponse = simple.updateMovie(batmanMovie);
-
- if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) {
- //System.out.println(moviesResponse.readEntity(String.class));
- System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus());
- }
-
- moviesResponse.close();
-
- } catch (Exception e) {
- e.printStackTrace();
+ if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) {
+ System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus());
}
+
+ moviesResponse.close();
+ System.out.println("Response Code: "+Response.Status.OK.getStatusCode());
}
}
\ No newline at end of file