From d6197cb2641df0f1abb0821c278058cd7a57f647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Haarla=CC=88nder?= Date: Tue, 21 Nov 2023 09:31:20 +0100 Subject: [PATCH] Test server for static files --- .../test/integration/ImejiTestBase.java | 40 +++++- .../test/integration/ItemTestBase.java | 2 +- .../integration/MyTestContainerFactory.java | 132 ------------------ .../rest/resources/CollectionIntegration.java | 11 +- .../rest/resources/ItemIntegration.java | 18 ++- .../rest/resources/StorageIntegration.java | 2 +- .../rest/resources/VersionManagerTest.java | 2 +- .../rest/resources/item/ItemCreate.java | 3 +- .../rest/resources/item/ItemDelete.java | 2 +- .../rest/resources/item/ItemRead.java | 2 +- .../rest/resources/item/ItemUpdate.java | 8 +- .../rest/resources/item/ItemUpdateFile.java | 6 +- 12 files changed, 57 insertions(+), 171 deletions(-) delete mode 100644 src/test/java/de/mpg/imeji/test/rest/resources/test/integration/MyTestContainerFactory.java diff --git a/src/test/java/de/mpg/imeji/test/rest/resources/test/integration/ImejiTestBase.java b/src/test/java/de/mpg/imeji/test/rest/resources/test/integration/ImejiTestBase.java index 54ac1adcf..e8875763f 100644 --- a/src/test/java/de/mpg/imeji/test/rest/resources/test/integration/ImejiTestBase.java +++ b/src/test/java/de/mpg/imeji/test/rest/resources/test/integration/ImejiTestBase.java @@ -1,10 +1,10 @@ package de.mpg.imeji.test.rest.resources.test.integration; import static de.mpg.imeji.logic.util.ResourceHelper.getStringFromPath; -import static de.mpg.imeji.test.rest.resources.test.integration.MyTestContainerFactory.STATIC_CONTEXT_REST; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.net.URI; import java.net.URISyntaxException; import javax.ws.rs.core.Application; @@ -12,9 +12,16 @@ import de.mpg.imeji.logic.security.user.UserService; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.glassfish.grizzly.http.server.HttpServer; +import org.glassfish.grizzly.http.server.StaticHttpHandler; import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; +import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; +import org.glassfish.jersey.servlet.ServletContainer; +import org.glassfish.jersey.test.DeploymentContext; import org.glassfish.jersey.test.JerseyTest; +import org.glassfish.jersey.test.ServletDeploymentContext; import org.glassfish.jersey.test.TestProperties; +import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; import org.junit.AfterClass; @@ -42,6 +49,12 @@ */ public class ImejiTestBase extends JerseyTest { + public static final String STATIC_SERVER_URL = "http://localhost:9999"; + public static final String STATIC_CONTEXT_PATH = "/static"; + public static final String STATIC_CONTEXT_STORAGE = "src/test/resources/storage"; + public static final String STATIC_CONTEXT_REST = "src/test/resources/rest"; + + private static HttpServer staticServer; protected static HttpAuthenticationFeature authAsUser = HttpAuthenticationFeature.basic(JenaUtil.TEST_USER_EMAIL, JenaUtil.TEST_USER_PWD); protected static HttpAuthenticationFeature authAsUser2 = HttpAuthenticationFeature.basic(JenaUtil.TEST_USER_EMAIL_2, JenaUtil.TEST_USER_PWD); @@ -63,21 +76,33 @@ protected Application configure() { enable(TestProperties.LOG_TRAFFIC); enable(TestProperties.DUMP_ENTITY); - if (app == null) { - app = new ImejiRestService(null); - } - return app; + return new ImejiRestService(null); + } + + @Override + protected DeploymentContext configureDeployment() { + return ServletDeploymentContext.forServlet(new ServletContainer(new ImejiRestService(null))).servletPath("rest").build(); } + + @Override protected TestContainerFactory getTestContainerFactory() throws TestContainerException { - return new MyTestContainerFactory(); + return new GrizzlyWebTestContainerFactory(); } + + @BeforeClass public static void setup() throws IOException, URISyntaxException { ElasticsearchTestUtil.startElasticsearch(); JenaUtil.initJena(); + //Start a server for the static content + staticServer = GrizzlyHttpServerFactory.createHttpServer(new URI(STATIC_SERVER_URL)); + staticServer.getServerConfiguration().addHttpHandler(new StaticHttpHandler(STATIC_CONTEXT_REST, STATIC_CONTEXT_STORAGE), + STATIC_CONTEXT_PATH); + staticServer.start(); + } @AfterClass @@ -85,6 +110,7 @@ public static void shutdown() throws IOException, URISyntaxException, Interrupte ConcurrencyUtil.waitForImejiThreadsToComplete(); ElasticsearchTestUtil.stopElasticsearch(); JenaUtil.closeJena(); + staticServer.shutdownNow(); app = null; } @@ -108,7 +134,7 @@ public static String initCollection() { CollectionAPIService s = new CollectionAPIService(); try { collectionTO = - (CollectionTO) RestProcessUtils.buildTOFromJSON(getStringFromPath(STATIC_CONTEXT_REST + "/collection.json"), CollectionTO.class); + (CollectionTO) RestProcessUtils.buildTOFromJSON(getStringFromPath("src/test/resources/rest/collection.json"), CollectionTO.class); collectionTO = s.create(collectionTO, JenaUtil.testUser); collectionId = collectionTO.getId(); diff --git a/src/test/java/de/mpg/imeji/test/rest/resources/test/integration/ItemTestBase.java b/src/test/java/de/mpg/imeji/test/rest/resources/test/integration/ItemTestBase.java index 7e13ecaa4..830d22dc0 100644 --- a/src/test/java/de/mpg/imeji/test/rest/resources/test/integration/ItemTestBase.java +++ b/src/test/java/de/mpg/imeji/test/rest/resources/test/integration/ItemTestBase.java @@ -36,7 +36,7 @@ public class ItemTestBase extends ImejiTestBase { private static final Logger LOGGER = LogManager.getLogger(ItemTestBase.class); public static Item item; - private static final String TARGET_PATH_PREFIX = "/rest/items"; + private static final String TARGET_PATH_PREFIX = "/items"; protected static void createItem() throws Exception { CollectionService cc = new CollectionService(); diff --git a/src/test/java/de/mpg/imeji/test/rest/resources/test/integration/MyTestContainerFactory.java b/src/test/java/de/mpg/imeji/test/rest/resources/test/integration/MyTestContainerFactory.java deleted file mode 100644 index c788e5e30..000000000 --- a/src/test/java/de/mpg/imeji/test/rest/resources/test/integration/MyTestContainerFactory.java +++ /dev/null @@ -1,132 +0,0 @@ -package de.mpg.imeji.test.rest.resources.test.integration; - -import java.io.IOException; -import java.net.URI; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.servlet.Servlet; -import javax.ws.rs.ProcessingException; - -import org.glassfish.grizzly.http.server.HttpServer; -import org.glassfish.grizzly.http.server.StaticHttpHandler; -import org.glassfish.grizzly.servlet.ServletRegistration; -import org.glassfish.grizzly.servlet.WebappContext; -import org.glassfish.jersey.client.ClientConfig; -import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; -import org.glassfish.jersey.servlet.ServletContainer; -import org.glassfish.jersey.test.DeploymentContext; -import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory; -import org.glassfish.jersey.test.spi.TestContainer; -import org.glassfish.jersey.test.spi.TestContainerException; -import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.glassfish.jersey.uri.UriComponent; - -import com.google.common.collect.ImmutableMap; - -/** - * The class overrides TestContainerFactory with GrizzlyWebContainerFactory. The GrizzlyWebContainer - * fully supports HttpServlet, that is needed to test @Context injection variables in tests - * - * @author vmakarenko - * - */ -public class MyTestContainerFactory implements TestContainerFactory { - - private static final Logger LOGGER = Logger.getLogger(MyTestContainerFactory.class.getName()); - - public static final String REST_CONTEXT_PATH = "/rest"; - public static final String STATIC_CONTEXT_PATH = "/static"; - public static final String STATIC_CONTEXT_STORAGE = "src/test/resources/storage"; - public static final String STATIC_CONTEXT_REST = "src/test/resources/rest"; - - @Override - public TestContainer create(final URI baseUri, final DeploymentContext deploymentContext) throws IllegalArgumentException { - return new TestContainer() { - private HttpServer server; - - @Override - public ClientConfig getClientConfig() { - return null; - } - - @Override - public URI getBaseUri() { - return baseUri; - } - - @Override - public void start() { - try { - this.server = create(baseUri, ServletContainer.class, null, - ImmutableMap.of("jersey.config.server.provider.packages", "de.mpg.imeji.rest.resources", - "jersey.config.server.provider.classnames", - "org.glassfish.jersey.filter.LoggingFilter;org.glassfish.jersey.media.multipart.MultiPartFeature"), - null); - - } catch (ProcessingException | IOException e) { - throw new TestContainerException(e); - } - } - - @Override - public void stop() { - if (this.server.isStarted()) { - LOGGER.log(Level.FINE, "Stopping GrizzlyTestContainer..."); - this.server.shutdownNow(); - } else { - LOGGER.log(Level.WARNING, "Ignoring stop request - GrizzlyTestContainer is already stopped."); - } - - } - }; - - } - - private static HttpServer create(URI u, Class c, Servlet servlet, Map initParams, - Map contextInitParams) throws IOException { - if (u == null) { - throw new IllegalArgumentException("The URI must not be null"); - } - - String path = u.getPath(); - if (path == null) { - throw new IllegalArgumentException("The URI path, of the URI " + u + ", must be non-null"); - } else if (path.isEmpty()) { - throw new IllegalArgumentException("The URI path, of the URI " + u + ", must be present"); - } else if (path.charAt(0) != '/') { - throw new IllegalArgumentException("The URI path, of the URI " + u + ". must start with a '/'"); - } - - path = String.format("/%s", UriComponent.decodePath(u.getPath(), true).get(1).toString()); - - WebappContext context = new WebappContext("GrizzlyContext", REST_CONTEXT_PATH); - ServletRegistration registration; - if (c != null) { - registration = context.addServlet(c.getName(), c); - } else { - registration = context.addServlet(servlet.getClass().getName(), servlet); - } - registration.addMapping("/*"); - - if (contextInitParams != null) { - for (Map.Entry e : contextInitParams.entrySet()) { - context.setInitParameter(e.getKey(), e.getValue()); - } - } - - if (initParams != null) { - registration.setInitParameters(initParams); - } - - HttpServer server = GrizzlyHttpServerFactory.createHttpServer(u); - - context.deploy(server); - - server.getServerConfiguration().addHttpHandler(new StaticHttpHandler(STATIC_CONTEXT_REST, STATIC_CONTEXT_STORAGE), STATIC_CONTEXT_PATH); - - return server; - } - -} diff --git a/src/test/java/de/mpg/imeji/testimpl/rest/resources/CollectionIntegration.java b/src/test/java/de/mpg/imeji/testimpl/rest/resources/CollectionIntegration.java index 8bb250734..c1e4cb7fe 100644 --- a/src/test/java/de/mpg/imeji/testimpl/rest/resources/CollectionIntegration.java +++ b/src/test/java/de/mpg/imeji/testimpl/rest/resources/CollectionIntegration.java @@ -3,7 +3,6 @@ import static de.mpg.imeji.logic.util.ResourceHelper.getStringFromPath; import static de.mpg.imeji.rest.process.RestProcessUtils.buildJSONFromObject; import static de.mpg.imeji.rest.process.RestProcessUtils.jsonToPOJO; -import static de.mpg.imeji.test.rest.resources.test.integration.MyTestContainerFactory.STATIC_CONTEXT_REST; import static javax.ws.rs.core.Response.Status.CREATED; import static javax.ws.rs.core.Response.Status.FORBIDDEN; import static javax.ws.rs.core.Response.Status.NOT_FOUND; @@ -57,7 +56,7 @@ public class CollectionIntegration extends ImejiTestBase { private static final Logger LOGGER = LoggerFactory.getLogger(CollectionIntegration.class); - private static String pathPrefix = "/rest/collections"; + private static String pathPrefix = "/collections"; private static String updateJSON; @Before @@ -67,7 +66,7 @@ public void specificSetup() { @Test public void test_1_CreateCollection() throws IOException, ImejiException { - String jsonString = getStringFromPath(STATIC_CONTEXT_REST + "/collection.json"); + String jsonString = getStringFromPath("src/test/resources/rest/collection.json"); Response response = target(pathPrefix).register(authAsUser).register(MultiPartFeature.class).request(MediaType.APPLICATION_JSON_TYPE) .post(Entity.entity(jsonString, MediaType.APPLICATION_JSON_TYPE)); assertEquals(response.getStatus(), CREATED.getStatusCode()); @@ -79,7 +78,7 @@ public void test_1_CreateCollection() throws IOException, ImejiException { @Test public void test_1_CreateCollection_5_NoAuth() throws IOException { - String jsonString = getStringFromPath(STATIC_CONTEXT_REST + "/collection.json"); + String jsonString = getStringFromPath("src/test/resources/rest/collection.json"); Response response = target(pathPrefix).register(MultiPartFeature.class).request(MediaType.APPLICATION_JSON_TYPE) .post(Entity.entity(jsonString, MediaType.APPLICATION_JSON_TYPE)); assertEquals(UNAUTHORIZED.getStatusCode(), response.getStatus()); @@ -374,7 +373,7 @@ public void test_6_UpdateCollection() throws IOException, BadRequestException, U @Test public void test_6_CreateCollection_1_AdditionalInfos() throws ImejiException, UnsupportedEncodingException, IOException { - String originalJsonString = getStringFromPath(STATIC_CONTEXT_REST + "/collection.json"); + String originalJsonString = getStringFromPath("src/test/resources/rest/collection.json"); String jsonString = originalJsonString; jsonString = jsonString.replace("\"label\": \"Label1\",", ""); @@ -403,7 +402,7 @@ public void test_6_CreateCollection_1_AdditionalInfos() throws ImejiException, U @Test public void test_6_UpdateCollection_1_AdditionalInfos() throws ImejiException, UnsupportedEncodingException, IOException { - String originalJsonString = getStringFromPath(STATIC_CONTEXT_REST + "/collection.json"); + String originalJsonString = getStringFromPath("src/test/resources/rest/collection.json"); // Create the collection Response response = target(pathPrefix).register(authAsUser).register(MultiPartFeature.class).request(MediaType.APPLICATION_JSON_TYPE) diff --git a/src/test/java/de/mpg/imeji/testimpl/rest/resources/ItemIntegration.java b/src/test/java/de/mpg/imeji/testimpl/rest/resources/ItemIntegration.java index a6059ce0c..3ab91a100 100644 --- a/src/test/java/de/mpg/imeji/testimpl/rest/resources/ItemIntegration.java +++ b/src/test/java/de/mpg/imeji/testimpl/rest/resources/ItemIntegration.java @@ -3,8 +3,6 @@ import static de.mpg.imeji.logic.util.ResourceHelper.getStringFromPath; import static de.mpg.imeji.logic.util.StorageUtils.calculateChecksum; import static de.mpg.imeji.rest.process.RestProcessUtils.jsonToPOJO; -import static de.mpg.imeji.test.rest.resources.test.integration.MyTestContainerFactory.STATIC_CONTEXT_PATH; -import static de.mpg.imeji.test.rest.resources.test.integration.MyTestContainerFactory.STATIC_CONTEXT_REST; import static javax.ws.rs.core.Response.Status.BAD_REQUEST; import static javax.ws.rs.core.Response.Status.CREATED; import static javax.ws.rs.core.Response.Status.OK; @@ -61,7 +59,7 @@ public class ItemIntegration extends ItemTestBase { private static final Logger LOGGER = LoggerFactory.getLogger(ItemIntegration.class); private static String itemJSON; private static String updateJSON; - private static final String PATH_PREFIX = "/rest/items"; + private static final String PATH_PREFIX = "/items"; private static final String UPDATED_FILE_NAME = "updated_filename.png"; private static String storedFileURL; @@ -70,7 +68,7 @@ public static void specificSetup() throws Exception { initCollection(); initItem(); itemJSON = getStringFromPath("src/test/resources/rest/itemCreateBasic.json"); - updateJSON = getStringFromPath(STATIC_CONTEXT_REST + "/item.json"); + updateJSON = getStringFromPath("src/test/resources/rest/item.json"); } @Test @@ -267,7 +265,7 @@ public void createItem_SyntaxInvalidJSONFile() throws Exception { @Test public void createItem_WithFile_Fetched() throws IOException { initCollection(); - final String fileURL = target().getUri() + STATIC_CONTEXT_PATH.substring(1) + "/test3.jpg"; + final String fileURL = STATIC_SERVER_URL + STATIC_CONTEXT_PATH + "/test3.jpg"; FormDataMultiPart multiPart = new FormDataMultiPart(); multiPart.field("json", itemJSON.replace("___COLLECTION_ID___", collectionId).replace("___FETCH_URL___", fileURL) @@ -283,7 +281,7 @@ public void createItem_WithFile_Fetched() throws IOException { @Test public void createItem_WithFile_Fetched_WithEmptyFileName() throws IOException { initCollection(); - final String fileURL = target().getUri() + STATIC_CONTEXT_PATH.substring(1) + "/test7.jpg"; + final String fileURL = STATIC_SERVER_URL + STATIC_CONTEXT_PATH + "/test7.jpg"; FormDataMultiPart multiPart = new FormDataMultiPart(); multiPart.field("json", @@ -532,7 +530,7 @@ public void test_1_UpdateItem_2_WithFile_Fetched() throws ImejiException, IOExce initCollection(); initItem(); - final String fileURL = target().getUri() + STATIC_CONTEXT_PATH.substring(1) + "/test2.jpg"; + final String fileURL = STATIC_SERVER_URL + STATIC_CONTEXT_PATH + "/test2.jpg"; FormDataMultiPart multiPart = new FormDataMultiPart(); multiPart.field("json", getStringFromPath(updateJSON).replace("___FILE_NAME___", UPDATED_FILE_NAME).replace("___FETCH_URL___", fileURL) @@ -574,7 +572,7 @@ public void test_1_UpdateItem_4_WithFile_Attached_Fetched() throws IOException, File newFile = ImejiTestResources.getTestPng(); - final String fileURL = target().getUri() + STATIC_CONTEXT_PATH.substring(1) + "/test.jpg"; + final String fileURL = STATIC_SERVER_URL + STATIC_CONTEXT_PATH + "/test.jpg"; FileDataBodyPart filePart = new FileDataBodyPart("file", newFile); @@ -624,7 +622,7 @@ public void test_1_UpdateItem_5_WithFile_Attached_Referenced() throws IOExceptio @Test public void test_1_UpdateItem_6_WithFile_Fetched_Referenced() throws IOException, ImejiException { - final String fileURL = target().getUri() + STATIC_CONTEXT_PATH.substring(1) + "/test.jpg"; + final String fileURL = STATIC_SERVER_URL + STATIC_CONTEXT_PATH + "/test.jpg"; FormDataMultiPart multiPart = new FormDataMultiPart(); multiPart.field("json", getStringFromPath(updateJSON).replace("___FILE_NAME___", UPDATED_FILE_NAME).replace("___FETCH_URL___", fileURL) @@ -653,7 +651,7 @@ public void test_1_UpdateItem_7_WithFile_Attached_Fetched_Referenced() throws IO File newFile = ImejiTestResources.getTest1Jpg(); FileDataBodyPart filePart = new FileDataBodyPart("file", newFile); - final String fileURL = target().getUri() + STATIC_CONTEXT_PATH.substring(1) + "/test1.jpg"; + final String fileURL = STATIC_SERVER_URL + STATIC_CONTEXT_PATH + "/test1.jpg"; FormDataMultiPart multiPart = new FormDataMultiPart(); multiPart.bodyPart(filePart); diff --git a/src/test/java/de/mpg/imeji/testimpl/rest/resources/StorageIntegration.java b/src/test/java/de/mpg/imeji/testimpl/rest/resources/StorageIntegration.java index 1a6187e3e..eb42f70a4 100644 --- a/src/test/java/de/mpg/imeji/testimpl/rest/resources/StorageIntegration.java +++ b/src/test/java/de/mpg/imeji/testimpl/rest/resources/StorageIntegration.java @@ -23,7 +23,7 @@ public class StorageIntegration extends ImejiTestBase { private static final Logger LOGGER = LoggerFactory.getLogger(StorageIntegration.class); - private final String PATH_PREFIX = "/rest/storage"; + private final String PATH_PREFIX = "/storage"; @Test public void test_1_uploadFormats() throws IOException { diff --git a/src/test/java/de/mpg/imeji/testimpl/rest/resources/VersionManagerTest.java b/src/test/java/de/mpg/imeji/testimpl/rest/resources/VersionManagerTest.java index db62ce9ab..6f561e06c 100644 --- a/src/test/java/de/mpg/imeji/testimpl/rest/resources/VersionManagerTest.java +++ b/src/test/java/de/mpg/imeji/testimpl/rest/resources/VersionManagerTest.java @@ -20,7 +20,7 @@ public class VersionManagerTest extends ImejiTestBase { private static String pathPrefixWithVersion = "/rest/vXXX_VERSION_XXX/collections"; - private static String pathPrefix = "/rest/collections"; + private static String pathPrefix = "/collections"; @Test public void testDeprecatedVersion() throws IOException { diff --git a/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemCreate.java b/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemCreate.java index aca3c35b4..f5dbc0a31 100644 --- a/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemCreate.java +++ b/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemCreate.java @@ -2,7 +2,6 @@ import static de.mpg.imeji.logic.util.ResourceHelper.getStringFromPath; import static de.mpg.imeji.rest.process.RestProcessUtils.jsonToPOJO; -import static de.mpg.imeji.test.rest.resources.test.integration.MyTestContainerFactory.STATIC_CONTEXT_PATH; import static javax.ws.rs.core.Response.Status.BAD_REQUEST; import static javax.ws.rs.core.Response.Status.CREATED; import static org.hamcrest.CoreMatchers.equalTo; @@ -46,7 +45,7 @@ public class ItemCreate extends ItemTestBase { private static String itemJSON; - private static final String pathPrefix = "/rest/items"; + private static final String pathPrefix = "/items"; @BeforeClass public static void specificSetup() throws Exception { diff --git a/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemDelete.java b/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemDelete.java index 38f5ca29c..3948b66f9 100644 --- a/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemDelete.java +++ b/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemDelete.java @@ -20,7 +20,7 @@ public class ItemDelete extends ImejiTestBase { private static final Logger LOGGER = LoggerFactory.getLogger(ItemDelete.class); - private static final String pathPrefix = "/rest/items"; + private static final String pathPrefix = "/items"; @BeforeClass public static void specificSetup() throws Exception { diff --git a/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemRead.java b/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemRead.java index 9fa84937e..2d627adae 100644 --- a/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemRead.java +++ b/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemRead.java @@ -32,7 +32,7 @@ public class ItemRead extends ItemTestBase { private static final Logger LOGGER = LoggerFactory.getLogger(ItemRead.class); - private static final String PATH_PREFIX = "/rest/items"; + private static final String PATH_PREFIX = "/items"; @Before public void specificSetup() throws Exception { diff --git a/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemUpdate.java b/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemUpdate.java index e7b140f96..8a305093b 100644 --- a/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemUpdate.java +++ b/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemUpdate.java @@ -1,7 +1,6 @@ package de.mpg.imeji.testimpl.rest.resources.item; import static de.mpg.imeji.logic.util.ResourceHelper.getStringFromPath; -import static de.mpg.imeji.test.rest.resources.test.integration.MyTestContainerFactory.STATIC_CONTEXT_REST; import static javax.ws.rs.core.Response.Status.BAD_REQUEST; import static javax.ws.rs.core.Response.Status.FORBIDDEN; import static javax.ws.rs.core.Response.Status.OK; @@ -42,17 +41,16 @@ public class ItemUpdate extends ItemTestBase { private static final Logger LOGGER = LoggerFactory.getLogger(ItemUpdate.class); - private static String updateJSON; - private static final String PATH_PREFIX = "/rest/items"; + //private static String updateJSON; + private static final String PATH_PREFIX = "/items"; private static final String UPDATED_FILE_NAME = "updated_filename.png"; - private final String UPDATE_ITEM_FILE_JSON = STATIC_CONTEXT_REST + "/item.json"; private static final String referenceUrl = "http://th03.deviantart.net/fs71/PRE/i/2012/242/1/f/png_moon_by_paradise234-d5czhdo.png"; @BeforeClass public static void specificSetup() throws Exception { initCollection(); createItem(); - updateJSON = getStringFromPath(STATIC_CONTEXT_REST + "/item.json"); + //updateJSON = getStringFromPath(STATIC_CONTEXT_REST + "/item.json"); } @Test diff --git a/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemUpdateFile.java b/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemUpdateFile.java index 5a5fb4c51..315e5a02e 100644 --- a/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemUpdateFile.java +++ b/src/test/java/de/mpg/imeji/testimpl/rest/resources/item/ItemUpdateFile.java @@ -2,8 +2,6 @@ import static de.mpg.imeji.logic.util.ResourceHelper.getStringFromPath; import static de.mpg.imeji.logic.util.StorageUtils.calculateChecksum; -import static de.mpg.imeji.test.rest.resources.test.integration.MyTestContainerFactory.STATIC_CONTEXT_PATH; -import static de.mpg.imeji.test.rest.resources.test.integration.MyTestContainerFactory.STATIC_CONTEXT_REST; import static javax.ws.rs.core.Response.Status.OK; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.endsWith; @@ -48,10 +46,10 @@ public class ItemUpdateFile extends ImejiTestBase { private static final Logger LOGGER = LoggerFactory.getLogger(ItemUpdateFile.class); - private static final String PATH_PREFIX = "/rest/items"; + private static final String PATH_PREFIX = "/items"; private static final String UPDATED_FILE_NAME = "updated_filename.png"; private static String storedFileURL; - private final String UPDATE_ITEM_FILE_JSON = STATIC_CONTEXT_REST + "/item.json"; + private final String UPDATE_ITEM_FILE_JSON = "/rest/item.json"; @BeforeClass public static void specificSetup() throws Exception {