aboutsummaryrefslogtreecommitdiff
path: root/DocumentService/src/eu/stork/documentservice/tests/DatabaseTests.java
diff options
context:
space:
mode:
Diffstat (limited to 'DocumentService/src/eu/stork/documentservice/tests/DatabaseTests.java')
-rw-r--r--DocumentService/src/eu/stork/documentservice/tests/DatabaseTests.java265
1 files changed, 0 insertions, 265 deletions
diff --git a/DocumentService/src/eu/stork/documentservice/tests/DatabaseTests.java b/DocumentService/src/eu/stork/documentservice/tests/DatabaseTests.java
deleted file mode 100644
index a888f0737..000000000
--- a/DocumentService/src/eu/stork/documentservice/tests/DatabaseTests.java
+++ /dev/null
@@ -1,265 +0,0 @@
-package eu.stork.documentservice.tests;
-
-import static org.junit.Assert.*;
-
-import java.util.Date;
-import java.util.UUID;
-
-import org.junit.Test;
-
-import eu.stork.documentservice.data.DatabaseConnector;
-import eu.stork.documentservice.data.DatabaseConnectorMySQLImpl;
-import eu.stork.documentservice.exceptions.DatabaseException;
-import eu.stork.documentservice.model.DocumentModel;
-import eu.stork.documentservice.model.RequestModel;
-import eu.stork.documentservice.model.TempDocumentModel;
-import eu.stork.documentservice.utils.Utils;
-
-public class DatabaseTests {
-
- private String user = "stork";
- private String password = "stork";
- private String database = "stork";
- private String server = "localhost:3306";
- private String pdfLoc = "C:/Temp/temp.pdf";
- private String destCountry = "AT";
- private String spCountry = "IS";
- private String spId = "Demo-SP";
- private String xmlrequest = "<xml><data>foo</data>";
- private String xmlresponse = "<xml><data>foo_signed</data>";
- private static String docId = "";
- private static String docId2 = "";
- private static String reqId = "";
-
- public DatabaseTests()
- {
- if (docId.isEmpty())
- docId = UUID.randomUUID().toString();
- if (docId2.isEmpty())
- docId2 = UUID.randomUUID().toString();
- if (reqId.isEmpty())
- reqId = UUID.randomUUID().toString();
- }
-
- @Test
- //Test adding document
- public void test1() {
- DatabaseConnector conn = new DatabaseConnectorMySQLImpl(user, password, server, database);
- DocumentModel document = new DocumentModel();
- document.setDocid(docId);
- document.setDocument(Utils.readData(pdfLoc));
- document.setFilename("pdfdoc.pdf");
- document.setMimetype("application/pdf");
-
- try
- {
- boolean ok = conn.addDocument(document);
- assertTrue(ok);
- }
- catch (DatabaseException ex)
- {
- ex.printStackTrace();
- }
- }
-
- @Test
- //Test getting document
- public void test2()
- {
- DatabaseConnector conn = new DatabaseConnectorMySQLImpl(user, password, server, database);
- try
- {
- DocumentModel document = conn.getDocument(docId);
- assertNotNull(document);
- }
- catch (DatabaseException ex)
- {
- ex.printStackTrace();
- }
- }
-
- @Test
- //Test updating document
- public void test3()
- {
- DatabaseConnector conn = new DatabaseConnectorMySQLImpl(user, password, server, database);
- try
- {
- DocumentModel document = conn.getDocument(docId);
- boolean ok = conn.updateDocument(document);
- assertTrue(ok);
- }
- catch (DatabaseException ex)
- {
- ex.printStackTrace();
- }
- }
-
- @Test
- //Test deleting document
- public void test4()
- {
- DatabaseConnector conn = new DatabaseConnectorMySQLImpl(user, password, server, database);
- try
- {
- boolean ok = conn.deleteDocument(docId);
- assertTrue(ok);
- }
- catch (DatabaseException ex)
- {
- ex.printStackTrace();
- }
- }
-
- @Test
- //Test adding new request
- public void test5()
- {
- DatabaseConnector conn = new DatabaseConnectorMySQLImpl(user, password, server, database);
- RequestModel request = new RequestModel();
- request.setRequestid(reqId);
- request.setDestcountry(destCountry);
- request.setSpcountry(spCountry);
- request.setSpid(spId);
- request.setXmlrequest(xmlrequest);
-
- try
- {
- boolean ok = conn.addRequest(request);
- assertTrue(ok);
- }
- catch (DatabaseException ex)
- {
- ex.printStackTrace();
- }
- }
-
- @Test
- //Test getting request
- public void test6()
- {
- DatabaseConnector conn = new DatabaseConnectorMySQLImpl(user, password, server, database);
-
- try
- {
- RequestModel request = conn.getRequest(reqId);
- assertNotNull(request);
- }
- catch (DatabaseException ex)
- {
- ex.printStackTrace();
- }
- }
-
- @Test
- //Test updating request
- public void test7()
- {
- DatabaseConnector conn = new DatabaseConnectorMySQLImpl(user, password, server, database);
-
- try
- {
- RequestModel request = conn.getRequest(reqId);
- request.setDocid(docId);
- boolean ok = conn.updateRequest(request);
- assertTrue(ok);
- }
- catch (DatabaseException ex)
- {
- ex.printStackTrace();
- }
- }
-
- @Test
- //Test getting new request
- public void test8()
- {
- DatabaseConnector conn = new DatabaseConnectorMySQLImpl(user, password, server, database);
-
- try
- {
- RequestModel request = conn.getRequest(reqId);
- request.setXmlresponse(xmlresponse);
- request.setRestimestamp(new Date());
- boolean ok = conn.updateRequest(request);
- assertTrue(ok);
- }
- catch (DatabaseException ex)
- {
- ex.printStackTrace();
- }
- }
-
-
- @Test
- //Test add temp document
- public void test10()
- {
- DatabaseConnector conn = new DatabaseConnectorMySQLImpl(user, password, server, database);
- TempDocumentModel document = new TempDocumentModel();
- document.setDocid(docId2);
- document.setDocument(Utils.readData(pdfLoc));
- document.setSpid(spId);
- //document.setFilename("pdfdoc.pdf");
- document.setMimetype("application/pdf");
-
- try
- {
- boolean ok = conn.addTempDocument(document);
- assertTrue(ok);
- }
- catch (DatabaseException ex)
- {
- ex.printStackTrace();
- }
- }
-
- @Test
- //Test getting temp document
- public void test11()
- {
- DatabaseConnector conn = new DatabaseConnectorMySQLImpl(user, password, server, database);
- try
- {
- TempDocumentModel document = conn.getTempDocument(docId2);
- assertNotNull(document);
- }
- catch (DatabaseException ex)
- {
- ex.printStackTrace();
- }
- }
-
- @Test
- //Test updating temp document
- public void test12()
- {
- DatabaseConnector conn = new DatabaseConnectorMySQLImpl(user, password, server, database);
- try
- {
- TempDocumentModel document = conn.getTempDocument(docId2);
- boolean ok = conn.updateTempDocument(document);
- assertTrue(ok);
- }
- catch (DatabaseException ex)
- {
- ex.printStackTrace();
- }
- }
-
- @Test
- //Test delete temp document
- public void test13()
- {
- DatabaseConnector conn = new DatabaseConnectorMySQLImpl(user, password, server, database);
- try
- {
- boolean ok = conn.deleteTempDocument(docId2);
- assertTrue(ok);
- }
- catch (DatabaseException ex)
- {
- ex.printStackTrace();
- }
- }
-}