NodeRefHourSaveTestCase.java 1.8 KB
Newer Older
P
pengys5 已提交
1 2 3 4 5
package com.a.eye.skywalking.collector.worker.noderef.persistence;

import com.a.eye.skywalking.collector.actor.ClusterWorkerContext;
import com.a.eye.skywalking.collector.actor.LocalWorkerContext;
import com.a.eye.skywalking.collector.actor.selector.HashCodeSelector;
P
pengys5 已提交
6
import com.a.eye.skywalking.collector.worker.config.WorkerConfig;
P
pengys5 已提交
7 8 9 10 11
import com.a.eye.skywalking.collector.worker.noderef.NodeRefIndex;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

12 13
import java.util.TimeZone;

P
pengys5 已提交
14 15 16 17 18 19 20 21 22
/**
 * @author pengys5
 */
public class NodeRefHourSaveTestCase {

    private NodeRefHourSave save;

    @Before
    public void init() {
23 24 25
        System.setProperty("user.timezone", "UTC");
        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

P
pengys5 已提交
26 27 28 29 30 31 32
        ClusterWorkerContext cluster = new ClusterWorkerContext(null);
        LocalWorkerContext local = new LocalWorkerContext();
        save = new NodeRefHourSave(NodeRefHourSave.Role.INSTANCE, cluster, local);
    }

    @Test
    public void testEsIndex() {
33
        Assert.assertEquals(NodeRefIndex.INDEX, save.esIndex());
P
pengys5 已提交
34 35 36 37
    }

    @Test
    public void testEsType() {
38
        Assert.assertEquals(NodeRefIndex.TYPE_HOUR, save.esType());
P
pengys5 已提交
39 40 41 42 43 44 45 46 47 48
    }

    @Test
    public void testRole() {
        Assert.assertEquals(NodeRefHourSave.class.getSimpleName(), NodeRefHourSave.Role.INSTANCE.roleName());
        Assert.assertEquals(HashCodeSelector.class.getSimpleName(), NodeRefHourSave.Role.INSTANCE.workerSelector().getClass().getSimpleName());
    }

    @Test
    public void testFactory() {
P
Fix 159  
pengys5 已提交
49 50 51
        NodeRefHourSave.Factory factory = new NodeRefHourSave.Factory();
        Assert.assertEquals(NodeRefHourSave.class.getSimpleName(), factory.role().roleName());
        Assert.assertEquals(NodeRefHourSave.class.getSimpleName(), factory.workerInstance(null).getClass().getSimpleName());
P
pengys5 已提交
52 53
    }
}