use of org.eclipse.scout.rt.shared.services.common.code.ICodeService in project scout.rt by eclipse.
the class CodeServiceTest method testInvlidateCodeTypes.
/**
* Tests that a client notification is created when invalidating a list of code types
* {@link CodeService#invalidateCodeTypes(List)}
*/
@Test
public void testInvlidateCodeTypes() {
ICodeService codeService = BEANS.get(ICodeService.class);
List<Class<? extends ICodeType<?, ?>>> list = new ArrayList<Class<? extends ICodeType<?, ?>>>();
list.add(SomeCodeType.class);
list.add(DummyCodeType.class);
codeService.invalidateCodeTypes(list);
ArgumentCaptor<InvalidateCacheNotification> notification = ArgumentCaptor.forClass(InvalidateCacheNotification.class);
verify(m_clientNotificationReg).putTransactionalForAllNodes(notification.capture(), anyBoolean());
Set<Class<? extends ICodeType<?, ?>>> codeTypeClasses = ((CodeTypeCacheEntryFilter) notification.getValue().getFilter()).getCodeTypeClasses();
assertEquals("CodeType list in the notification size", 2, codeTypeClasses.size());
for (Class<? extends ICodeType<?, ?>> codeTypeClass : codeTypeClasses) {
assertTrue("CodeTypes not invalidated", codeTypeClass == SomeCodeType.class || codeTypeClass == DummyCodeType.class);
}
}
use of org.eclipse.scout.rt.shared.services.common.code.ICodeService in project scout.rt by eclipse.
the class CodeServiceTest method testReloadCodeTypes.
@Test
public void testReloadCodeTypes() {
ICodeService codeService = BEANS.get(ICodeService.class);
List<Class<? extends ICodeType<?, ?>>> list = new ArrayList<Class<? extends ICodeType<?, ?>>>();
list.add(SomeCodeType.class);
list.add(DummyCodeType.class);
codeService.reloadCodeTypes(list);
ArgumentCaptor<InvalidateCacheNotification> notification = ArgumentCaptor.forClass(InvalidateCacheNotification.class);
verify(m_clientNotificationReg).putTransactionalForAllNodes(notification.capture(), anyBoolean());
Set<Class<? extends ICodeType<?, ?>>> codeTypeClasses = ((CodeTypeCacheEntryFilter) notification.getValue().getFilter()).getCodeTypeClasses();
assertEquals("CodeType list in the notification size", 2, codeTypeClasses.size());
for (Class<? extends ICodeType<?, ?>> codeTypeClass : codeTypeClasses) {
assertTrue("CodeTypes not invalidated", codeTypeClass == SomeCodeType.class || codeTypeClass == DummyCodeType.class);
}
}
use of org.eclipse.scout.rt.shared.services.common.code.ICodeService in project scout.rt by eclipse.
the class CodeServiceTest method testReloadCodeType.
/**
* Tests that a client notification is created when reloading a code type {@link CodeService#reloadCodeType}
*/
@Test
public void testReloadCodeType() {
ICodeService codeService = BEANS.get(ICodeService.class);
codeService.reloadCodeType(SomeCodeType.class);
ArgumentCaptor<InvalidateCacheNotification> notification = ArgumentCaptor.forClass(InvalidateCacheNotification.class);
verify(m_clientNotificationReg).putTransactionalForAllNodes(notification.capture(), anyBoolean());
Set<Class<? extends ICodeType<?, ?>>> codeTypeClasses = ((CodeTypeCacheEntryFilter) notification.getValue().getFilter()).getCodeTypeClasses();
assertEquals("CodeType list in the notification size", 1, codeTypeClasses.size());
assertEquals("CodeType list(0) class", SomeCodeType.class, codeTypeClasses.iterator().next());
}
use of org.eclipse.scout.rt.shared.services.common.code.ICodeService in project scout.rt by eclipse.
the class CodeServiceTest method testInvlidateCodeType.
/**
* Tests that a client notification is created when invalidating a code type
* {@link CodeService#invalidateCodeType(Class)}
*/
@Test
public void testInvlidateCodeType() {
ICodeService codeService = BEANS.get(ICodeService.class);
codeService.getCodeType(SomeCodeType.class);
// verify that execLoadCodes has been invoked and reset flag, so that next execLoadCodes can be detected
assertTrue(SomeCodeType.EXEC_LOAD_CODES_INVOKED.getAndSet(false));
codeService.invalidateCodeType(SomeCodeType.class);
assertFalse(SomeCodeType.EXEC_LOAD_CODES_INVOKED.get());
// check notification
ArgumentCaptor<InvalidateCacheNotification> notification = ArgumentCaptor.forClass(InvalidateCacheNotification.class);
verify(m_clientNotificationReg).putTransactionalForAllNodes(notification.capture(), anyBoolean());
Set<Class<? extends ICodeType<?, ?>>> codeTypeClasses = ((CodeTypeCacheEntryFilter) notification.getValue().getFilter()).getCodeTypeClasses();
assertEquals("CodeType list in the notification size", 1, codeTypeClasses.size());
assertEquals("CodeType list(0) class", SomeCodeType.class, codeTypeClasses.iterator().next());
// get codetype manually
codeService.getCodeType(SomeCodeType.class);
assertTrue(SomeCodeType.EXEC_LOAD_CODES_INVOKED.get());
}
use of org.eclipse.scout.rt.shared.services.common.code.ICodeService in project scout.rt by eclipse.
the class CodeServiceTest method testInvlidateCodeTypeInDifferentTransactions.
@Test
public void testInvlidateCodeTypeInDifferentTransactions() {
final ICodeService codeService = BEANS.get(ICodeService.class);
// make sure code type is loaded
codeService.getCodeType(SomeCodeType.class);
// verify that execLoadCodes has been invoked and reset flag, so that next execLoadCodes can be detected
assertTrue(SomeCodeType.EXEC_LOAD_CODES_INVOKED.getAndSet(false));
// invalidate code type in another transaction
ServerRunContexts.copyCurrent().run(new IRunnable() {
@Override
public void run() throws Exception {
// invalidate code type
codeService.invalidateCodeType(SomeCodeType.class);
// verify that code type has not been loaded yet
assertFalse(SomeCodeType.EXEC_LOAD_CODES_INVOKED.get());
}
});
// verify that code type has not been loaded yet
assertFalse(SomeCodeType.EXEC_LOAD_CODES_INVOKED.get());
// load code type in another transaction
ServerRunContexts.copyCurrent().run(new IRunnable() {
@Override
public void run() throws Exception {
// invalidate code type
assertNotNull(codeService.getCodeType(SomeCodeType.class));
// verify that execLoadCodes has been invoked and reset flag, so that next execLoadCodes can be detected
assertTrue(SomeCodeType.EXEC_LOAD_CODES_INVOKED.getAndSet(false));
}
});
assertNotNull(codeService.getCodeType(SomeCodeType.class));
assertFalse(SomeCodeType.EXEC_LOAD_CODES_INVOKED.get());
}
Aggregations