All Downloads are FREE. Search and download functionalities are using the official Maven repository.

bichromate.core.sTestCleanupFactory Maven / Gradle / Ivy

Go to download

Java, Selenium, Appium, Winium, Extend, and TestNG automated testing framework. Bichromate integrates the best of these frameworks and takes automation to the next level. With Bichromate there is one function call that builds any type of Web,IOS Mobile, Android, and Windows App driver on any platform (Windows, Mac, Linux). From Local web drivers, to SauceLabs, Browserstack, and Selenium grid. Build data driven tests is never easier. Bichromate also gives you built in Factories that, access DBs, Video Capture, FTP, POM Generation, Hilite element.

There is a newer version: 3.13
Show newest version
/*
 *
 * Copyright (c) 2016 by David Ramer, Inc. All Rights Reserved.
 *
 * David Ramer grants you ("Licensee") a non-exclusive, royalty free, license to use,
 * modify and redistribute this software in source and binary code form,
 * provided that i) this copyright notice and license appear on all copies of
 * the software; and ii) Licensee does not utilize the software in a manner
 * which is disparaging to David Ramer.
 *
 * This software is provided "AS IS," without a warranty of any kind. ALL
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
 * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
 * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. David Ramer AND ITS LICENSORS SHALL NOT BE
 * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
 * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL David Ramer OR ITS
 * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
 * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
 * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
 * OR INABILITY TO USE SOFTWARE, EVEN IF DRamer HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES.
 *
 * This software is not designed or intended for use in on-line control of
 * aircraft, air traffic, aircraft navigation or aircraft communications; or in
 * the design, construction, operation or maintenance of any nuclear
 * facility. Licensee represents and warrants that it will not use or
 * redistribute the Software for such purposes.
 */


package bichromate.core;

import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoField;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

import org.apache.commons.io.FileUtils;

/**
 * class sTestCleanupFactory() constructor
 * constructor for the sTestCleanupFactory Class is used to clean-up all files created after tests are run
 */
@SuppressWarnings("unused")
public class sTestCleanupFactory {
	
	private static final String cleanReportsFilesSchedule = null;


	protected static ResourceBundle resources;
	
	
	private String cleanLogFiles = null; 
	private String cleanLogFilesSchedule = null; 
	private String cleanReports = null; 
	private String cleanReportsSchedule = null; 
	private String cleanScreenCapture = null; 
	private String cleanScreenCaptureSchedule = null; 
	private String holidays = null;
	private List holidayDates = null;
	private LocalDate today = null;
	private DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
	private boolean holidayDatesSetup = false;
	private int executeCleanup = 0;
	private sTestOSInformationFactory osInfo = null;
	
	
	// The returned value (0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday)
	
	
	static {
		try {
			resources = ResourceBundle.getBundle("core.sTestCleanupFactory", Locale.getDefault());
		} catch (MissingResourceException mre) {
			System.out.println("sTestCleanupFactory.properties not found: "+ mre);
			System.exit(0);
		}
		
	}
	/**
	 * This method sTestCleanupFactory() constructor
	 *constructor for the sTestCleanupFactory Class is used to clean-up all files created after tests are run
	 * @param myResources to initialize all Factories, you can pass in Bichromate.properties
	 */
	public sTestCleanupFactory(ResourceBundle myResources) {
		
		sTestCleanupFactorySetup(myResources);
	}// sTestCleanupFactory
	
	/**
	 * This method sTestCleanupFactory() constructor
	 *constructor for the sTestCleanupFactory Class is used to clean-up all files created after tests are run
	 */
	public sTestCleanupFactory() {
		sTestCleanupFactorySetup(resources);
		
	}// sTestCleanupFactory
	private void sTestCleanupFactorySetup(ResourceBundle myResources){
		//
		// setup STestOSInformation
		//
		osInfo = new sTestOSInformationFactory();
		
		
		cleanLogFiles = new String(myResources.getString("sTestCleanupFactory.cleanLogFiles"));
		cleanLogFilesSchedule = new String(myResources.getString("sTestCleanupFactory.cleanLogFilesSchedule")); 
		cleanReports = new String(myResources.getString("sTestCleanupFactory.cleanReports")); 
		cleanReportsSchedule = new String(myResources.getString("sTestCleanupFactory.cleanReportsSchedule"));
		cleanScreenCapture = new String(myResources.getString("sTestCleanupFactory.cleanScreenCapture")); 
		cleanScreenCaptureSchedule = new String(myResources.getString("sTestCleanupFactory.cleanScreenCaptureSchedule")); 
		holidays = new String(myResources.getString("sTestCleanupFactory.holidays")); 	
	
		//
		// setup Holiday dates
		//
		setupHolidayDates();
		
	}//sTestCleanupFactorySetup
	
	private boolean setupHolidayDates(){
		holidayDates = new ArrayList();
		
		//today = new Date();
		today = LocalDate.now();
		
		ArrayList  aList= new ArrayList(Arrays.asList(holidays.split(",")));
		
		for(int i=0;i aList= new ArrayList(Arrays.asList(daysToProcess.split(",")));
		  for(int i=0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy