/*
 * Copyright 2017, OpenSkywalking Organization All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Project repository: https://github.com/OpenSkywalking/skywalking
 */

package org.skywalking.apm.collector.core.util;

import org.junit.Assert;
import org.junit.Test;

/**
 * @author wu-sheng
 */
public class TimeBucketUtilsTest {
    @Test
    public void testGetInfoFromATimestamp() {
        long timeMillis = 1509521745220L;
        Assert.assertArrayEquals(new long[] {
            20171101153545L,
            20171101153544L,
            20171101153543L,
            20171101153542L,
            20171101153541L
        }, TimeBucketUtils.INSTANCE.getFiveSecondTimeBuckets(TimeBucketUtils.INSTANCE.getSecondTimeBucket(timeMillis)));
        Assert.assertEquals(20171101153545L, TimeBucketUtils.INSTANCE.getSecondTimeBucket(timeMillis));
        Assert.assertEquals(201711011535L, TimeBucketUtils.INSTANCE.getMinuteTimeBucket(timeMillis));
        Assert.assertEquals(201711011500L, TimeBucketUtils.INSTANCE.getHourTimeBucket(timeMillis));
        Assert.assertEquals(201711010000L, TimeBucketUtils.INSTANCE.getDayTimeBucket(timeMillis));
    }
}

@@ -747,16 +747,67 @@
 .util;%0A%0A
+import java.util.TimeZone;%0Aimport org.junit.After;%0A
 import o
@@ -823,16 +823,41 @@
 Assert;%0A
+import org.junit.Before;%0A
 import o
@@ -935,16 +935,177 @@
 sTest %7B%0A
+    @Before%0A    public void setup() %7B%0A        TimeZone.setDefault(TimeZone.getTimeZone(%22Asia/Shanghai%22));%0A    %7D%0A%0A    @After%0A    public void teardown() %7B%0A%0A    %7D%0A%0A
     @Tes

Fix time zone issue.