mock
This commit is contained in:
parent
91ab61b9fe
commit
700c772298
|
|
@ -7,7 +7,7 @@ import akka.cluster.Member;
|
|||
import akka.cluster.MemberStatus;
|
||||
import com.a.eye.skywalking.collector.cluster.WorkerListenerMessage;
|
||||
import com.a.eye.skywalking.collector.cluster.WorkersListener;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import com.a.eye.skywalking.collector.log.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
|
|
@ -52,7 +52,7 @@ public abstract class AbstractClusterWorker extends AbstractWorker {
|
|||
protected abstract void onWork(Object message) throws Exception;
|
||||
|
||||
static class WorkerWithAkka extends UntypedActor {
|
||||
private Logger logger = LogManager.getFormatterLogger(WorkerWithAkka.class);
|
||||
private Logger logger = LogManager.INSTANCE.getFormatterLogger(WorkerWithAkka.class);
|
||||
|
||||
private Cluster cluster;
|
||||
private final AbstractClusterWorker ownerWorker;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.a.eye.skywalking.collector.log;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public enum LogManager {
|
||||
INSTANCE;
|
||||
|
||||
public Logger getFormatterLogger(final Class<?> clazz) {
|
||||
return org.apache.logging.log4j.LogManager.getFormatterLogger(clazz);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.a.eye.skywalking.collector.actor;
|
||||
|
||||
import akka.actor.ActorSystem;
|
||||
import com.a.eye.skywalking.collector.actor.selector.RollingSelector;
|
||||
import com.a.eye.skywalking.collector.actor.selector.WorkerSelector;
|
||||
import com.a.eye.skywalking.collector.log.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
public class AbstractClusterWorkerProviderTestCase {
|
||||
|
||||
@Test
|
||||
public void testOnCreate() throws ProviderNotFoundException {
|
||||
LogManager logManager = Mockito.mock(LogManager.class);
|
||||
Whitebox.setInternalState(LogManager.class, "INSTANCE", logManager);
|
||||
Logger logger = Mockito.mock(Logger.class);
|
||||
Mockito.when(logManager.getFormatterLogger(Mockito.any())).thenReturn(logger);
|
||||
|
||||
ActorSystem actorSystem = Mockito.mock(ActorSystem.class);
|
||||
ClusterWorkerContext clusterWorkerContext = new ClusterWorkerContext(actorSystem);
|
||||
Impl impl = new Impl();
|
||||
impl.onCreate(null);
|
||||
}
|
||||
|
||||
class Impl extends AbstractClusterWorkerProvider<AbstractClusterWorkerTestCase.Impl> {
|
||||
@Override public Role role() {
|
||||
return Role.INSTANCE;
|
||||
}
|
||||
|
||||
@Override public AbstractClusterWorkerTestCase.Impl workerInstance(ClusterWorkerContext clusterContext) {
|
||||
return new AbstractClusterWorkerTestCase.Impl(role(), clusterContext, new LocalWorkerContext());
|
||||
}
|
||||
|
||||
@Override public int workerNum() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
enum Role implements com.a.eye.skywalking.collector.actor.Role {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public String roleName() {
|
||||
return AbstractClusterWorkerTestCase.Impl.class.getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkerSelector workerSelector() {
|
||||
return new RollingSelector();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +1,80 @@
|
|||
package com.a.eye.skywalking.collector.actor;
|
||||
|
||||
import akka.actor.Address;
|
||||
import akka.cluster.ClusterEvent;
|
||||
import akka.cluster.Member;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ClusterEvent.MemberUp.class, Address.class})
|
||||
public class AbstractClusterWorkerTestCase {
|
||||
|
||||
private AbstractClusterWorker.WorkerWithAkka workerWithAkka = mock(AbstractClusterWorker.WorkerWithAkka.class, CALLS_REAL_METHODS);
|
||||
private AbstractClusterWorker worker = PowerMockito.spy(new Impl(null, null, null));
|
||||
|
||||
@Before
|
||||
public void init(){
|
||||
Logger logger = mock(Logger.class);
|
||||
Whitebox.setInternalState(workerWithAkka, "logger", logger);
|
||||
Whitebox.setInternalState(workerWithAkka, "ownerWorker", worker);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllocateJob() throws Exception {
|
||||
AbstractClusterWorker worker = PowerMockito.mock(AbstractClusterWorker.class);
|
||||
|
||||
String jobStr = "TestJob";
|
||||
worker.allocateJob(jobStr);
|
||||
|
||||
Mockito.verify(worker).onWork(jobStr);
|
||||
verify(worker).onWork(jobStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMemberUp() throws Throwable {
|
||||
ClusterEvent.MemberUp memberUp = mock(ClusterEvent.MemberUp.class);
|
||||
|
||||
Address address = mock(Address.class);
|
||||
when(address.toString()).thenReturn("address");
|
||||
|
||||
Member member = mock(Member.class);
|
||||
when(member.address()).thenReturn(address);
|
||||
|
||||
when(memberUp.member()).thenReturn(member);
|
||||
|
||||
workerWithAkka.onReceive(memberUp);
|
||||
|
||||
verify(workerWithAkka).register(member);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessage() throws Throwable {
|
||||
String message = "test";
|
||||
workerWithAkka.onReceive(message);
|
||||
|
||||
verify(worker).allocateJob(message);
|
||||
}
|
||||
|
||||
static class Impl extends AbstractClusterWorker {
|
||||
@Override public void preStart() throws ProviderNotFoundException {
|
||||
}
|
||||
|
||||
public Impl(Role role, ClusterWorkerContext clusterContext, LocalWorkerContext selfContext) {
|
||||
super(role, clusterContext, selfContext);
|
||||
}
|
||||
|
||||
@Override protected void onWork(Object message) throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.a.eye.skywalking.collector.actor.selector;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class AbstractHashMessageTestCase {
|
||||
|
||||
@Test
|
||||
public void testGetHashCode() {
|
||||
String key = "key";
|
||||
|
||||
Impl impl = new Impl(key);
|
||||
Assert.assertEquals(key.hashCode(), impl.getHashCode());
|
||||
}
|
||||
|
||||
class Impl extends AbstractHashMessage {
|
||||
public Impl(String key) {
|
||||
super(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -46,4 +46,10 @@ public class HashCodeSelectorTestCase {
|
|||
WorkerRef select_3 = selector.select(members, message_3);
|
||||
Assert.assertEquals(workerRef_3.hashCode(), select_3.hashCode());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testSelectError() {
|
||||
HashCodeSelector selector = new HashCodeSelector();
|
||||
selector.select(null, new Object());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.a.eye.skywalking.collector.log;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class MockLog {
|
||||
|
||||
public Logger mockito() {
|
||||
LogManager logManager = PowerMockito.mock(LogManager.class);
|
||||
Logger logger = Mockito.mock(Logger.class);
|
||||
Mockito.when(logManager.getFormatterLogger(Mockito.any())).thenReturn(logger);
|
||||
return logger;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
akka {
|
||||
actor {
|
||||
provider = "akka.cluster.ClusterActorRefProvider"
|
||||
|
||||
serializers {
|
||||
java = "akka.serialization.JavaSerializer"
|
||||
proto = "akka.remote.serialization.ProtobufSerializer"
|
||||
// data = "com.a.eye.skywalking.collector.worker.TraceSegmentSerializer"
|
||||
// json = "com.a.eye.skywalking.collector.commons.serializer.JsonSerializer"
|
||||
}
|
||||
|
||||
serialization-bindings {
|
||||
"java.lang.String" = java
|
||||
"com.google.protobuf.Message" = proto
|
||||
// "com.a.eye.skywalking.messages.ISerializable" = data
|
||||
// "com.google.gson.JsonObject" = json
|
||||
// "java.io.Serializable" = none
|
||||
}
|
||||
|
||||
// serialize-messages = on
|
||||
warn-about-java-serializer-usage = on
|
||||
}
|
||||
|
||||
remote {
|
||||
log-remote-lifecycle-events = off
|
||||
|
||||
netty.tcp {
|
||||
hostname = "127.0.0.1"
|
||||
port = 1000
|
||||
}
|
||||
}
|
||||
|
||||
cluster {
|
||||
auto-down-unreachable-after = off
|
||||
metrics.enabled = off
|
||||
}
|
||||
}
|
||||
|
|
@ -36,8 +36,7 @@ public class GlobalTraceIndex extends AbstractIndex {
|
|||
.startObject()
|
||||
.startObject("properties")
|
||||
.startObject(SUB_SEG_IDS)
|
||||
.field("type", "text")
|
||||
.field("index", "not_analyzed")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
|
|
|||
|
|
@ -37,16 +37,13 @@ public class NodeCompIndex extends AbstractIndex {
|
|||
.startObject()
|
||||
.startObject("properties")
|
||||
.startObject(NAME)
|
||||
.field("type", "string")
|
||||
.field("index", "not_analyzed")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.startObject(PEERS)
|
||||
.field("type", "string")
|
||||
.field("index", "not_analyzed")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.startObject(AGG_COLUMN)
|
||||
.field("type", "string")
|
||||
.field("index", "not_analyzed")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
|
|
|||
|
|
@ -35,34 +35,31 @@ public class NodeRefIndex extends AbstractIndex {
|
|||
@Override
|
||||
public XContentBuilder createMappingBuilder() throws IOException {
|
||||
XContentBuilder mappingBuilder = XContentFactory.jsonBuilder()
|
||||
.startObject()
|
||||
.startObject("properties")
|
||||
.startObject(FRONT)
|
||||
.field("type", "string")
|
||||
.field("index", "not_analyzed")
|
||||
.endObject()
|
||||
.startObject(FRONT_IS_REAL_CODE)
|
||||
.field("type", "boolean")
|
||||
.field("index", "not_analyzed")
|
||||
.endObject()
|
||||
.startObject(BEHIND)
|
||||
.field("type", "string")
|
||||
.field("index", "not_analyzed")
|
||||
.endObject()
|
||||
.startObject(BEHIND_IS_REAL_CODE)
|
||||
.field("type", "boolean")
|
||||
.field("index", "not_analyzed")
|
||||
.endObject()
|
||||
.startObject(AGG_COLUMN)
|
||||
.field("type", "string")
|
||||
.field("index", "not_analyzed")
|
||||
.endObject()
|
||||
.startObject(TIME_SLICE)
|
||||
.field("type", "long")
|
||||
.field("index", "not_analyzed")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
.startObject()
|
||||
.startObject("properties")
|
||||
.startObject(FRONT)
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.startObject(FRONT_IS_REAL_CODE)
|
||||
.field("type", "boolean")
|
||||
.field("index", "not_analyzed")
|
||||
.endObject()
|
||||
.startObject(BEHIND)
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.startObject(BEHIND_IS_REAL_CODE)
|
||||
.field("type", "boolean")
|
||||
.field("index", "not_analyzed")
|
||||
.endObject()
|
||||
.startObject(AGG_COLUMN)
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.startObject(TIME_SLICE)
|
||||
.field("type", "long")
|
||||
.field("index", "not_analyzed")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
return mappingBuilder;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,8 +64,7 @@ public class NodeRefResSumIndex extends AbstractIndex {
|
|||
.field("index", "not_analyzed")
|
||||
.endObject()
|
||||
.startObject(AGG_COLUMN)
|
||||
.field("type", "string")
|
||||
.field("index", "not_analyzed")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.startObject(TIME_SLICE)
|
||||
.field("type", "long")
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ public class SegmentCostIndex extends AbstractIndex {
|
|||
.startObject()
|
||||
.startObject("properties")
|
||||
.startObject(SEG_ID)
|
||||
.field("type", "string")
|
||||
.field("index", "not_analyzed")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.startObject(START_TIME)
|
||||
.field("type", "long")
|
||||
|
|
@ -52,8 +51,7 @@ public class SegmentCostIndex extends AbstractIndex {
|
|||
.field("index", "not_analyzed")
|
||||
.endObject()
|
||||
.startObject(OPERATION_NAME)
|
||||
.field("type", "string")
|
||||
.field("index", "not_analyzed")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.startObject(COST)
|
||||
.field("type", "long")
|
||||
|
|
|
|||
|
|
@ -37,16 +37,14 @@ public class SegmentExceptionIndex extends AbstractIndex {
|
|||
.startObject()
|
||||
.startObject("properties")
|
||||
.startObject(SEG_ID)
|
||||
.field("type", "string")
|
||||
.field("index", "not_analyzed")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.startObject(IS_ERROR)
|
||||
.field("type", "boolean")
|
||||
.field("index", "not_analyzed")
|
||||
.endObject()
|
||||
.startObject(ERROR_KIND)
|
||||
.field("type", "string")
|
||||
.field("index", "not_analyzed")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@ public class SegmentIndex extends AbstractIndex {
|
|||
.startObject()
|
||||
.startObject("properties")
|
||||
.startObject("traceSegmentId")
|
||||
.field("type", "string")
|
||||
.field("index", "not_analyzed")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.startObject("startTime")
|
||||
.field("type", "date")
|
||||
|
|
@ -47,8 +46,7 @@ public class SegmentIndex extends AbstractIndex {
|
|||
.field("index", "not_analyzed")
|
||||
.endObject()
|
||||
.startObject("applicationCode")
|
||||
.field("type", "string")
|
||||
.field("index", "not_analyzed")
|
||||
.field("type", "keyword")
|
||||
.endObject()
|
||||
.startObject("minute")
|
||||
.field("type", "long")
|
||||
|
|
|
|||
|
|
@ -19,4 +19,8 @@ public enum PersistenceWorkerListener {
|
|||
public List<AbstractLocalSyncWorker> getWorkers() {
|
||||
return workers;
|
||||
}
|
||||
|
||||
public void reset(){
|
||||
workers.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,20 +15,12 @@
|
|||
<DefaultRolloverStrategy max="30"/>
|
||||
</RollingFile>
|
||||
</Appenders>
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="root" level="INFO" additivity="false">
|
||||
<appender-ref ref="RollingFile" level="INFO"/>
|
||||
</Logger>
|
||||
<Root level="INFO" additivity="false">
|
||||
<logger name="com.a.eye.skywalking.collector" level="debug">
|
||||
<AppenderRef ref="RollingFile"/>
|
||||
</logger>
|
||||
<Root level="INFO">
|
||||
<AppenderRef ref="RollingFile"/>
|
||||
</Root>
|
||||
<Root level="info">
|
||||
<AppenderRef ref="Console"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.a.eye.skywalking.collector.worker.config;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class CacheSizeConfigProviderTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
CacheSizeConfigProvider provider = new CacheSizeConfigProvider();
|
||||
provider.cliArgs();
|
||||
|
||||
Assert.assertEquals(CacheSizeConfig.class, provider.configClass());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.a.eye.skywalking.collector.worker.config;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class CacheSizeConfigTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
Assert.assertEquals(1024, CacheSizeConfig.Cache.Analysis.SIZE);
|
||||
Assert.assertEquals(5000, CacheSizeConfig.Cache.Persistence.SIZE);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.a.eye.skywalking.collector.worker.config;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class EsConfigProviderTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
EsConfigProvider provider = new EsConfigProvider();
|
||||
|
||||
Assert.assertEquals(EsConfig.class, provider.configClass());
|
||||
|
||||
System.setProperty("es.cluster.NAME", "A");
|
||||
System.setProperty("es.cluster.NODES", "B");
|
||||
System.setProperty("es.cluster.transport.SNIFFER", "C");
|
||||
System.setProperty("es.index.shards.NUMBER", "10");
|
||||
System.setProperty("es.index.replicas.NUMBER", "20");
|
||||
provider.cliArgs();
|
||||
|
||||
Assert.assertEquals("A", EsConfig.Es.Cluster.NAME);
|
||||
Assert.assertEquals("B", EsConfig.Es.Cluster.NODES);
|
||||
Assert.assertEquals("C", EsConfig.Es.Cluster.Transport.SNIFFER);
|
||||
Assert.assertEquals("10", EsConfig.Es.Index.Shards.NUMBER);
|
||||
Assert.assertEquals("20", EsConfig.Es.Index.Replicas.NUMBER);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.a.eye.skywalking.collector.worker.config;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class HttpConfigProviderTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
HttpConfigProvider provider = new HttpConfigProvider();
|
||||
|
||||
Assert.assertEquals(HttpConfig.class, provider.configClass());
|
||||
|
||||
System.setProperty("http.HOSTNAME", "A");
|
||||
System.setProperty("http.PORT", "B");
|
||||
System.setProperty("http.CONTEXTPATH", "C");
|
||||
provider.cliArgs();
|
||||
|
||||
Assert.assertEquals("A", HttpConfig.Http.HOSTNAME);
|
||||
Assert.assertEquals("B", HttpConfig.Http.PORT);
|
||||
Assert.assertEquals("C", HttpConfig.Http.CONTEXTPATH);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.a.eye.skywalking.collector.worker.config;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class HttpConfigTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
Assert.assertEquals("", HttpConfig.Http.HOSTNAME);
|
||||
Assert.assertEquals("", HttpConfig.Http.PORT);
|
||||
Assert.assertEquals("", HttpConfig.Http.CONTEXTPATH);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.a.eye.skywalking.collector.worker.config;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class WorkerConfigProviderTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
WorkerConfigProvider provider = new WorkerConfigProvider();
|
||||
provider.cliArgs();
|
||||
|
||||
Assert.assertEquals(WorkerConfig.class, provider.configClass());
|
||||
}
|
||||
}
|
||||
|
|
@ -20,6 +20,6 @@ public class GlobalTraceIndexTestCase {
|
|||
@Test
|
||||
public void testBuilder() throws IOException {
|
||||
GlobalTraceIndex index = new GlobalTraceIndex();
|
||||
Assert.assertEquals("{\"properties\":{\"subSegIds\":{\"type\":\"text\",\"index\":\"not_analyzed\"}}}", index.createMappingBuilder().string());
|
||||
Assert.assertEquals("{\"properties\":{\"subSegIds\":{\"type\":\"keyword\"}}}", index.createMappingBuilder().string());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,6 @@ public class NodeCompIndexTestCase {
|
|||
@Test
|
||||
public void testBuilder() throws IOException {
|
||||
NodeCompIndex index = new NodeCompIndex();
|
||||
Assert.assertEquals("{\"properties\":{\"name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"peers\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"aggId\":{\"type\":\"string\",\"index\":\"not_analyzed\"}}}", index.createMappingBuilder().string());
|
||||
Assert.assertEquals("{\"properties\":{\"name\":{\"type\":\"keyword\"},\"peers\":{\"type\":\"keyword\"},\"aggId\":{\"type\":\"keyword\"}}}", index.createMappingBuilder().string());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@ public class NodeRefIndexTestCase {
|
|||
@Test
|
||||
public void testBuilder() throws IOException {
|
||||
NodeRefIndex index = new NodeRefIndex();
|
||||
Assert.assertEquals("{\"properties\":{\"front\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"frontIsRealCode\":{\"type\":\"boolean\",\"index\":\"not_analyzed\"},\"behind\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"behindIsRealCode\":{\"type\":\"boolean\",\"index\":\"not_analyzed\"},\"aggId\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"timeSlice\":{\"type\":\"long\",\"index\":\"not_analyzed\"}}}", index.createMappingBuilder().string());
|
||||
Assert.assertEquals("{\"properties\":{\"front\":{\"type\":\"keyword\"},\"frontIsRealCode\":{\"type\":\"boolean\",\"index\":\"not_analyzed\"},\"behind\":{\"type\":\"keyword\"},\"behindIsRealCode\":{\"type\":\"boolean\",\"index\":\"not_analyzed\"},\"aggId\":{\"type\":\"keyword\"},\"timeSlice\":{\"type\":\"long\",\"index\":\"not_analyzed\"}}}", index.createMappingBuilder().string());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@ public class NodeRefResSumIndexTestCase {
|
|||
@Test
|
||||
public void testBuilder() throws IOException {
|
||||
NodeRefResSumIndex index = new NodeRefResSumIndex();
|
||||
Assert.assertEquals("{\"properties\":{\"oneSecondLess\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"threeSecondLess\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"fiveSecondLess\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"fiveSecondGreater\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"error\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"summary\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"aggId\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"timeSlice\":{\"type\":\"long\",\"index\":\"not_analyzed\"}}}", index.createMappingBuilder().string());
|
||||
Assert.assertEquals("{\"properties\":{\"oneSecondLess\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"threeSecondLess\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"fiveSecondLess\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"fiveSecondGreater\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"error\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"summary\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"aggId\":{\"type\":\"keyword\"},\"timeSlice\":{\"type\":\"long\",\"index\":\"not_analyzed\"}}}", index.createMappingBuilder().string());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@ public class SegmentCostIndexTestCase {
|
|||
@Test
|
||||
public void testBuilder() throws IOException {
|
||||
SegmentCostIndex index = new SegmentCostIndex();
|
||||
Assert.assertEquals("{\"properties\":{\"segId\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"startTime\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"END_TIME\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"operationName\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"cost\":{\"type\":\"long\",\"index\":\"not_analyzed\"}}}", index.createMappingBuilder().string());
|
||||
Assert.assertEquals("{\"properties\":{\"segId\":{\"type\":\"keyword\"},\"startTime\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"END_TIME\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"operationName\":{\"type\":\"keyword\"},\"cost\":{\"type\":\"long\",\"index\":\"not_analyzed\"}}}", index.createMappingBuilder().string());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@ public class SegmentExceptionIndexTestCase {
|
|||
@Test
|
||||
public void testBuilder() throws IOException {
|
||||
SegmentExceptionIndex index = new SegmentExceptionIndex();
|
||||
Assert.assertEquals("{\"properties\":{\"segId\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"isError\":{\"type\":\"boolean\",\"index\":\"not_analyzed\"},\"errorKind\":{\"type\":\"string\",\"index\":\"not_analyzed\"}}}", index.createMappingBuilder().string());
|
||||
Assert.assertEquals("{\"properties\":{\"segId\":{\"type\":\"keyword\"},\"isError\":{\"type\":\"boolean\",\"index\":\"not_analyzed\"},\"errorKind\":{\"type\":\"keyword\"}}}", index.createMappingBuilder().string());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@ public class SegmentIndexTestCase {
|
|||
@Test
|
||||
public void testBuilder() throws IOException {
|
||||
SegmentIndex index = new SegmentIndex();
|
||||
Assert.assertEquals("{\"properties\":{\"traceSegmentId\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"startTime\":{\"type\":\"date\",\"index\":\"not_analyzed\"},\"endTime\":{\"type\":\"date\",\"index\":\"not_analyzed\"},\"applicationCode\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"minute\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"hour\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"day\":{\"type\":\"long\",\"index\":\"not_analyzed\"}}}", index.createMappingBuilder().string());
|
||||
Assert.assertEquals("{\"properties\":{\"traceSegmentId\":{\"type\":\"keyword\"},\"startTime\":{\"type\":\"date\",\"index\":\"not_analyzed\"},\"endTime\":{\"type\":\"date\",\"index\":\"not_analyzed\"},\"applicationCode\":{\"type\":\"keyword\"},\"minute\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"hour\":{\"type\":\"long\",\"index\":\"not_analyzed\"},\"day\":{\"type\":\"long\",\"index\":\"not_analyzed\"}}}", index.createMappingBuilder().string());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
package com.a.eye.skywalking.collector.worker.storage;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class MergeAnalysisDataTestCase {
|
||||
|
||||
@Test
|
||||
public void getOrCreate() {
|
||||
MergeAnalysisData mergeAnalysisData = new MergeAnalysisData();
|
||||
MergeData mergeData = mergeAnalysisData.getOrCreate("Test1");
|
||||
|
||||
MergeData mergeData_1 = mergeAnalysisData.getOrCreate("Test1");
|
||||
Assert.assertEquals(mergeData, mergeData_1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void asMap() {
|
||||
MergeAnalysisData mergeAnalysisData = new MergeAnalysisData();
|
||||
MergeData mergeData = mergeAnalysisData.getOrCreate("Test1");
|
||||
|
||||
MergeData mergeData_1 = mergeAnalysisData.asMap().get("Test1");
|
||||
Assert.assertEquals(mergeData, mergeData_1);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,14 @@
|
|||
package com.a.eye.skywalking.collector.worker.storage;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class MergePersistenceWindowDataTestCase {
|
||||
public class MergePersistenceDataTestCase {
|
||||
|
||||
@Test
|
||||
public void testGetElseCreate() {
|
||||
|
|
@ -37,4 +39,29 @@ public class MergePersistenceWindowDataTestCase {
|
|||
persistenceData.getCurrentAndHold().clear();
|
||||
Assert.assertEquals(0, persistenceData.getCurrentAndHold().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hold() throws NoSuchFieldException, IllegalAccessException {
|
||||
MergePersistenceData persistenceData = new MergePersistenceData();
|
||||
persistenceData.hold();
|
||||
|
||||
Field testAField = persistenceData.getClass().getDeclaredField("lockedWindowData");
|
||||
testAField.setAccessible(true);
|
||||
WindowData<MergeData> windowData = (WindowData<MergeData>)testAField.get(persistenceData);
|
||||
Assert.assertEquals(true, windowData.isHolding());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void release() throws NoSuchFieldException, IllegalAccessException {
|
||||
MergePersistenceData persistenceData = new MergePersistenceData();
|
||||
persistenceData.hold();
|
||||
|
||||
Field testAField = persistenceData.getClass().getDeclaredField("lockedWindowData");
|
||||
testAField.setAccessible(true);
|
||||
WindowData<MergeData> windowData = (WindowData<MergeData>)testAField.get(persistenceData);
|
||||
Assert.assertEquals(true, windowData.isHolding());
|
||||
|
||||
persistenceData.release();
|
||||
Assert.assertEquals(false, windowData.isHolding());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.a.eye.skywalking.collector.worker.storage;
|
||||
|
||||
import com.a.eye.skywalking.collector.worker.Const;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class MetricAnalysisDataTestCase {
|
||||
|
||||
@Test
|
||||
public void getOrCreate() {
|
||||
String id = "2016" + Const.ID_SPLIT + "A" + Const.ID_SPLIT + "B";
|
||||
MetricAnalysisData metricAnalysisData = new MetricAnalysisData();
|
||||
MetricData metricData = metricAnalysisData.getOrCreate(id);
|
||||
|
||||
MetricData metricData_1 = metricAnalysisData.getOrCreate(id);
|
||||
Assert.assertEquals(metricData, metricData_1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void asMap() {
|
||||
String id = "2016" + Const.ID_SPLIT + "A" + Const.ID_SPLIT + "B";
|
||||
MetricAnalysisData metricAnalysisData = new MetricAnalysisData();
|
||||
MetricData metricData = metricAnalysisData.getOrCreate(id);
|
||||
|
||||
MetricData metricData_1 = metricAnalysisData.asMap().get(id);
|
||||
Assert.assertEquals(metricData, metricData_1);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,14 @@
|
|||
package com.a.eye.skywalking.collector.worker.storage;
|
||||
|
||||
import com.a.eye.skywalking.collector.worker.Const;
|
||||
import java.lang.reflect.Field;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class MetricPersistenceWindowDataTestCase {
|
||||
public class MetricPersistenceTestCase {
|
||||
|
||||
@Test
|
||||
public void testGetElseCreate() {
|
||||
|
|
@ -39,4 +40,29 @@ public class MetricPersistenceWindowDataTestCase {
|
|||
metricPersistenceData.getCurrentAndHold().clear();
|
||||
Assert.assertEquals(0, metricPersistenceData.getCurrentAndHold().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hold() throws NoSuchFieldException, IllegalAccessException {
|
||||
MetricPersistenceData persistenceData = new MetricPersistenceData();
|
||||
persistenceData.hold();
|
||||
|
||||
Field testAField = persistenceData.getClass().getDeclaredField("lockedWindowData");
|
||||
testAField.setAccessible(true);
|
||||
WindowData<MergeData> windowData = (WindowData<MergeData>)testAField.get(persistenceData);
|
||||
Assert.assertEquals(true, windowData.isHolding());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void release() throws NoSuchFieldException, IllegalAccessException {
|
||||
MetricPersistenceData persistenceData = new MetricPersistenceData();
|
||||
persistenceData.hold();
|
||||
|
||||
Field testAField = persistenceData.getClass().getDeclaredField("lockedWindowData");
|
||||
testAField.setAccessible(true);
|
||||
WindowData<MergeData> windowData = (WindowData<MergeData>)testAField.get(persistenceData);
|
||||
Assert.assertEquals(true, windowData.isHolding());
|
||||
|
||||
persistenceData.release();
|
||||
Assert.assertEquals(false, windowData.isHolding());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.a.eye.skywalking.collector.worker.storage;
|
||||
|
||||
import com.a.eye.skywalking.collector.actor.AbstractLocalSyncWorker;
|
||||
import java.util.List;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class PersistenceWorkerListenerTestCase {
|
||||
|
||||
@Test
|
||||
public void register() {
|
||||
PersistenceWorkerListener.INSTANCE.reset();
|
||||
AbstractLocalSyncWorker worker = Mockito.mock(AbstractLocalSyncWorker.class);
|
||||
PersistenceWorkerListener.INSTANCE.register(worker);
|
||||
|
||||
List<AbstractLocalSyncWorker> workers = PersistenceWorkerListener.INSTANCE.getWorkers();
|
||||
Assert.assertEquals(worker, workers.get(0));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.a.eye.skywalking.collector.worker.storage;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class RecordAnalysisDataTestCase {
|
||||
|
||||
@Test
|
||||
public void getOrCreate() {
|
||||
RecordAnalysisData recordAnalysisData = new RecordAnalysisData();
|
||||
RecordData recordData = recordAnalysisData.getOrCreate("Test1");
|
||||
|
||||
RecordData recordData_1 = recordAnalysisData.getOrCreate("Test1");
|
||||
Assert.assertEquals(recordData, recordData_1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void asMap() {
|
||||
RecordAnalysisData recordAnalysisData = new RecordAnalysisData();
|
||||
RecordData recordData = recordAnalysisData.getOrCreate("Test1");
|
||||
recordData.merge(null);
|
||||
|
||||
RecordData recordData_1 = recordAnalysisData.asMap().get("Test1");
|
||||
Assert.assertEquals(recordData, recordData_1);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,13 +2,14 @@ package com.a.eye.skywalking.collector.worker.storage;
|
|||
|
||||
import com.a.eye.skywalking.collector.worker.Const;
|
||||
import com.google.gson.JsonObject;
|
||||
import java.lang.reflect.Field;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class RecordPersistenceWindowDataTestCase {
|
||||
public class RecordPersistenceTestCase {
|
||||
|
||||
@Test
|
||||
public void testGetElseCreate() {
|
||||
|
|
@ -43,4 +44,29 @@ public class RecordPersistenceWindowDataTestCase {
|
|||
recordPersistenceData.getCurrentAndHold().clear();
|
||||
Assert.assertEquals(0, recordPersistenceData.getCurrentAndHold().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hold() throws NoSuchFieldException, IllegalAccessException {
|
||||
RecordPersistenceData persistenceData = new RecordPersistenceData();
|
||||
persistenceData.hold();
|
||||
|
||||
Field testAField = persistenceData.getClass().getDeclaredField("lockedWindowData");
|
||||
testAField.setAccessible(true);
|
||||
WindowData<MergeData> windowData = (WindowData<MergeData>)testAField.get(persistenceData);
|
||||
Assert.assertEquals(true, windowData.isHolding());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void release() throws NoSuchFieldException, IllegalAccessException {
|
||||
RecordPersistenceData persistenceData = new RecordPersistenceData();
|
||||
persistenceData.hold();
|
||||
|
||||
Field testAField = persistenceData.getClass().getDeclaredField("lockedWindowData");
|
||||
testAField.setAccessible(true);
|
||||
WindowData<MergeData> windowData = (WindowData<MergeData>)testAField.get(persistenceData);
|
||||
Assert.assertEquals(true, windowData.isHolding());
|
||||
|
||||
persistenceData.release();
|
||||
Assert.assertEquals(false, windowData.isHolding());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.a.eye.skywalking.collector.worker.storage;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class SegmentDataTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SegmentData segmentData = new SegmentData("Test1");
|
||||
|
||||
segmentData.merge(null);
|
||||
Assert.assertEquals("Test1", segmentData.getId());
|
||||
|
||||
segmentData.setSegmentStr("Test2");
|
||||
Assert.assertEquals("Test2", segmentData.getSegmentStr());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.a.eye.skywalking.collector.worker.storage;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class SegmentPersistenceDataTestCase {
|
||||
|
||||
@Test
|
||||
public void getOrCreate() throws NoSuchFieldException, IllegalAccessException {
|
||||
SegmentPersistenceData segmentPersistenceData = new SegmentPersistenceData();
|
||||
segmentPersistenceData.hold();
|
||||
SegmentData segmentData = segmentPersistenceData.getOrCreate("Test1");
|
||||
|
||||
SegmentData segmentData_1 = segmentPersistenceData.getOrCreate("Test1");
|
||||
Assert.assertEquals(segmentData, segmentData_1);
|
||||
|
||||
SegmentData segmentData_2 = segmentPersistenceData.getOrCreate("Test2");
|
||||
Assert.assertEquals(2, segmentPersistenceData.size());
|
||||
|
||||
System.out.println(segmentPersistenceData.asMap().toString());
|
||||
Assert.assertEquals(segmentData, segmentPersistenceData.asMap().get("Test1"));
|
||||
Assert.assertEquals(segmentData_2, segmentPersistenceData.asMap().get("Test2"));
|
||||
|
||||
Field testAField = segmentPersistenceData.getClass().getDeclaredField("lockedWindowData");
|
||||
testAField.setAccessible(true);
|
||||
WindowData<SegmentData> windowData = (WindowData<SegmentData>)testAField.get(segmentPersistenceData);
|
||||
Assert.assertEquals(true, windowData.isHolding());
|
||||
|
||||
segmentPersistenceData.release();
|
||||
Assert.assertEquals(false, windowData.isHolding());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
package com.a.eye.skywalking.collector.worker.storage;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class WindowTestCase {
|
||||
|
||||
@Test
|
||||
public void switchPointer() throws NoSuchFieldException, IllegalAccessException {
|
||||
Impl impl = new Impl();
|
||||
|
||||
Field pointerField = impl.getClass().getSuperclass().getDeclaredField("pointer");
|
||||
pointerField.setAccessible(true);
|
||||
WindowData<DataImpl> pointer = (WindowData<DataImpl>)pointerField.get(impl);
|
||||
|
||||
Field windowDataAField = impl.getClass().getSuperclass().getDeclaredField("windowDataA");
|
||||
windowDataAField.setAccessible(true);
|
||||
WindowData<DataImpl> windowDataA = (WindowData<DataImpl>)windowDataAField.get(impl);
|
||||
|
||||
Field windowDataBField = impl.getClass().getSuperclass().getDeclaredField("windowDataB");
|
||||
windowDataBField.setAccessible(true);
|
||||
WindowData<DataImpl> windowDataB = (WindowData<DataImpl>)windowDataBField.get(impl);
|
||||
|
||||
Assert.assertEquals(false, windowDataA.isHolding());
|
||||
WindowData<DataImpl> current = impl.getCurrentAndHold();
|
||||
Assert.assertEquals(current, windowDataA);
|
||||
Assert.assertEquals(true, windowDataA.isHolding());
|
||||
|
||||
WindowData<DataImpl> last = impl.getLast();
|
||||
Assert.assertEquals(last, windowDataB);
|
||||
|
||||
Assert.assertEquals(pointer, windowDataA);
|
||||
impl.switchPointer();
|
||||
pointer = (WindowData<DataImpl>)pointerField.get(impl);
|
||||
Assert.assertEquals(pointer, windowDataB);
|
||||
|
||||
current = impl.getCurrentAndHold();
|
||||
Assert.assertEquals(current, windowDataB);
|
||||
Assert.assertEquals(true, windowDataB.isHolding());
|
||||
|
||||
last = impl.getLast();
|
||||
Assert.assertEquals(last, windowDataA);
|
||||
|
||||
impl.switchPointer();
|
||||
pointer = (WindowData<DataImpl>)pointerField.get(impl);
|
||||
Assert.assertEquals(pointer, windowDataA);
|
||||
}
|
||||
|
||||
class Impl extends Window<DataImpl> {
|
||||
|
||||
}
|
||||
|
||||
class DataImpl implements Data {
|
||||
@Override public String getId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public void merge(Map<String, ?> dbData) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue