Skip to content
Snippets Groups Projects
Commit 985629ac authored by Thiemo Belmega's avatar Thiemo Belmega
Browse files

Get resources by stream instead of path

parent 967946c5
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,11 @@
<name>toolup Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.37</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
......
package de.unipotsdam.cs.toolup.database;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
......@@ -11,16 +9,16 @@ import java.util.Properties;
public class SqlStatementFactory {
public static final String SQL_STATEMENTS_FILENAME = "/SQL_Statements.xml";
private static final String TOKEN_TABLE_NAME = "TABLE_NAME";
private static final File SQL_STATEMENT_FILE = new File("SQL_Statements.xml").getAbsoluteFile();
private static final CharSequence TOKEN_FOREIGN_KEY = "FOREIGN_KEY";
private static final String TOKEN_FOREIGN_KEY = "FOREIGN_KEY";
private final Connection connection;
private Properties sqlStatements;
public SqlStatementFactory() throws IOException, SQLException {
sqlStatements = new Properties();
sqlStatements.loadFromXML(new FileInputStream(SQL_STATEMENT_FILE));
sqlStatements.loadFromXML(this.getClass().getResourceAsStream(SQL_STATEMENTS_FILENAME));
connection = DriverManager.getConnection(ToolUpProperties.getDatabaseUrl());
}
......
package de.unipotsdam.cs.toolup.database;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
......@@ -14,7 +12,6 @@ public class ToolUpProperties {
private static final String KEY_SCHEMA = "database schema";
private static final String DATABASE_CONNECTOR = "jdbc:mysql://";
static File PROPERTIES_FILE = new File("Tool.UP_cfg.xml");
private static String DATABASE_URL = null;
private static Properties PROPERTIES = null;
......@@ -53,7 +50,7 @@ public class ToolUpProperties {
private static synchronized void loadPropertiesFromFile() throws IOException {
if (PROPERTIES == null) {
PROPERTIES = new Properties();
PROPERTIES.loadFromXML(new FileInputStream(PROPERTIES_FILE));
PROPERTIES.loadFromXML(ToolUpProperties.class.getResourceAsStream("/Tool.UP_cfg.xml"));
}
}
......
......@@ -20,9 +20,12 @@ public class BusinessObjectTest {
public static final String APPLICATION_TEST_ID_1 = "application/test_id_1";
public static final String APPLICATION_TEST_ID_2 = "application/test_id_2";
public static final String CATEGORY_TEST_ID_11 = "category/test_id_11";
private static final String FILENAME_TEST_APP_JSON = "test/resources/TestApplication.json";
private static final String FILENAME_TEST_FEAT_JSON = "test/resources/TestFeature.json";
private static final String FILENAME_TEST_CAT_JSON = "test/resources/TestCategory.json";
public static final String PROVIDE_SAMPLE_IDS = "provideSampleIds";
public static final String PROVIDE_BOS_TO_COMPARE = "provideBOsToCompare";
public static final String PROVIDE_BUSINESS_OBJECTS = "provideBusinessObjects";
private static final String FILENAME_TEST_APP_JSON = "src/test/java/resources/TestApplication.json";
private static final String FILENAME_TEST_FEAT_JSON = "src/test/java/resources/TestFeature.json";
private static final String FILENAME_TEST_CAT_JSON = "src/test/java/resources/TestCategory.json";
private static final String APPLICATION_TESTDESCRIPTION_1 = "Dropbox Description";
private static final String APPLICATION_TESTTITLE_1 = "Dropbox";
private static final String FEATURE_TESTTITLE_21 = "Kalender anlegen";
......@@ -32,9 +35,6 @@ public class BusinessObjectTest {
private static final String TABLENAME_CATEGORY = "category";
private static final String TABLENAME_FEATURE = "feature";
private static final String TABLENAME_APPLICATION = "application";
private static final String PROVIDE_SAMPLE_IDS = "provideSampleIds";
private static final String PROVIDE_BOS_TO_COMPARE = "provideBOsToCompare";
private static final String PROVIDE_BUSINESS_OBJECTS = "provideBusinessObjects";
@Test(dataProvider = PROVIDE_SAMPLE_IDS)
public void testThatTablenameIsExtractableFromId(String expectedTableName, String id) throws InvalidIdException {
......@@ -190,7 +190,7 @@ public class BusinessObjectTest {
return new Object[][]{
{app1, expectedJsonApp},
{feat1, expectedJsonFeat},
{cat1, expectedJsonCat},
{cat1, expectedJsonCat}
};
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment