Changeset 5568
- Timestamp:
- 08/18/14 19:28:05 (10 years ago)
- Location:
- ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RestGroupServiceTest.java
r5567 r5568 1294 1294 assertEquals(403, cresponse.getStatus()); 1295 1295 } 1296 1297 @Test 1298 public void testGetRegisteredGroupProfilecomponentRawData() throws Exception { 1299 1300 System.out.println("test getRegisteredComponentAndProfileRawData"); 1301 1302 fillUpGroupB(); 1303 fillUpGroupC(); 1304 1305 String id = ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1"; 1306 String component = this.getAuthenticatedResource(getResource() 1307 .path("/registry/components/" + id + "/xsd")) 1308 .accept(MediaType.TEXT_XML).get(String.class).trim(); 1309 assertTrue(component 1310 .startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?><xs:schema")); 1311 assertTrue(component.endsWith("</xs:schema>")); 1312 1313 component = this.getAuthenticatedResource(getResource().path("/registry/components/" + id + "/xml")) 1314 .accept(MediaType.TEXT_XML).get(String.class).trim(); 1315 assertTrue(component 1316 .startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<CMD_ComponentSpec")); 1317 assertTrue(component.endsWith("</CMD_ComponentSpec>")); 1318 assertTrue(component.contains("xsi:schemaLocation")); 1319 1320 id = ProfileDescription.PROFILE_PREFIX + "Bprofile-1"; 1321 String profile = this.getAuthenticatedResource(getResource() 1322 .path("/registry/profiles/" + id + "/xsd")) 1323 .accept(MediaType.TEXT_XML).get(String.class).trim(); 1324 assertTrue(profile 1325 .startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?><xs:schema")); 1326 assertTrue(profile.endsWith("</xs:schema>")); 1327 1328 profile = this.getAuthenticatedResource(getResource().path("/registry/profiles/" + id + "/xml")) 1329 .accept(MediaType.TEXT_XML).get(String.class).trim(); 1330 assertTrue(profile 1331 .startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<CMD_ComponentSpec")); 1332 assertTrue(profile.endsWith("</CMD_ComponentSpec>")); 1333 assertTrue(profile.contains("xsi:schemaLocation")); 1334 1335 id = ComponentDescription.COMPONENT_PREFIX + "Ccomponent-1"; 1336 ClientResponse resp = this.getAuthenticatedResource(getResource() 1337 .path("/registry/components/" + id + "/xsd")) 1338 .accept(MediaType.TEXT_XML).get( ClientResponse.class); 1339 assertEquals(403, resp.getStatus()); 1340 1341 id = ProfileDescription.PROFILE_PREFIX + "Cprofile-1"; 1342 resp = this.getAuthenticatedResource(getResource() 1343 .path("/registry/profiles/" + id + "/xsd")) 1344 .accept(MediaType.TEXT_XML).get( ClientResponse.class); 1345 assertEquals(403, resp.getStatus()); 1346 1347 1348 } 1296 1349 1297 1350 } -
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/SanboxTest.java
r5567 r5568 235 235 236 236 @Test 237 public void testRegisterCommentInGroup() throws Exception { 238 239 System.out.println("testRegisterCommmentInGroup"); 240 241 237 public void testGetRegisteredGroupProfilecomponentRawData() throws Exception { 238 239 System.out.println("test getRegisteredComponentAndProfileRawData"); 240 242 241 fillUpGroupB(); 243 242 fillUpGroupC(); 244 243 245 FormDataMultiPart form = new FormDataMultiPart(); 246 String id = ProfileDescription.PROFILE_PREFIX + "Bprofile-1"; 247 form.field(IComponentRegistryRestService.DATA_FORM_FIELD, 248 RegistryTestHelper.getCommentTestContentStringForProfile("comment1", id), 249 MediaType.APPLICATION_OCTET_STREAM_TYPE); 250 CommentResponse response = getAuthenticatedResource( 251 "/registry/profiles/" + id + "/comments").type( 252 MediaType.MULTIPART_FORM_DATA) 253 .post(CommentResponse.class, form); 254 assertTrue(response.isRegistered()); 255 assertTrue(response.isInUserSpace()); 256 Comment comment = response.getComment(); 257 assertNotNull(comment); 258 assertEquals("comment1", comment.getComment()); 259 assertEquals("Database test user", comment.getUserName()); 260 Assert.notNull(comment.getCommentDate()); 261 assertEquals(1, Long.parseLong(comment.getId())); 262 263 // User id should not be serialized! 264 assertEquals(0, comment.getUserId()); 265 266 267 form = new FormDataMultiPart(); 268 id = ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1"; 269 form.field(IComponentRegistryRestService.DATA_FORM_FIELD, 270 RegistryTestHelper.getCommentTestContentStringForComponent("comment2", id), 271 MediaType.APPLICATION_OCTET_STREAM_TYPE); 272 response = getAuthenticatedResource( 273 "/registry/components/" + id + "/comments").type( 274 MediaType.MULTIPART_FORM_DATA) 275 .post(CommentResponse.class, form); 276 assertTrue(response.isRegistered()); 277 assertTrue(response.isInUserSpace()); 278 comment = response.getComment(); 279 assertNotNull(comment); 280 assertEquals("comment2", comment.getComment()); 281 assertEquals("Database test user", comment.getUserName()); 282 Assert.notNull(comment.getCommentDate()); 283 assertEquals(2, Long.parseLong(comment.getId())); 284 285 // User id should not be serialized! 286 assertEquals(0, comment.getUserId()); 287 288 // not my group 289 290 form = new FormDataMultiPart(); 244 String id = ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1"; 245 String component = this.getAuthenticatedResource(getResource() 246 .path("/registry/components/" + id + "/xsd")) 247 .accept(MediaType.TEXT_XML).get(String.class).trim(); 248 assertTrue(component 249 .startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?><xs:schema")); 250 assertTrue(component.endsWith("</xs:schema>")); 251 252 component = this.getAuthenticatedResource(getResource().path("/registry/components/" + id + "/xml")) 253 .accept(MediaType.TEXT_XML).get(String.class).trim(); 254 assertTrue(component 255 .startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<CMD_ComponentSpec")); 256 assertTrue(component.endsWith("</CMD_ComponentSpec>")); 257 assertTrue(component.contains("xsi:schemaLocation")); 258 259 id = ProfileDescription.PROFILE_PREFIX + "Bprofile-1"; 260 String profile = this.getAuthenticatedResource(getResource() 261 .path("/registry/profiles/" + id + "/xsd")) 262 .accept(MediaType.TEXT_XML).get(String.class).trim(); 263 assertTrue(profile 264 .startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?><xs:schema")); 265 assertTrue(profile.endsWith("</xs:schema>")); 266 267 profile = this.getAuthenticatedResource(getResource().path("/registry/profiles/" + id + "/xml")) 268 .accept(MediaType.TEXT_XML).get(String.class).trim(); 269 assertTrue(profile 270 .startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<CMD_ComponentSpec")); 271 assertTrue(profile.endsWith("</CMD_ComponentSpec>")); 272 assertTrue(profile.contains("xsi:schemaLocation")); 273 274 id = ComponentDescription.COMPONENT_PREFIX + "Ccomponent-1"; 275 ClientResponse resp = this.getAuthenticatedResource(getResource() 276 .path("/registry/components/" + id + "/xsd")) 277 .accept(MediaType.TEXT_XML).get( ClientResponse.class); 278 assertEquals(403, resp.getStatus()); 279 291 280 id = ProfileDescription.PROFILE_PREFIX + "Cprofile-1"; 292 form.field(IComponentRegistryRestService.DATA_FORM_FIELD, 293 RegistryTestHelper.getCommentTestContentStringForProfile("comment3", id), 294 MediaType.APPLICATION_OCTET_STREAM_TYPE); 295 ClientResponse cresponse = getAuthenticatedResource( 296 "/registry/profiles/" + id + "/comments").type( 297 MediaType.MULTIPART_FORM_DATA) 298 .post(ClientResponse.class, form); 299 assertEquals(403, cresponse.getStatus()); 300 301 302 303 form = new FormDataMultiPart(); 304 id = ComponentDescription.COMPONENT_PREFIX + "Ccomponent-1"; 305 form.field(IComponentRegistryRestService.DATA_FORM_FIELD, 306 RegistryTestHelper.getCommentTestContentStringForComponent("comment4", id), 307 MediaType.APPLICATION_OCTET_STREAM_TYPE); 308 cresponse = getAuthenticatedResource( 309 "/registry/components/" + id + "/comments").type( 310 MediaType.MULTIPART_FORM_DATA) 311 .post(ClientResponse.class, form); 312 assertEquals(403, cresponse.getStatus()); 281 resp = this.getAuthenticatedResource(getResource() 282 .path("/registry/profiles/" + id + "/xsd")) 283 .accept(MediaType.TEXT_XML).get( ClientResponse.class); 284 assertEquals(403, resp.getStatus()); 285 286 313 287 } 314 288
Note: See TracChangeset
for help on using the changeset viewer.