diff --git a/java/org/jlab/coda/jevio/test/HipoTest.java b/java/org/jlab/coda/jevio/test/HipoTest.java index c229968f..f9e15817 100644 --- a/java/org/jlab/coda/jevio/test/HipoTest.java +++ b/java/org/jlab/coda/jevio/test/HipoTest.java @@ -137,12 +137,12 @@ void testTreeEventCreation(int tag, int num) throws IOException { EvioNode node = EvioNode.extractEventNode(evioDataBuf, null, 0, 0, 0); - System.out.println("Event:\n" + event.treeToString("")); + System.out.println("\n\nEvent (created by tree methods):\n" + event.treeToString("")); System.out.println("Event Header:\n" + event.getHeader().toString()); // Take event & write it into buffer - System.out.println("Write event to " + writeFileName1 + " as compressed LZ4"); - EventWriter writer = new EventWriter(writeFileName1, null, "runType", 1, 0L, 0, 0, + System.out.println("Write event to " + writeFileName2 + " as compressed LZ4"); + EventWriter writer = new EventWriter(writeFileName2, null, "runType", 1, 0L, 0, 0, ByteOrder.nativeOrder(), dictionary, true, false, null, 1, 1, 1, 1, CompressionType.RECORD_COMPRESSION_LZ4, 2, 16, 0); @@ -152,28 +152,32 @@ void testTreeEventCreation(int tag, int num) throws IOException { // Test double sync writer.writeEvent(node, false, false); - System.out.println(" createObjectEvents: call writer.close()"); + System.out.println(" call writer.close()"); writer.close(); // Read event back out of file - System.out.println(" createObjectEvents:create EvioReader"); - EvioReader reader = new EvioReader(writeFileName1); + System.out.println(" create EvioReader"); + EvioReader reader = new EvioReader(writeFileName2); - System.out.println(" createObjectEvents: have dictionary? " + reader.hasDictionaryXML()); - String xmlDict = reader.getDictionaryXML(); - System.out.println(" createObjectEvents: read dictionary ->\n\n" + xmlDict); + System.out.println(" have dictionary? " + reader.hasDictionaryXML()); + if (reader.hasDictionaryXML()) { + String xmlDict = reader.getDictionaryXML(); + System.out.println(" read dictionary ->\n\n" + xmlDict); + } - System.out.println("\n createObjectEvents: have first event? " + reader.hasFirstEvent()); - EvioEvent fe = reader.getFirstEvent(); - System.out.println(" createObjectEvents: read first event ->\n\n" + fe.treeToString("")); + System.out.println("\n have first event? " + reader.hasFirstEvent()); + if (reader.hasFirstEvent()) { + EvioEvent fe = reader.getFirstEvent(); + System.out.println(" read first event ->\n\n" + fe.treeToString("")); + } - System.out.println("\n createObjectEvents: try getting ev #1"); + System.out.println("\n try getting ev #1"); EvioEvent ev = reader.parseEvent(1); - System.out.println(" createObjectEvents: event ->\n" + ev.treeToString("")); + System.out.println(" event ->\n" + ev.treeToString("")); - System.out.println("\n createObjectEvents: try getting ev #2"); + System.out.println("\n try getting ev #2"); ev = reader.parseEvent(2); - System.out.println(" createObjectEvents: event ->\n" + ev.treeToString("")); + System.out.println(" event ->\n" + ev.treeToString("")); } catch (EvioException e) { e.printStackTrace(); @@ -186,7 +190,7 @@ public static void main(String args[]) { try { HipoTest tester = new HipoTest(); tester.testCompactEventCreation(1,1); - //tester.testTreeEventCreation(1,1); + tester.testTreeEventCreation(1,1); } catch (Exception e) { e.printStackTrace(); diff --git a/src/test/Hipo_Test.cpp b/src/test/Hipo_Test.cpp index 7157535a..daabff27 100644 --- a/src/test/Hipo_Test.cpp +++ b/src/test/Hipo_Test.cpp @@ -141,34 +141,39 @@ namespace evio { // Build event (bank of banks) with EventBuilder object std::shared_ptr event = createTreeEvent(tag, num); - std::cout << "Event:\n" << event->treeToString("") << std::endl; + std::cout << "\n\nEvent (created by tree methods):\n" << event->treeToString("") << std::endl; std::cout << "Event Header:\n" << event->getHeader()->toString() << std::endl; // Take event & write it into buffer - std::cout << "Write event to " << writeFileName1 << " as compressed LZ4" << std::endl; - EventWriter writer(writeFileName1, "", "runType", 1, 0L, 0, 0, + std::cout << "Write event to " << writeFileName2 << " as compressed LZ4" << std::endl; + EventWriter writer(writeFileName2, "", "runType", 1, 0L, 0, 0, ByteOrder::ENDIAN_LOCAL, dictionary, true, false, nullptr, 1, 1, 1, 1, Compressor::LZ4, 2, 16, 0); writer.setFirstEvent(event); writer.writeEvent(event); - std::cout << " createObjectEvents: call writer.close()" << std::endl; + std::cout << " call writer.close()" << std::endl; writer.close(); // Read event back out of file - EvioReader reader(writeFileName1); + std::cout << " create EvioReader" << std::endl; + EvioReader reader(writeFileName2); - std::cout << " createObjectEvents: have dictionary? " << reader.hasDictionaryXML() << std::endl; - std::string xmlDict = reader.getDictionaryXML(); - std::cout << " createObjectEvents: read dictionary ->\n\n" << xmlDict << std::endl << std::endl; + std::cout << " have dictionary? " << reader.hasDictionaryXML() << std::endl; + if (reader.hasDictionaryXML()) { + std::string xmlDict = reader.getDictionaryXML(); + std::cout << " read dictionary ->\n\n" << xmlDict << std::endl << std::endl; + } - std::cout << " createObjectEvents: have first event? " << reader.hasFirstEvent() << std::endl; - auto fe = reader.getFirstEvent(); - std::cout << " createObjectEvents: read first event ->\n\n" << fe->treeToString("") << std::endl << std::endl; + std::cout << " have first event? " << reader.hasFirstEvent() << std::endl; + if (reader.hasFirstEvent()) { + auto fe = reader.getFirstEvent(); + std::cout << " read first event ->\n\n" << fe->treeToString("") << std::endl << std::endl; + } - std::cout << " createObjectEvents: try getting ev #1" << std::endl; + std::cout << " try getting ev #1" << std::endl; auto ev = reader.parseEvent(1); - std::cout << " createObjectEvents: event ->\n" << ev->treeToString("") << std::endl; + std::cout << " event ->\n" << ev->treeToString("") << std::endl; } catch (EvioException &e) { std::cout << e.what() << std::endl; @@ -188,7 +193,7 @@ namespace evio { int main(int argc, char **argv) { auto tester = evio::HipoTester(); tester.testCompactEventCreation(1,1); - //tester.testTreeEventCreation(1,1); + tester.testTreeEventCreation(1,1); return 0; }