TSK-1828 remove resteasy-client dependency (#2068)
This commit is contained in:
parent
e01036fbd6
commit
cc1c29b9b3
|
@ -69,12 +69,6 @@
|
|||
<version>${version.thorntail}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-client</artifactId>
|
||||
<version>${version.resteasy}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
|
|
|
@ -47,9 +47,9 @@ public class TaskanaProducers {
|
|||
ctx = new InitialContext();
|
||||
properties.load(propertyStream);
|
||||
dataSource = (DataSource) ctx.lookup(properties.getProperty("datasource.jndi"));
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
DatabaseMetaData metaData = connection.getMetaData();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
try (Connection connection = dataSource.getConnection()) {
|
||||
DatabaseMetaData metaData = connection.getMetaData();
|
||||
LOGGER.debug("---------------> {}", metaData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ import pro.taskana.workbasket.api.models.Workbasket;
|
|||
public class TaskanaCdiTestRestController {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaCdiTestRestController.class);
|
||||
private static final String CDIDOMAIN = "CDIDOMAIN";
|
||||
private static final String CLASSIFICATION_TYPE = "T1";
|
||||
|
||||
@EJB private TaskanaEjb taskanaEjb;
|
||||
|
||||
|
@ -29,16 +31,17 @@ public class TaskanaCdiTestRestController {
|
|||
|
||||
@GET
|
||||
public Response startTask() throws Exception {
|
||||
Workbasket workbasket = taskanaEjb.getWorkbasketService().newWorkbasket("key", "cdiDomain");
|
||||
Workbasket workbasket = taskanaEjb.getWorkbasketService().newWorkbasket("KEY", CDIDOMAIN);
|
||||
workbasket.setName("wb");
|
||||
workbasket.setType(WorkbasketType.PERSONAL);
|
||||
taskanaEjb.getWorkbasketService().createWorkbasket(workbasket);
|
||||
workbasket = taskanaEjb.getWorkbasketService().createWorkbasket(workbasket);
|
||||
Classification classification =
|
||||
classificationService.newClassification("TEST", "cdiDomain", "t1");
|
||||
classificationService.newClassification("TEST", CDIDOMAIN, CLASSIFICATION_TYPE);
|
||||
taskanaEjb.getClassificationService().createClassification(classification);
|
||||
|
||||
Task task = taskanaEjb.getTaskService().newTask(workbasket.getKey());
|
||||
Task task = taskanaEjb.getTaskService().newTask(workbasket.getId());
|
||||
task.setClassificationKey(classification.getKey());
|
||||
task.setName("startTask");
|
||||
ObjectReferenceImpl objRef = new ObjectReferenceImpl();
|
||||
objRef.setCompany("aCompany");
|
||||
objRef.setSystem("aSystem");
|
||||
|
@ -55,7 +58,22 @@ public class TaskanaCdiTestRestController {
|
|||
|
||||
@POST
|
||||
public Response rollbackTask() throws Exception {
|
||||
taskanaEjb.triggerRollback();
|
||||
Workbasket workbasket =
|
||||
taskanaEjb.getWorkbasketService().newWorkbasket("KEY_ROLLBACK", CDIDOMAIN);
|
||||
workbasket.setName("wb_rollback");
|
||||
workbasket.setType(WorkbasketType.PERSONAL);
|
||||
workbasket = taskanaEjb.getWorkbasketService().createWorkbasket(workbasket);
|
||||
Classification classification =
|
||||
classificationService.newClassification("TEST_ROLLBACK", CDIDOMAIN, CLASSIFICATION_TYPE);
|
||||
taskanaEjb.getClassificationService().createClassification(classification);
|
||||
|
||||
try {
|
||||
taskanaEjb.triggerRollback(workbasket.getId(), classification.getKey());
|
||||
} catch (Exception e) {
|
||||
if (!"java.lang.RuntimeException: Expected Test Exception".equals(e.getMessage())) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return Response.status(204).build();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,17 +4,10 @@ import javax.ejb.Stateless;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import pro.taskana.classification.api.ClassificationService;
|
||||
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.task.api.TaskService;
|
||||
import pro.taskana.task.api.exceptions.AttachmentPersistenceException;
|
||||
import pro.taskana.task.api.exceptions.ObjectReferencePersistenceException;
|
||||
import pro.taskana.task.api.exceptions.TaskAlreadyExistException;
|
||||
import pro.taskana.task.api.models.Task;
|
||||
import pro.taskana.task.internal.models.ObjectReferenceImpl;
|
||||
import pro.taskana.workbasket.api.WorkbasketService;
|
||||
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
|
||||
|
||||
@Stateless
|
||||
public class TaskanaEjb {
|
||||
|
@ -37,11 +30,11 @@ public class TaskanaEjb {
|
|||
return workbasketService;
|
||||
}
|
||||
|
||||
public void triggerRollback()
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
|
||||
TaskAlreadyExistException, InvalidArgumentException, AttachmentPersistenceException,
|
||||
ObjectReferencePersistenceException {
|
||||
final Task task = taskService.newTask(null);
|
||||
public void triggerRollback(String workbasketId, String classificationKey) throws Exception {
|
||||
|
||||
final Task task = taskService.newTask(workbasketId);
|
||||
task.setClassificationKey(classificationKey);
|
||||
task.setName("triggerRollback");
|
||||
ObjectReferenceImpl objRef = new ObjectReferenceImpl();
|
||||
objRef.setCompany("aCompany");
|
||||
objRef.setSystem("aSystem");
|
||||
|
@ -52,6 +45,6 @@ public class TaskanaEjb {
|
|||
|
||||
taskService.createTask(task);
|
||||
System.out.println("---------------->" + task.getId());
|
||||
throw new RuntimeException();
|
||||
throw new RuntimeException("Expected Test Exception");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,25 @@
|
|||
package pro.taskana.common.internal;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import javax.ws.rs.client.Client;
|
||||
import javax.ws.rs.client.ClientBuilder;
|
||||
import java.time.Duration;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.Archive;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.wildfly.swarm.undertow.WARArchive;
|
||||
|
@ -18,59 +27,58 @@ import org.wildfly.swarm.undertow.WARArchive;
|
|||
@RunWith(Arquillian.class)
|
||||
public class TaskanaProducersTest {
|
||||
|
||||
private static final String REST_TEST_URL = "http://127.0.0.1:8090/rest/test";
|
||||
|
||||
private static final HttpClient HTTP_CLIENT =
|
||||
HttpClient.newBuilder()
|
||||
.version(HttpClient.Version.HTTP_1_1)
|
||||
.connectTimeout(Duration.ofSeconds(10))
|
||||
.build();
|
||||
|
||||
@Deployment(testable = false)
|
||||
public static Archive<?> createDeployment() throws Exception {
|
||||
WARArchive deployment = ShrinkWrap.create(WARArchive.class);
|
||||
deployment.addPackage("pro.taskana");
|
||||
deployment.addClass(TaskanaProducers.class);
|
||||
deployment.addAllDependencies();
|
||||
deployment.addDependency("org.mybatis:mybatis:3.4.2");
|
||||
deployment.addDependency("org.mybatis:mybatis-cdi:1.0.0");
|
||||
deployment.addDependency("pro.taskana:taskana-core");
|
||||
deployment.addAsResource("META-INF/beans.xml");
|
||||
deployment.addAsResource("taskana.properties");
|
||||
deployment.addAsResource("project-defaults.yml");
|
||||
return deployment;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommit() throws Exception {
|
||||
|
||||
Client client = ClientBuilder.newClient();
|
||||
client.target("http://127.0.0.1:8090/rest/test").request().get();
|
||||
|
||||
Class.forName("org.h2.Driver");
|
||||
int resultCount = 0;
|
||||
try (Connection conn = getConnection()) {
|
||||
try (Statement statement = conn.createStatement()) {
|
||||
ResultSet rs = statement.executeQuery("SELECT ID, OWNER FROM TASKANA.TASK");
|
||||
|
||||
while (rs.next()) {
|
||||
resultCount++;
|
||||
}
|
||||
}
|
||||
Assert.assertEquals(0, resultCount);
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws IOException {
|
||||
// Delete Taskana folder if exists
|
||||
Path taskanaH2Data = Path.of(System.getProperty("user.home"), "taskana-h2-data");
|
||||
if (Files.exists(taskanaH2Data)) {
|
||||
FileUtils.deleteDirectory(taskanaH2Data.toFile());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommit() throws Exception {
|
||||
HttpRequest getRequest = HttpRequest.newBuilder(new URI(REST_TEST_URL)).GET().build();
|
||||
|
||||
HttpResponse<String> response =
|
||||
HTTP_CLIENT.send(getRequest, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
assertThat(response.statusCode()).isEqualTo(200);
|
||||
assertThat(countTasksByName("startTask")).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRollback() throws Exception {
|
||||
Client client = ClientBuilder.newClient();
|
||||
client.target("http://127.0.0.1:8090/rest/test").request().post(null);
|
||||
HttpRequest postRequest =
|
||||
HttpRequest.newBuilder(new URI(REST_TEST_URL))
|
||||
.POST(HttpRequest.BodyPublishers.ofString("null"))
|
||||
.build();
|
||||
|
||||
Class.forName("org.h2.Driver");
|
||||
int resultCount = 0;
|
||||
try (Connection conn = getConnection()) {
|
||||
try (Statement statement = conn.createStatement()) {
|
||||
ResultSet rs = statement.executeQuery("SELECT ID, OWNER FROM TASKANA.TASK");
|
||||
HttpResponse<String> response =
|
||||
HTTP_CLIENT.send(postRequest, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
while (rs.next()) {
|
||||
resultCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals(0, resultCount);
|
||||
assertThat(response.statusCode()).isEqualTo(204);
|
||||
assertThat(countTasksByName("triggerRollback")).isZero();
|
||||
}
|
||||
|
||||
private Connection getConnection() throws Exception {
|
||||
|
@ -80,4 +88,22 @@ public class TaskanaProducersTest {
|
|||
"SA",
|
||||
"SA");
|
||||
}
|
||||
|
||||
private int countTasksByName(String taskName) throws Exception {
|
||||
|
||||
Class.forName("org.h2.Driver");
|
||||
int resultCount = 0;
|
||||
try (Connection conn = getConnection()) {
|
||||
try (PreparedStatement statement =
|
||||
conn.prepareStatement("SELECT COUNT(ID) FROM TASKANA.TASK WHERE NAME = ?")) {
|
||||
statement.setString(1, taskName);
|
||||
ResultSet rs = statement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
resultCount = rs.getInt(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultCount;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
datasource.jndi=java:jboss/datasources/TestDS
|
||||
taskana.domains=CDIDOMAIN
|
||||
taskana.classification.types=T1
|
||||
|
|
1
pom.xml
1
pom.xml
|
@ -75,7 +75,6 @@
|
|||
<version.camunda.dmn>7.18.0</version.camunda.dmn>
|
||||
|
||||
<!-- java ee dependencies -->
|
||||
<version.resteasy>5.0.1.Final</version.resteasy>
|
||||
<version.thorntail>2.7.0.Final</version.thorntail>
|
||||
<version.javaee-api>8.0.1</version.javaee-api>
|
||||
<version.javax.servlet>4.0.1</version.javax.servlet>
|
||||
|
|
|
@ -101,11 +101,6 @@
|
|||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-client</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
|
|
Loading…
Reference in New Issue