Changeset 4000
- Timestamp:
- 11/11/13 15:59:29 (11 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src
- Files:
-
- 2 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java
r3974 r4000 68 68 @Autowired 69 69 private DBIntegrityService dbIntegrityService; 70 @Autowired70 71 71 @Context 72 72 private HttpServletRequest httpServletRequest; … … 74 74 @Context 75 75 private HttpServletResponse httpServletResponse; 76 @Autowired76 77 77 @Context 78 78 private UriInfo uriInfo; 79 @Autowired79 80 80 @Context 81 pr otectedProviders providers;81 private Providers providers; 82 82 83 83 final String default_permission = "reader"; 84 84 85 86 public void setUriInfo(UriInfo uriInfo){ 87 this.uriInfo = uriInfo; 88 } 89 90 public void setHttpServletResponse(HttpServletResponse httpServletResponse){ 91 this.httpServletResponse = httpServletResponse; 92 } 93 94 public void setHttpServletRequest(HttpServletRequest httpServletRequest){ 95 this.httpServletRequest = httpServletRequest; 96 } 97 98 public void setProviders(Providers providers){ 99 this.providers = providers; 100 } 101 102 85 103 86 104 public AnnotationResource() { -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java
r3974 r4000 50 50 import java.util.UUID; 51 51 import javax.servlet.ServletException; 52 import javax.servlet.http.HttpServletRequest;53 import javax.servlet.http.HttpServletResponse;54 import javax.ws.rs.core.MediaType;55 52 import javax.ws.rs.core.UriInfo; 56 import javax.ws.rs.ext.Providers;57 53 import javax.xml.bind.JAXBException; 58 import javax.xml.bind.Marshaller;59 54 import javax.xml.datatype.DatatypeConfigurationException; 55 import org.springframework.mock.web.MockHttpServletRequest; 60 56 61 57 /** … … 66 62 @RunWith(value = SpringJUnit4ClassRunner.class) 67 63 @ContextConfiguration(locations = { "/spring-test-config/mockeryRest.xml", "/spring-test-config/mockDBIntegrityService.xml", 68 "/spring-config/jaxbMarshallerFactory.xml", "/spring-test-config/mockUriInfo.xml", "/spring-test-config/mockHttpServletRequest.xml", "/spring-test-config/mockProviders.xml"}) 64 "/spring-test-config/mockUriInfo.xml", 65 "/spring-config/jaxbMarshallerFactory.xml"}) 69 66 public class AnnotationResourceTest { 70 67 71 68 @Autowired 72 private Mockery mockeryRest; 69 private Mockery mockeryRest; 70 @Autowired 71 private MockObjectsFactoryRest mockObjectFactory; 73 72 @Autowired 74 73 private DBIntegrityService mockDbIntegrityService; 75 74 @Autowired 76 private UriInfo mockUriInfo;77 @Autowired78 private HttpServletRequest mockHttpServletRequest;79 80 @Autowired81 private Providers mockProviders;82 @Autowired83 75 private AnnotationResource annotationResource; 84 76 @Autowired 77 UriInfo mockUriInfo; 78 79 private MockHttpServletRequest mockRequest; 85 80 86 81 public AnnotationResourceTest() { 87 } 88 82 mockRequest = new MockHttpServletRequest(); 83 mockRequest.setRemoteUser("twan"); 84 85 } 86 89 87 90 88 /** … … 95 93 System.out.println("getAnnotation"); 96 94 final String externalIDstring= TestBackendConstants._TEST_ANNOT_2_EXT; 97 final Annotation expectedAnnotation = (new TestInstances()).getAnnotationOne(); 98 final ResourceJaxbMarshallerProvider rmp = new ResourceJaxbMarshallerProvider(); 99 95 final Annotation expectedAnnotation = (new TestInstances()).getAnnotationOne(); 96 annotationResource.setHttpServletRequest(mockRequest); 97 annotationResource.setUriInfo(mockUriInfo); 98 99 100 100 mockeryRest.checking(new Expectations() { 101 101 { 102 102 103 oneOf(mockUriInfo).getBaseUri(); 104 will(returnValue(URI.create("http://localhost:8080/annotator-backend/api/"))); 105 106 107 oneOf(mockProviders).getContextResolver(Marshaller.class, MediaType.WILDCARD_TYPE); 108 will(returnValue(rmp)); 109 110 oneOf(mockHttpServletRequest).getRemoteUser(); 111 will(returnValue("twan")); 112 103 oneOf(mockUriInfo).getBaseUri(); 104 will(returnValue(URI.create("http://localhost:8080/annotator-backend/api/"))); 105 106 113 107 oneOf(mockDbIntegrityService).setServiceURI(with(any(String.class))); 114 108 will(doAll()); … … 128 122 }); 129 123 130 124 131 125 JAXBElement<Annotation> result = annotationResource.getAnnotation(externalIDstring); 132 126 assertEquals(expectedAnnotation, result.getValue()); … … 139 133 public void testDeleteAnnotation() throws SQLException, IOException { 140 134 System.out.println("deleteAnnotation"); 141 //final Number annotationID = mockDbIntegrityService.getAnnotationInternalIdentifier(UUID.fromString(UUID));142 //int[] resultDelete = mockDbIntegrityService.deleteAnnotation(annotationID);143 135 144 136 final int[] mockDelete = new int[4]; … … 148 140 mockDelete[3]=1; // # deletd Targets, 4 149 141 150 151 142 annotationResource.setHttpServletRequest(mockRequest); 143 annotationResource.setUriInfo(mockUriInfo); 144 152 145 mockeryRest.checking(new Expectations() { 153 146 { 154 155 oneOf(mockUriInfo).getBaseUri(); 156 will(returnValue(URI.create("http://localhost:8080/annotator-backend/api/"))); 157 158 159 oneOf(mockHttpServletRequest).getRemoteUser(); 160 will(returnValue("twan")); 161 147 oneOf(mockUriInfo).getBaseUri(); 148 will(returnValue(URI.create("http://localhost:8080/annotator-backend/api/"))); 149 150 162 151 oneOf(mockDbIntegrityService).getUserInternalIDFromRemoteID("twan"); 163 152 will(returnValue(3)); … … 219 208 addedAnnotation.setOwnerRef("http://localhost:8080/annotator-backend/api/users/"+TestBackendConstants._TEST_USER_3_EXT_ID); 220 209 210 annotationResource.setHttpServletRequest(mockRequest); 211 annotationResource.setUriInfo(mockUriInfo); 221 212 222 213 mockeryRest.checking(new Expectations() { 223 214 { 224 225 215 oneOf(mockUriInfo).getBaseUri(); 226 will(returnValue(URI.create("http://localhost:8080/annotator-backend/api/"))); 227 228 229 oneOf(mockHttpServletRequest).getRemoteUser(); 230 will(returnValue("twan")); 231 216 will(returnValue(URI.create("http://localhost:8080/annotator-backend/api/"))); 217 232 218 233 219 oneOf(mockDbIntegrityService).setServiceURI(with(any(String.class))); -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/NotebookResourceTest.java
r3974 r4000 32 32 @RunWith(value = SpringJUnit4ClassRunner.class) 33 33 @ContextConfiguration(locations = {"/spring-test-config/mockeryRest.xml", "/spring-test-config/mockDBIntegrityService.xml", "/spring-config/jaxbMarshallerFactory.xml", 34 "/spring-test-config/mockUriInfo.xml", "/spring-test-config/mockHttpServletRequest.xml", 35 "/spring-test-config/mockProviders.xml"}) 34 "/spring-test-config/mockUriInfo.xml"}) 36 35 public class NotebookResourceTest { 37 36
Note: See TracChangeset
for help on using the changeset viewer.