diff --git a/api-data-store-server-java/src/test/java/ch/ethz/sis/afsclient/client/AfsClientTest.java b/api-data-store-server-java/src/test/java/ch/ethz/sis/afsclient/client/AfsClientTest.java index 694c329b9352d59c37186d9206c01ccf40fee55d..b4ada3b7708bf88e59347c0d389a16f58ced0b9d 100644 --- a/api-data-store-server-java/src/test/java/ch/ethz/sis/afsclient/client/AfsClientTest.java +++ b/api-data-store-server-java/src/test/java/ch/ethz/sis/afsclient/client/AfsClientTest.java @@ -27,7 +27,8 @@ public class AfsClientTest httpServer = new DummyHttpServer(httpServerPort, httpServerPath); httpServer.start(); afsClient = new AfsClient( - new URI("http", null, "localhost", httpServerPort, httpServerPath, null, null)); + new URI("http", null, "localhost", httpServerPort, + httpServerPath, null, null)); } @AfterClass diff --git a/server-data-store/src/test/java/ch/ethz/sis/afsserver/ApiClientTest.java b/server-data-store/src/test/java/ch/ethz/sis/afsserver/ApiClientTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d443be045773553d6f5bfb309d388fb2cb5d680c --- /dev/null +++ b/server-data-store/src/test/java/ch/ethz/sis/afsserver/ApiClientTest.java @@ -0,0 +1,73 @@ +/* + * Copyright ETH 2023 Zürich, Scientific IT Services + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package ch.ethz.sis.afsserver; + +import static org.junit.Assert.*; + +import java.net.URI; +import java.util.List; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import ch.ethz.sis.afs.manager.TransactionConnection; +import ch.ethz.sis.afsclient.client.AfsClient; +import ch.ethz.sis.afsserver.server.Server; +import ch.ethz.sis.afsserver.server.observer.impl.DummyServerObserver; +import ch.ethz.sis.afsserver.startup.AtomicFileSystemServerParameter; +import ch.ethz.sis.shared.startup.Configuration; + +public final class ApiClientTest +{ + private static Server<TransactionConnection, ?> afsServer; + + private static AfsClient afsClient; + + @BeforeClass + public static void classSetUp() throws Exception + { + final Configuration configuration = + new Configuration(List.of(AtomicFileSystemServerParameter.class), + "src/test/resources/test-server-config.properties"); + final DummyServerObserver dummyServerObserver = new DummyServerObserver(); + afsServer = new Server<>(configuration, dummyServerObserver, dummyServerObserver); + + final int httpServerPort = + configuration.getIntegerProperty(AtomicFileSystemServerParameter.httpServerPort); + final String httpServerPath = + configuration.getStringProperty(AtomicFileSystemServerParameter.httpServerUri); + afsClient = new AfsClient( + new URI("http", null, "localhost", httpServerPort, + httpServerPath, null, null)); + } + + @AfterClass + public static void classTearDown() throws Exception + { + afsServer.shutdown(true); + } + + @Test + public void testLogin() throws Exception + { + final String token = afsClient.login("test", "test"); + assertNotNull(token); + } + +} diff --git a/api-data-store-server-java/src/test/resources/afs-server-config.properties b/server-data-store/src/test/resources/test-server-config.properties old mode 100755 new mode 100644 similarity index 100% rename from api-data-store-server-java/src/test/resources/afs-server-config.properties rename to server-data-store/src/test/resources/test-server-config.properties index c06770648e5fb85e905171669a9af524bf77a182..0b988b4160d4a558b42d4d219c337a9e64b0cb6f --- a/api-data-store-server-java/src/test/resources/afs-server-config.properties +++ b/server-data-store/src/test/resources/test-server-config.properties @@ -8,8 +8,8 @@ writeAheadLogRoot=./target/tests/transactions storageRoot=./target/tests/storage httpServerClass=ch.ethz.sis.afsserver.http.impl.NettyHttpServer -httpServerUri=/fileserver httpServerPort=8085 +httpServerUri=/fileserver httpMaxContentLength=1024 maxReadSizeInBytes=1024