Skip to content
Snippets Groups Projects
Commit 33291bf7 authored by Hallvard Trætteberg's avatar Hallvard Trætteberg
Browse files

Logging og port-bruk

parent cc9c5847
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,6 @@ import java.util.Objects; ...@@ -6,7 +6,6 @@ import java.util.Objects;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.ComboBox; import javafx.scene.control.ComboBox;
import todolist.core.TodoList; import todolist.core.TodoList;
import todolist.json.TodoPersistence;
public class TodoModelController { public class TodoModelController {
......
...@@ -80,15 +80,24 @@ ...@@ -80,15 +80,24 @@
<plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
</plugin> </plugin>
<!-- Reservere porter og tilordne dem til variabler -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>maven-failsafe-plugin</artifactId> <artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0-M1</version> <version>3.2.0</version>
<configuration>
<portNames>
<portName>jetty.port</portName>
<portName>jetty.port.stop</portName>
</portNames>
</configuration>
<executions> <executions>
<execution> <execution>
<id>reserve-port</id>
<phase>pre-integration-test</phase>
<goals> <goals>
<goal>integration-test</goal> <goal>reserve-network-port</goal>
<goal>verify</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
...@@ -99,10 +108,10 @@ ...@@ -99,10 +108,10 @@
<version>9.4.31.v20200723</version> <version>9.4.31.v20200723</version>
<configuration> <configuration>
<httpConnector> <httpConnector>
<port>8999</port> <port>${jetty.port}</port>
</httpConnector> </httpConnector>
<stopKey>quit</stopKey> <stopKey>quit</stopKey>
<stopPort>9000</stopPort> <stopPort>${jetty.port.stop}</stopPort>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
...@@ -121,6 +130,25 @@ ...@@ -121,6 +130,25 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<!-- System.getProperty("todo.port") gir riktig port -->
<systemPropertyVariables>
<todo.port>${jetty.port}</todo.port>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>
# http://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html
org.slf4j.simpleLogger.defaultLogLevel=INFO
org.slf4j.simpleLogger.log.todolist.restapi=DEBUG
...@@ -10,6 +10,8 @@ import static org.junit.jupiter.api.Assertions.fail; ...@@ -10,6 +10,8 @@ import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import java.net.URI;
import java.net.URISyntaxException;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.testfx.framework.junit5.ApplicationTest; import org.testfx.framework.junit5.ApplicationTest;
...@@ -27,14 +29,15 @@ public class TodoAppIT extends ApplicationTest { ...@@ -27,14 +29,15 @@ public class TodoAppIT extends ApplicationTest {
stage.show(); stage.show();
} }
private TodoPersistence todoPersistence = new TodoPersistence();
@BeforeEach @BeforeEach
public void setupItems() { public void setupItems() throws URISyntaxException {
// same as in test-todolist.json (should perhaps read it instead) // same as in test-todolist.json (should perhaps read it instead)
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream("it-todomodel.json"))) { try (Reader reader = new InputStreamReader(getClass().getResourceAsStream("it-todomodel.json"))) {
// TODO: implement and use remote todo model access String port = System.getProperty("todo.port");
this.controller.setTodoModelAccess(new DirectTodoModelAccess(todoPersistence.readTodoModel(reader))); assertNotNull(port, "No todo.port system property set");
URI baseUri = new URI("http://localhost:" + port + "/todo/");
System.out.println("Base RemoteTodoModelAcces URI: " + baseUri);
this.controller.setTodoModelAccess(new RemoteTodoModelAccess(baseUri));
} catch (IOException ioe) { } catch (IOException ioe) {
fail(ioe.getMessage()); fail(ioe.getMessage());
} }
......
...@@ -45,7 +45,7 @@ public class TodoListResource { ...@@ -45,7 +45,7 @@ public class TodoListResource {
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public TodoList getTodoList() { public TodoList getTodoList() {
checkTodoList(); checkTodoList();
LOG.debug("getTodoList(%s)", name); LOG.debug("getTodoList({})", name);
return this.todoList; return this.todoList;
} }
...@@ -59,7 +59,7 @@ public class TodoListResource { ...@@ -59,7 +59,7 @@ public class TodoListResource {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public boolean putTodoList(TodoList todoListArg) { public boolean putTodoList(TodoList todoListArg) {
LOG.debug("putTodoList(%s)", todoListArg); LOG.debug("putTodoList({})", todoListArg);
return this.todoModel.putTodoList(todoListArg) == null; return this.todoModel.putTodoList(todoListArg) == null;
} }
......
...@@ -7,8 +7,6 @@ import java.nio.charset.StandardCharsets; ...@@ -7,8 +7,6 @@ import java.nio.charset.StandardCharsets;
import org.glassfish.hk2.utilities.binding.AbstractBinder; import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.jackson.JacksonFeature; import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import todolist.core.TodoList; import todolist.core.TodoList;
import todolist.core.TodoModel; import todolist.core.TodoModel;
import todolist.json.TodoPersistence; import todolist.json.TodoPersistence;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment