Skip to content

Commit

Permalink
Implemented testGetSQLConnection JUnit 5 testing
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelAl committed Jul 4, 2020
1 parent 8a94db5 commit 1a96264
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 235 deletions.
2 changes: 2 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin" path="src"/>
<classpathentry kind="src" path="tests"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
Expand All @@ -11,5 +12,6 @@
<classpathentry kind="lib" path="lib/sqlite-jdbc-3.30.1.jar"/>
<classpathentry kind="lib" path="lib/postgresql-42.2.14.jar"/>
<classpathentry kind="lib" path="lib/sqlbuilder-3.0.0.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="output" path="resources/code"/>
</classpath>
1 change: 1 addition & 0 deletions resources/code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/samuelal/
Binary file removed resources/code/ExampleTaglet.class
Binary file not shown.
231 changes: 0 additions & 231 deletions resources/code/ExampleTaglet.java

This file was deleted.

2 changes: 2 additions & 0 deletions src/samuelal/squelized/QueryBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ private static void loadSQLBuilderSchema() {

public static String createTable(String tableName, String[] columnNames, int[] columnTypes, Integer[] columnLength) {

loadSQLBuilderSchema();

// Specify table name
DbTable newTable = dbSchema.addTable(tableName);

Expand Down
27 changes: 23 additions & 4 deletions src/samuelal/squelized/SQLConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ protected void welcome() {
* runs SQL query through connection
* and returns Table object with results
*
* @param String
* @return Table
* @param String query
* @return Table results
*/
public Table runQuery(String query)
{
Expand Down Expand Up @@ -145,16 +145,35 @@ public Table runQuery(String query)
return queryResult;
}


/**
* gets all the data of a table and
* generates a Processing Table with it
*
* @param String tableName
* @return Table results
*/
public Table getTable(String tableName) {
return runQuery(QueryBuilder.displayAllTableRecords(tableName));
}

/**
* gets all the data in a specific table column
* and generates Processing Table
*
* @param tableName
* @param columnName
* @return Table results
*/
public Table getColumn(String tableName, String columnName) {
return getColumns(tableName, new String[] {columnName});
}


/**
*
* @param String tableName
* @param String[] columnNames
* @return Table results
*/
public Table getColumns(String tableName, String[] columnNames) {
return runQuery(QueryBuilder.displayRecords(tableName, columnNames));
}
Expand Down
48 changes: 48 additions & 0 deletions tests/samuelal/squelized/SQLConnectionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package samuelal.squelized;

import static org.junit.jupiter.api.Assertions.*;

import java.util.Properties;

import org.junit.jupiter.api.Test;

class SQLConnectionTest {

@Test
void testGetSQLConnection() {
Properties mySqlProps = new Properties();
mySqlProps.setProperty("user", "root");
mySqlProps.setProperty("password", "1234");
mySqlProps.setProperty("useUnicode", "true");
mySqlProps.setProperty("useJDBCCompliantTimezoneShift", "true");
mySqlProps.setProperty("useLegacyDatetimecode", "true");
mySqlProps.setProperty("serverTimezone", "UTC");
SQLConnection mysql = new MySQLConnection("jdbc:mysql://localhost:3306/squelized_test", mySqlProps);
}

@Test
void testGetDatabaseType() {
fail("Not yet implemented"); // TODO
}

@Test
void testRunQuery() {
fail("Not yet implemented"); // TODO
}

@Test
void testGetTable() {
fail("Not yet implemented"); // TODO
}

@Test
void testGetColumn() {
fail("Not yet implemented"); // TODO
}

@Test
void testGetColumns() {
fail("Not yet implemented"); // TODO
}

}

0 comments on commit 1a96264

Please sign in to comment.