fixed test cases

This commit is contained in:
Jeremy Long
2017-05-05 15:17:39 -04:00
parent 55bfe4cad8
commit 5681e0bfdf
4 changed files with 19 additions and 5 deletions

View File

@@ -230,6 +230,16 @@ public final class CveDB implements AutoCloseable {
} }
} }
/**
* Method added for testing, returns the current usage count of the CveDB
* singleton.
*
* @return the current usage of the CveDB singleton
*/
protected synchronized int getUsageCount() {
return usageCount;
}
/** /**
* Opens the database connection. If the database does not exist, it will * Opens the database connection. If the database does not exist, it will
* create a new one. * create a new one.

View File

@@ -68,8 +68,10 @@ public class CveDBIT extends BaseDBTestCase {
} catch (DatabaseException | SQLException ex) { } catch (DatabaseException | SQLException ex) {
fail(ex.getMessage()); fail(ex.getMessage());
} finally { } finally {
int start = instance.getUsageCount();
instance.close(); instance.close();
assertFalse(instance.isOpen()); int end = instance.getUsageCount();
assertTrue( end < start);
} }
} }

View File

@@ -49,8 +49,10 @@ public class CveDBMySqlIT extends BaseTest {
System.out.println("Unable to connect to the My SQL database; verify that the db server is running and that the schema has been generated"); System.out.println("Unable to connect to the My SQL database; verify that the db server is running and that the schema has been generated");
fail(ex.getMessage()); fail(ex.getMessage());
} finally { } finally {
int start = instance.getUsageCount();
instance.close(); instance.close();
assertFalse(instance.isOpen()); int end = instance.getUsageCount();
assertTrue( end < start);
} }
} }

View File

@@ -320,9 +320,6 @@ Copyright (c) 2012 - Jeremy Long
<value>${project.build.directory}/temp</value> <value>${project.build.directory}/temp</value>
</property> </property>
</systemProperties> </systemProperties>
<excludes>
<exclude>**/*MySqlIT.java</exclude>
</excludes>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
@@ -336,6 +333,9 @@ Copyright (c) 2012 - Jeremy Long
<value>${project.build.directory}/temp</value> <value>${project.build.directory}/temp</value>
</property> </property>
</systemProperties> </systemProperties>
<excludes>
<exclude>**/*MySqlIT.java</exclude>
</excludes>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>