aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorefiacor <fiachra.corcoran@est.tech>2019-11-04 11:25:55 +0000
committerFiachra Corcoran <fiachra.corcoran@est.tech>2019-11-04 11:30:28 +0000
commit6ac1c84f0aeec17dba6c55c7097a264b1a7b6ba2 (patch)
tree0bc67a66f9daf5a7248740f2a72ee960f480c394
parent4c5b91b5ce0901bf3044709fb2a172c2ae7763fc (diff)
Fixing failing unit tests
Signed-off-by: efiacor <fiachra.corcoran@est.tech> Change-Id: Idacec3a21157e4b8c1f807fd045de47b497e6f6c Issue-ID: DMAAP-1284
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecordTest.java20
1 files changed, 10 insertions, 10 deletions
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecordTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecordTest.java
index 24400f63..189db839 100644
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecordTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/LogRecordTest.java
@@ -42,14 +42,15 @@ public class LogRecordTest {
private static EntityManagerFactory emf;
private static EntityManager em;
+ private static ProvDbUtils provDbUtils;
@BeforeClass
public static void init() {
emf = Persistence.createEntityManagerFactory("dr-unit-tests");
em = emf.createEntityManager();
System.setProperty(
- "org.onap.dmaap.datarouter.provserver.properties",
- "src/test/resources/h2Database.properties");
+ "org.onap.dmaap.datarouter.provserver.properties",
+ "src/test/resources/h2Database.properties");
}
@AfterClass
@@ -61,7 +62,7 @@ public class LogRecordTest {
@Before
public void setUp() throws ParseException, SQLException {
-
+ provDbUtils = ProvDbUtils.getInstance();
}
@Test
@@ -95,19 +96,18 @@ public class LogRecordTest {
System.setOut(new PrintStream(outContent));
String[] rlebitset = {"0-1,2-2"};
LogRecord.printLogRecords(System.out, new RLEBitSet(rlebitset[0]));
- Assert.assertEquals(outContent.toString().substring(25), "LOG|ID|1|URL/file123|PUT|application/vnd.dmaap-dr.log-list; version=1.0|100|pub|1|172.0.0.8|user|204|1|1|204|0|other|1|0\n");
+ Assert.assertEquals("LOG|ID|1|URL/file123|PUT|application/vnd.dmaap-dr.log-list; version=1.0|100|pub|1|172.0.0.8|user|204|1|1|204|0|other|1|0\n", outContent.toString().substring(25));
}
private void setArgsLoadAndAssertEquals(String type, String s) throws ParseException, SQLException {
String[] args = {"2018-08-29-10-10-10-543.", "LOG", "ID", "1", "URL/file123", "PUT", "application/vnd.dmaap-.log-list; version=1.0", "100", type, "1", "172.0.0.8", "user", "204", "1", "1", "204", "0", "other", "1", "100", "file123"};
LogRecord logRecord = new LogRecord(args);
- try (Connection conn = ProvDbUtils.getInstance().getConnection()) {
- PreparedStatement ps = conn.prepareStatement(
- "insert into LOG_RECORDS values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ String compare_string;
+ try (Connection conn = provDbUtils.getConnection(); PreparedStatement ps = conn.prepareStatement(
+ "insert into LOG_RECORDS values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
logRecord.load(ps);
- String compare_string = ps.toString().substring(ps.toString().indexOf("{1:"), ps.toString().indexOf("2:")) + ps
- .toString().substring(ps.toString().indexOf("3:"));
- Assert.assertEquals(compare_string, s);
+ compare_string = ps.toString().substring(ps.toString().indexOf("{1:"), ps.toString().indexOf(", 2:")) + ps.toString().substring(ps.toString().indexOf(", 3:"));
}
+ Assert.assertEquals(s, compare_string);
}
}