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;
import javafx.fxml.FXML;
import javafx.scene.control.ComboBox;
import todolist.core.TodoList;
import todolist.json.TodoPersistence;
public class TodoModelController {
......
......@@ -80,15 +80,24 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<!-- Reservere porter og tilordne dem til variabler -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M1</version>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<portNames>
<portName>jetty.port</portName>
<portName>jetty.port.stop</portName>
</portNames>
</configuration>
<executions>
<execution>
<id>reserve-port</id>
<phase>pre-integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
<goal>reserve-network-port</goal>
</goals>
</execution>
</executions>
......@@ -99,10 +108,10 @@
<version>9.4.31.v20200723</version>
<configuration>
<httpConnector>
<port>8999</port>
<port>${jetty.port}</port>
</httpConnector>
<stopKey>quit</stopKey>
<stopPort>9000</stopPort>
<stopPort>${jetty.port.stop}</stopPort>
</configuration>
<executions>
<execution>
......@@ -121,6 +130,25 @@
</execution>
</executions>
</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>
</build>
</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;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URI;
import java.net.URISyntaxException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.testfx.framework.junit5.ApplicationTest;
......@@ -27,14 +29,15 @@ public class TodoAppIT extends ApplicationTest {
stage.show();
}
private TodoPersistence todoPersistence = new TodoPersistence();
@BeforeEach
public void setupItems() {
public void setupItems() throws URISyntaxException {
// same as in test-todolist.json (should perhaps read it instead)
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream("it-todomodel.json"))) {
// TODO: implement and use remote todo model access
this.controller.setTodoModelAccess(new DirectTodoModelAccess(todoPersistence.readTodoModel(reader)));
String port = System.getProperty("todo.port");
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) {
fail(ioe.getMessage());
}
......
......@@ -45,7 +45,7 @@ public class TodoListResource {
@Produces(MediaType.APPLICATION_JSON)
public TodoList getTodoList() {
checkTodoList();
LOG.debug("getTodoList(%s)", name);
LOG.debug("getTodoList({})", name);
return this.todoList;
}
......@@ -59,7 +59,7 @@ public class TodoListResource {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public boolean putTodoList(TodoList todoListArg) {
LOG.debug("putTodoList(%s)", todoListArg);
LOG.debug("putTodoList({})", todoListArg);
return this.todoModel.putTodoList(todoListArg) == null;
}
......
......@@ -7,8 +7,6 @@ import java.nio.charset.StandardCharsets;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import todolist.core.TodoList;
import todolist.core.TodoModel;
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