Search in sources :

Example 1 with MicroserviceKey

use of io.servicecomb.serviceregistry.api.MicroserviceKey in project java-chassis by ServiceComb.

the class TestCacheRegistryListener method testonMicroserviceInstanceChangedUPDATE.

@Test
public void testonMicroserviceInstanceChangedUPDATE() {
    MicroserviceInstanceChangedEvent changedEvent = new MicroserviceInstanceChangedEvent();
    changedEvent.setAction(WatchAction.UPDATE);
    MicroserviceKey key = Mockito.mock(MicroserviceKey.class);
    changedEvent.setKey(key);
    MicroserviceInstance mInstance = Mockito.mock(MicroserviceInstance.class);
    changedEvent.setInstance(mInstance);
    instance.onMicroserviceInstanceChanged(changedEvent);
}
Also used : MicroserviceInstanceChangedEvent(io.servicecomb.serviceregistry.api.response.MicroserviceInstanceChangedEvent) MicroserviceKey(io.servicecomb.serviceregistry.api.MicroserviceKey) MicroserviceInstance(io.servicecomb.serviceregistry.api.registry.MicroserviceInstance) Test(org.junit.Test)

Example 2 with MicroserviceKey

use of io.servicecomb.serviceregistry.api.MicroserviceKey in project java-chassis by ServiceComb.

the class TestInstanceCacheManager method testInstanceUpdate.

@Test
public void testInstanceUpdate() {
    Microservice oInstance = RegistryUtils.getMicroservice();
    InstanceCacheManager oInstanceCacheManager = new InstanceCacheManager();
    MicroserviceInstanceChangedEvent oChangedEnvent = new MicroserviceInstanceChangedEvent();
    oChangedEnvent.setAction(WatchAction.UPDATE);
    MicroserviceKey oKey = new MicroserviceKey();
    oKey.setAppId(oInstance.getAppId());
    oKey.setVersion(oInstance.getVersion());
    oKey.setServiceName(oInstance.getServiceName());
    oChangedEnvent.setKey(oKey);
    oChangedEnvent.setInstance(RegistryUtils.getMicroserviceInstance());
    oInstanceCacheManager.onInstanceUpdate(oChangedEnvent);
    oChangedEnvent.setAction(WatchAction.DELETE);
    oInstanceCacheManager.onInstanceUpdate(oChangedEnvent);
    oChangedEnvent.setAction(WatchAction.CREATE);
    oInstanceCacheManager.onInstanceUpdate(oChangedEnvent);
    Assert.assertEquals("UP", RegistryUtils.getMicroserviceInstance().getStatus().toString());
}
Also used : MicroserviceInstanceChangedEvent(io.servicecomb.serviceregistry.api.response.MicroserviceInstanceChangedEvent) Microservice(io.servicecomb.serviceregistry.api.registry.Microservice) MicroserviceKey(io.servicecomb.serviceregistry.api.MicroserviceKey) Test(org.junit.Test)

Example 3 with MicroserviceKey

use of io.servicecomb.serviceregistry.api.MicroserviceKey in project java-chassis by ServiceComb.

the class TestCacheRegistryListener method testonMicroserviceInstanceChangedCREATE.

@Test
public void testonMicroserviceInstanceChangedCREATE() {
    MicroserviceInstanceChangedEvent changedEvent = new MicroserviceInstanceChangedEvent();
    changedEvent.setAction(WatchAction.CREATE);
    MicroserviceKey key = Mockito.mock(MicroserviceKey.class);
    changedEvent.setKey(key);
    MicroserviceInstance mInstance = Mockito.mock(MicroserviceInstance.class);
    changedEvent.setInstance(mInstance);
    instance.onMicroserviceInstanceChanged(changedEvent);
}
Also used : MicroserviceInstanceChangedEvent(io.servicecomb.serviceregistry.api.response.MicroserviceInstanceChangedEvent) MicroserviceKey(io.servicecomb.serviceregistry.api.MicroserviceKey) MicroserviceInstance(io.servicecomb.serviceregistry.api.registry.MicroserviceInstance) Test(org.junit.Test)

Example 4 with MicroserviceKey

use of io.servicecomb.serviceregistry.api.MicroserviceKey in project java-chassis by ServiceComb.

the class TestCacheRegistryListener method testonMicroserviceInstanceChangedDELETE.

@Test
public void testonMicroserviceInstanceChangedDELETE() {
    MicroserviceInstanceChangedEvent changedEvent = new MicroserviceInstanceChangedEvent();
    changedEvent.setAction(WatchAction.DELETE);
    MicroserviceKey key = Mockito.mock(MicroserviceKey.class);
    changedEvent.setKey(key);
    MicroserviceInstance mInstance = Mockito.mock(MicroserviceInstance.class);
    changedEvent.setInstance(mInstance);
    instance.onMicroserviceInstanceChanged(changedEvent);
}
Also used : MicroserviceInstanceChangedEvent(io.servicecomb.serviceregistry.api.response.MicroserviceInstanceChangedEvent) MicroserviceKey(io.servicecomb.serviceregistry.api.MicroserviceKey) MicroserviceInstance(io.servicecomb.serviceregistry.api.registry.MicroserviceInstance) Test(org.junit.Test)

Aggregations

MicroserviceKey (io.servicecomb.serviceregistry.api.MicroserviceKey)4 MicroserviceInstanceChangedEvent (io.servicecomb.serviceregistry.api.response.MicroserviceInstanceChangedEvent)4 Test (org.junit.Test)4 MicroserviceInstance (io.servicecomb.serviceregistry.api.registry.MicroserviceInstance)3 Microservice (io.servicecomb.serviceregistry.api.registry.Microservice)1