@Test public void testTransformToHtml() throws Exception { processor.addApplication(new Application0()); ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter(); ContainerResponse response = launcher.service("GET", "/a", "", null, null, writer, null); Assert.assertEquals(200, response.getStatus()); System.out.println(new String(writer.getBody())); }
public void testDeleteRootFolder() throws Exception { ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter(); String path = SERVICE_URI + "delete/" + mountPoint.getRoot().getId(); ContainerResponse response = launcher.service(HttpMethod.POST, path, BASE_URI, null, null, writer, null); assertEquals(403, response.getStatus()); log.info(new String(writer.getBody())); }
public void testDeleteFileWrongId() throws Exception { ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter(); String path = SERVICE_URI + "delete/" + fileId + "_WRONG_ID"; ContainerResponse response = launcher.service(HttpMethod.POST, path, BASE_URI, null, null, writer, null); assertEquals(404, response.getStatus()); log.info(new String(writer.getBody())); }
public void testDeleteFileLockedNoLockToken() throws Exception { file.lock(0); ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter(); String path = SERVICE_URI + "delete/" + fileId; ContainerResponse response = launcher.service(HttpMethod.POST, path, BASE_URI, null, null, writer, null); assertEquals(403, response.getStatus()); log.info(new String(writer.getBody())); try { mountPoint.getVirtualFileById(fileId); } catch (NotFoundException e) { fail("File must not be removed since it is locked. "); } }
public void testUpdateFileNoPermissions() throws Exception { String properties = "[{\"name\":\"MyProperty\", \"value\":[\"MyValue\"]}]"; String requestPath = SERVICE_URI + "item/" + protectedFileId; Map<String, List<String>> h = new HashMap<>(1); h.put(HttpHeaders.CONTENT_TYPE, Arrays.asList(MediaType.APPLICATION_JSON)); ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter(); ContainerResponse response = launcher.service( HttpMethod.POST, requestPath, BASE_URI, h, properties.getBytes(), writer, null); assertEquals(403, response.getStatus()); log.info(new String(writer.getBody())); assertNull("Properties must not be updated.", readProperties(protectedFilePath)); Item item = getItem(protectedFileId); assertNull(getPropertyValue(item, "MyProperty")); }
private void publicationTest(boolean singleton, ResourceId resourceId) throws Exception { String script = // "@javax.ws.rs.Path(\"a\")" // + "class GroovyResource {" // + "@javax.ws.rs.GET @javax.ws.rs.Path(\"{who}\")" // + "def m0(@javax.ws.rs.PathParam(\"who\") String who) { return (\"hello \" + who)}" // + "}"; int initSize = resources.getSize(); Assert.assertEquals(0, groovyPublisher.resources.size()); if (singleton) { groovyPublisher.publishSingleton(script, resourceId, null, null, null); } else { groovyPublisher.publishPerRequest(script, resourceId, null, null, null); } Assert.assertEquals(initSize + 1, resources.getSize()); Assert.assertEquals(1, groovyPublisher.resources.size()); Assert.assertTrue(groovyPublisher.isPublished(resourceId)); String cs = resources .getMatchedResource("/a", new ArrayList<String>()) .getObjectModel() .getObjectClass() .getProtectionDomain() .getCodeSource() .getLocation() .toString(); Assert.assertEquals("file:/groovy/script/jaxrs", cs); ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter(); ContainerResponse resp = launcher.service("GET", "/a/groovy", "", null, null, writer, null); Assert.assertEquals(200, resp.getStatus()); Assert.assertEquals("hello groovy", new String(writer.getBody())); groovyPublisher.unpublishResource(resourceId); Assert.assertEquals(initSize, resources.getSize()); Assert.assertEquals(0, groovyPublisher.resources.size()); }