use of nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester in project yauaa by nielsbasjes.
the class TestPerformance method validateAllPredefinedBrowsersPerformance.
@Disabled
@Test
void validateAllPredefinedBrowsersPerformance() {
// NOSONAR: Do not complain about ignored performance test
UserAgentAnalyzerTester uaa = UserAgentAnalyzerTester.newBuilder().showMatcherLoadStats().immediateInitialization().build();
assertTrue(uaa.runTests(false, false, null, true, true));
}
use of nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester in project yauaa by nielsbasjes.
the class AbstractSerializationTest method serializeAndDeserializeUAA.
private void serializeAndDeserializeUAA(boolean immediate, boolean runTestsBefore, boolean useTestRules) throws IOException, ClassNotFoundException {
LOG.info("==============================================================");
LOG.info("Create");
LOG.info("--------------------------------------------------------------");
UserAgentAnalyzerTesterBuilder uaab = UserAgentAnalyzerTester.newBuilder().keepTests().withCacheInstantiator(new TestingCacheInstantiator()).withCache(1234).hideMatcherLoadStats();
if (useTestRules) {
uaab.dropDefaultResources().addResources("classpath*:AllSteps.yaml").addResources("classpath*:AllFields-tests.yaml").addResources("classpath*:AllPossibleSteps.yaml").addResources("classpath*:IsNullLookup.yaml");
}
if (immediate) {
uaab.immediateInitialization();
}
UserAgentAnalyzerTester uaaBefore = uaab.build();
String uaaBeforeString = uaaBefore.toString();
if (runTestsBefore) {
LOG.info("--------------------------------------------------------------");
assertTrue(uaaBefore.runTests(false, false, null, false, false), "Tests BEFORE serialization failed");
// Get rid of the data of the last tested useragent
uaaBefore.reset();
String uaaBeforeAfterTestsString = uaaBefore.toString();
assertEquals(uaaBeforeString, uaaBeforeAfterTestsString);
}
LOG.info("--------------------------------------------------------------");
LOG.info("Serialize");
long serializeStartNs = System.nanoTime();
byte[] bytes = serialize(uaaBefore);
long serializeStopNs = System.nanoTime();
LOG.info("Serialize took {} ns ({} ms)", serializeStopNs - serializeStartNs, (serializeStopNs - serializeStartNs) / 1_000_000);
LOG.info("The UserAgentAnalyzer was serialized into {} bytes", bytes.length);
LOG.info("--------------------------------------------------------------");
LOG.info("Deserialize");
long deserializeStartNs = System.nanoTime();
UserAgentAnalyzerTester uaaAfter = deserialize(bytes);
long deserializeStopNs = System.nanoTime();
LOG.info("Done");
LOG.info("Deserialize took {} ns ({} ms)", deserializeStopNs - deserializeStartNs, (deserializeStopNs - deserializeStartNs) / 1_000_000);
String uaaAfterString = uaaAfter.toString();
assertEquals(uaaBeforeString, uaaAfterString);
assertEquals(1234, uaaAfter.getCacheSize());
LOG.info("==============================================================");
LOG.info("Validating when getting all fields");
LOG.info("--------------------------------------------------------------");
assertTrue(uaaAfter.runTests(false, false, null, false, false), "Tests AFTER serialization failed");
LOG.info("==============================================================");
}
use of nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester in project yauaa by nielsbasjes.
the class TestJavaSerialization method deserialize.
UserAgentAnalyzerTester deserialize(byte[] bytes) throws IOException, ClassNotFoundException {
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
try (ObjectInput in = new ObjectInputStream(bis)) {
Object o = in.readObject();
assertTrue(o instanceof UserAgentAnalyzerTester);
return (UserAgentAnalyzerTester) o;
}
}
use of nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester in project yauaa by nielsbasjes.
the class TestYamlBasedExpressions method runSubstringTests.
@Test
void runSubstringTests() {
UserAgentAnalyzerTester uaa = createTester("SubString-tests.yaml");
assertTrue(uaa.runTests(false, false));
}
use of nl.basjes.parse.useragent.debug.UserAgentAnalyzerTester in project yauaa by nielsbasjes.
the class TestYamlBasedExpressions method runSubstringVersionTests.
@Test
void runSubstringVersionTests() {
UserAgentAnalyzerTester uaa = createTester("SubStringVersion-tests.yaml");
assertTrue(uaa.runTests(false, false));
}
Aggregations