Lo del jUnit lo he pillado, es inútil hace pruebas a los getter y setter.
Ahora bien, estoy utilizando el framework "apache cocoon", este es el codigo:
Código Java:
Ver originalpackage es.witmachine.controller;
import es.witmachine.manager.MachineManager;
import es.witmachine.model.Machine;
import java.util.Map;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import org.apache.cocoon.rest.controller.annotation.Inject;
import org.apache.cocoon.rest.controller.annotation.RESTController;
import org.apache.cocoon.rest.controller.annotation.RequestParameter;
import org.apache.cocoon.rest.controller.annotation.SitemapParameter;
import org.apache.cocoon.rest.controller.method.Delete;
import org.apache.cocoon.rest.controller.method.Get;
import org.apache.cocoon.rest.controller.method.Post;
import org.apache.cocoon.rest.controller.method.Put;
import org.apache.cocoon.rest.controller.response.RedirectResponse;
import org.apache.cocoon.rest.controller.response.RestResponse;
import org.apache.cocoon.rest.controller.response.URLResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@RESTController
public class MachineController implements Post, Get, Delete, Put {
@RequestParameter
private String name, description, date, hoursJobs
;
@SitemapParameter
private int idmachine;
@Autowired
@Qualifier("machineManager")
private MachineManager machineManager;
@Inject
HttpServletRequest request;
public RestResponse doPost
() throws Exception { final Machine machine = new Machine();
machine.setName(name);
machine.setDescription(description);
machine.setHoursJobs(hoursJobs);
machine.setDate(date);
machineManager.create(machine);
return new RedirectResponse("/machine");
}
public RestResponse doPut
() throws Exception { final Machine machine = new Machine();
machine.setName(name);
machine.setDescription(description);
machine.setHoursJobs(hoursJobs);
machine.setDate(date);
machineManager.update(machine);
return new RedirectResponse("/machine");
}
public RestResponse doDelete
() throws Exception { machineManager.delete(idmachine);
return new RedirectResponse("/machine");
}
public RestResponse doGet
() throws Exception { final Map
<String, Object
> result
= new HashMap
<String, Object
>(); System.
out.
println("idmachine= " + idmachine
); result.put("idmachine", this.idmachine);
result.put("name", this.name);
result.put("description", this.description);
result.put("hoursJobs", this.hoursJobs);
return new URLResponse("servlet:/screen/rest-controller-view.html", result);
}
}
y el error que me da en la consola es este:
error: package org.apache.cocoon.rest.controller.annotation does not exist