/** * Tests setting a partial logger name (a hierarchy scope) */ private static void testUserLoggerSetHierarchy() { Properties props= new Properties(); ByteArrayOutputStream out1= new ByteArrayOutputStream(); ByteArrayOutputStream err1= new ByteArrayOutputStream(); PrintStream out2= new PrintStream(out1); PrintStream err2= new PrintStream(err1); props.put("log4testng.logger.java.lang", "DEBUG"); testInitialize(props, out2, err2); Logger strLogger= Logger.getLogger(String.class); strLogger.trace("trace should not appear"); Assert.assertEquals(out1.toString(), ""); Assert.assertEquals(err1.toString(), ""); strLogger.debug("debug should appear"); Assert.assertTrue(out1.toString().startsWith("[java.lang.String] [DEBUG] debug should appear")); Assert.assertEquals(err1.toString(), ""); }
/** * Test setting the root logger level */ private static void testRootLoggerSet() { Properties props= new Properties(); ByteArrayOutputStream out1= new ByteArrayOutputStream(); ByteArrayOutputStream err1= new ByteArrayOutputStream(); PrintStream out2= new PrintStream(out1); PrintStream err2= new PrintStream(err1); props.put("log4testng.rootLogger", "DEBUG"); testInitialize(props, out2, err2); Logger strLogger= Logger.getLogger(String.class); strLogger.trace("trace should appear"); Assert.assertEquals(out1.toString(), ""); Assert.assertEquals(err1.toString(), ""); strLogger.debug("debug should appear"); Assert.assertTrue(out1.toString().startsWith("[java.lang.String] [DEBUG] debug should appear")); Assert.assertEquals(err1.toString(), ""); }
/** * Test setting a user logger level */ private static void testUserLoggerSet() { Properties props= new Properties(); ByteArrayOutputStream out1= new ByteArrayOutputStream(); ByteArrayOutputStream err1= new ByteArrayOutputStream(); PrintStream out2= new PrintStream(out1); PrintStream err2= new PrintStream(err1); props.put("log4testng.logger.java.lang.String", "DEBUG"); testInitialize(props, out2, err2); Logger strLogger= Logger.getLogger(String.class); strLogger.trace("trace should not appear"); Assert.assertEquals(out1.toString(), ""); Assert.assertEquals(err1.toString(), ""); strLogger.debug("debug should appear"); int outLength= out1.toString().length(); Assert.assertTrue(out1.toString().startsWith("[java.lang.String] [DEBUG] debug should appear")); Assert.assertEquals(err1.toString(), ""); Logger classLogger= Logger.getLogger(Class.class); classLogger.debug("debug should not appear"); Assert.assertEquals(out1.toString().length(), outLength); Assert.assertEquals(err1.toString(), ""); classLogger.warn("warn should appear"); Assert.assertTrue(out1.toString().contains("[java.lang.Class] [WARN] warn should appear")); Assert.assertEquals(err1.toString(), ""); }
/** Tests setting a partial logger name (a hierarchy scope) */ private static void testUserLoggerSetHierarchy() { Properties props = new Properties(); ByteArrayOutputStream out1 = new ByteArrayOutputStream(); ByteArrayOutputStream err1 = new ByteArrayOutputStream(); PrintStream out2 = new PrintStream(out1); PrintStream err2 = new PrintStream(err1); props.put("log4testng.logger.java.lang", "DEBUG"); testInitialize(props, out2, err2); Logger strLogger = Logger.getLogger(String.class); strLogger.trace("trace should not appear"); Assert.assertEquals(out1.toString(), ""); Assert.assertEquals(err1.toString(), ""); strLogger.debug("debug should appear"); Assert.assertTrue(out1.toString().startsWith("[java.lang.String] [DEBUG] debug should appear")); Assert.assertEquals(err1.toString(), ""); }
/** Test setting the root logger level */ private static void testRootLoggerSet() { Properties props = new Properties(); ByteArrayOutputStream out1 = new ByteArrayOutputStream(); ByteArrayOutputStream err1 = new ByteArrayOutputStream(); PrintStream out2 = new PrintStream(out1); PrintStream err2 = new PrintStream(err1); props.put("log4testng.rootLogger", "DEBUG"); testInitialize(props, out2, err2); Logger strLogger = Logger.getLogger(String.class); strLogger.trace("trace should appear"); Assert.assertEquals(out1.toString(), ""); Assert.assertEquals(err1.toString(), ""); strLogger.debug("debug should appear"); Assert.assertTrue(out1.toString().startsWith("[java.lang.String] [DEBUG] debug should appear")); Assert.assertEquals(err1.toString(), ""); }
Assert.assertEquals(out1.toString(), ""); Assert.assertEquals(err1.toString(), ""); strLogger.debug("debug should not appear"); Assert.assertEquals(out1.toString(), ""); Assert.assertEquals(err1.toString(), "");
/** Test setting a user logger level */ private static void testUserLoggerSet() { Properties props = new Properties(); ByteArrayOutputStream out1 = new ByteArrayOutputStream(); ByteArrayOutputStream err1 = new ByteArrayOutputStream(); PrintStream out2 = new PrintStream(out1); PrintStream err2 = new PrintStream(err1); props.put("log4testng.logger.java.lang.String", "DEBUG"); testInitialize(props, out2, err2); Logger strLogger = Logger.getLogger(String.class); strLogger.trace("trace should not appear"); Assert.assertEquals(out1.toString(), ""); Assert.assertEquals(err1.toString(), ""); strLogger.debug("debug should appear"); int outLength = out1.toString().length(); Assert.assertTrue(out1.toString().startsWith("[java.lang.String] [DEBUG] debug should appear")); Assert.assertEquals(err1.toString(), ""); Logger classLogger = Logger.getLogger(Class.class); classLogger.debug("debug should not appear"); Assert.assertEquals(out1.toString().length(), outLength); Assert.assertEquals(err1.toString(), ""); classLogger.warn("warn should appear"); Assert.assertTrue(out1.toString().contains("[java.lang.Class] [WARN] warn should appear")); Assert.assertEquals(err1.toString(), ""); }
Assert.assertEquals(out1.toString(), ""); Assert.assertEquals(err1.toString(), ""); strLogger.debug("debug should not appear"); Assert.assertEquals(out1.toString(), ""); Assert.assertEquals(err1.toString(), "");
public static void executeWithTimeOut(Queue<String> failures, Callable<Long> task) { ExecutorService es = Executors.newSingleThreadExecutor( new ThreadFactoryBuilder().setDaemon(true).build()); Future<Long> future = es.submit(task); try { long timeNS = future.get(TIMEOUT, TimeUnit.SECONDS); logger.debug("\nExecuted in " + TimeUnit.NANOSECONDS.toSeconds(timeNS) + " second(s)"); } catch (ExecutionException e) { fail("Exception during test: " + e.toString(), e); } catch (TimeoutException e) { handleTimout(failures, es, e); } catch (InterruptedException e) { fail("", e); } }
public static void handleTimout(Queue<String> failures, ExecutorService es, TimeoutException e) { for (StackTraceElement[] trace : Thread.getAllStackTraces().values()) { for (StackTraceElement element : trace) { logger.info("\tat " + element); } if (trace.length > 0) { logger.info("------"); } } MoreExecutors.shutdownAndAwaitTermination(es, 10, TimeUnit.SECONDS); for (String failure : failures) { logger.debug(failure); } fail("Spun forever", e); }
private void parseSuite(String suitePath) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("suiteXmlPath: \"" + suitePath + "\"");
private void parseSuite(String suitePath) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("suiteXmlPath: \"" + suitePath + "\"");
/** * Prepare browserConf and IProperty for the test method */ public void prepareData() { if (isEnabled) { switch (dataSource) { case XmlData: updateXml(System.getProperty("env-type")); break; case GoogleData: updateGoogleSheet(System.getProperty("env-type")); break; case NoSource: // ignore no need to set data break; default: break; } }else{ LOGGER.debug("As the method:"+methodName+" is not enabled no need to set data"); } }
private void verify_UpdateDataProviderClass(IDataProvidable testAnnotation, Method testMethod) { if (testAnnotation.getDataProviderClass() != null && StringUtils.isNotBlank(testAnnotation.getDataProviderClass() .toString())) { if (!testAnnotation.getDataProviderClass().equals( omelet.data.DataProvider.class)) { throw new FrameworkException( "please fix data provider class for method:" + testMethod.getName()); } } else { testAnnotation.setDataProviderClass(omelet.data.DataProvider.class); LOGGER.debug("Setting Data provider class for method: " + testMethod.getName() + " value " + testAnnotation.getDataProviderClass().getName()); } }
private void verify_UpdateDataProviderName(IDataProvidable testAnnotation, Method testMethod) { if (StringUtils.isNotBlank(testAnnotation.getDataProvider())) { validateDataProviderName(testAnnotation.getDataProvider()); } else { testAnnotation.setDataProvider(getDataSourceParameter().name()); dataSource = getDataSourceParameter(); LOGGER.debug("Setting Data provider for method: " + testMethod.getName() + " value: " + testAnnotation.getDataProvider()); } }
public void setRetryAnalyser(ITestAnnotation methodAnnotation) { if (methodAnnotation.getRetryAnalyzer() == null) { methodAnnotation.setRetryAnalyzer(RetryAnalyzer.class); retryAnalyzer = methodAnnotation.getRetryAnalyzer(); } else { retryAnalyzer = methodAnnotation.getRetryAnalyzer(); } LOGGER.debug("Setting Retry Analyzer to " + methodAnnotation.getRetryAnalyzer() + " for Method: " + methodName); }