/*
 * The MIT License (MIT)
 *
 * Copyright (c) Open Application Platform Authors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package oap.testng;

import oap.io.Files;
import org.joda.time.DateTimeUtils;
import org.joda.time.DateTimeZone;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeMethod;

import java.io.IOException;

public abstract class AbstractTest {
    static {
        DateTimeZone.setDefault( DateTimeZone.UTC );
    }

    protected boolean CLEANUP_TEMP = true;

    @AfterSuite
    public void afterSuite() {
        if( CLEANUP_TEMP ) Files.delete( Env.tmp );
    }

    @AfterClass
    public void afterClass() {
        if( CLEANUP_TEMP ) Files.delete( Env.tmpRoot );
    }

    @BeforeMethod
    public void beforeMethod() {
        DateTimeUtils.setCurrentMillisSystem();
        DateTimeZone.setDefault( DateTimeZone.UTC );
    }

    @AfterMethod
    public void afterMethod() throws IOException {
        afterMethod( true );
    }

    protected void afterMethod( boolean cleanup ) throws IOException {
        if( CLEANUP_TEMP && cleanup ) Files.delete( Env.tmpRoot );
        DateTimeUtils.setCurrentMillisSystem();
    }
}

@@ -1509,82 +1509,8 @@
 t %7B%0A
-    static %7B%0A        DateTimeZone.setDefault( DateTimeZone.UTC );%0A    %7D%0A%0A 
    p
@@ -1547,25 +1547,24 @@
 = true;%0A%0A   
- 
 @AfterSuite%0A
@@ -1563,17 +1563,16 @@
 erSuite%0A
- 
    publi
@@ -1591,34 +1591,32 @@
 Suite() %7B%0A      
- 
- 
 if( CLEANUP_TEMP
@@ -1642,29 +1642,27 @@
 v.tmp );%0A   
- 
 %7D%0A%0A
- 
    @AfterCla
@@ -1664,17 +1664,16 @@
 erClass%0A
- 
    publi
@@ -1692,34 +1692,32 @@
 Class() %7B%0A      
-  
 if( CLEANUP_TEMP
@@ -1744,25 +1744,24 @@
 .tmpRoot );%0A
- 
    %7D%0A%0A    @B
@@ -1757,17 +1757,16 @@
   %7D%0A%0A   
- 
 @BeforeM
@@ -1767,25 +1767,24 @@
 eforeMethod%0A
- 
    public vo
@@ -1805,26 +1805,24 @@
 d() %7B%0A      
- 
- 
 DateTimeUtil
@@ -1849,18 +1849,16 @@
 stem();%0A
-  
       Da
@@ -1903,21 +1903,19 @@
 C );%0A   
- 
 %7D%0A%0A
- 
    @Afte
@@ -1922,17 +1922,16 @@
 rMethod%0A
- 
    publi
@@ -1978,18 +1978,16 @@
 %7B%0A      
-  
 afterMet
@@ -1999,17 +1999,16 @@
 true );%0A
- 
    %7D%0A%0A  
@@ -2008,17 +2008,16 @@
   %7D%0A%0A   
- 
 protecte
@@ -2071,26 +2071,24 @@
 Exception %7B%0A
-  
       if( CL
@@ -2142,26 +2142,24 @@
 ot );%0A      
-  
 DateTimeUtil
@@ -2186,16 +2186,15 @@
 stem();%0A
- 
    %7D%0A%7D%0A

no utc set