use of com.mvp4g.rebind.config.element.LoaderElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testChildModuleLoaders.
@Test
public void testChildModuleLoaders() throws InvalidMvp4gConfigurationException {
setEventBus();
oracle.addClass(Loaders.Loader1.class);
oracle.addClass(Loaders.Loader2.class);
oracle.addClass(Modules.ModuleWithLoader.class);
oracle.addClass(Modules.ModuleWithSameLoader1.class);
oracle.addClass(Modules.ModuleWithSameLoader2.class);
oracle.addClass(Modules.Module01.class);
ChildModuleElement withLoader = new ChildModuleElement();
withLoader.setName("withLoader");
withLoader.setClassName(Modules.ModuleWithLoader.class.getCanonicalName());
childModules.add(withLoader);
ChildModuleElement withSameLoader1 = new ChildModuleElement();
withSameLoader1.setName("withSameLoader1");
withSameLoader1.setClassName(Modules.ModuleWithSameLoader1.class.getCanonicalName());
childModules.add(withSameLoader1);
ChildModuleElement withSameLoader2 = new ChildModuleElement();
withSameLoader2.setName("withSameLoader2");
withSameLoader2.setClassName(Modules.ModuleWithSameLoader2.class.getCanonicalName());
childModules.add(withSameLoader2);
ChildModuleElement noLoader = new ChildModuleElement();
noLoader.setName("noLoader");
noLoader.setClassName(Modules.Module01.class.getCanonicalName());
childModules.add(noLoader);
configuration.findChildModuleHistoryNameAndLoader();
String loader1Name = "loader" + Loaders.Loader1.class.getCanonicalName().replace(".", "_");
String loader2Name = "loader" + Loaders.Loader2.class.getCanonicalName().replace(".", "_");
assertEquals(loader1Name, withLoader.getLoader());
assertEquals(loader2Name, withSameLoader1.getLoader());
assertEquals(loader2Name, withSameLoader2.getLoader());
assertNull(noLoader.getLoader());
Set<LoaderElement> loaders = configuration.getLoaders();
assertEquals(2, loaders.size());
Iterator<LoaderElement> it = loaders.iterator();
LoaderElement next;
String name;
while (it.hasNext()) {
next = it.next();
name = next.getName();
if (name.equals(loader1Name)) {
assertEquals(Loaders.Loader1.class.getCanonicalName(), next.getClassName());
} else if (name.equals(loader2Name)) {
assertEquals(Loaders.Loader2.class.getCanonicalName(), next.getClassName());
} else {
fail("Unknown loader " + next.getName());
}
}
}
use of com.mvp4g.rebind.config.element.LoaderElement in project mvp4g by mvp4g.
the class Mvp4gConfigurationTest method testSplitterLoaders.
@Test
public void testSplitterLoaders() throws InvalidMvp4gConfigurationException {
setEventBus();
oracle.addClass(Loaders.Loader1.class);
oracle.addClass(Loaders.Loader2.class);
oracle.addClass(Splitters.SplitterWithLoader.class);
oracle.addClass(Splitters.SplitterWithSameLoader1.class);
oracle.addClass(Splitters.SplitterWithSameLoader2.class);
PresenterElement presenter1 = newPresenter(SimplePresenter01.class, "presenter1");
presenter1.setAsync(Splitters.SplitterWithLoader.class.getCanonicalName());
presenters.add(presenter1);
PresenterElement presenter2 = newPresenter(SimplePresenter02.class, "presenter2");
presenter2.setAsync(Splitters.SplitterWithSameLoader1.class.getCanonicalName());
presenters.add(presenter2);
PresenterElement presenter3 = newPresenter(SimplePresenter03.class, "presenter3");
presenter3.setAsync(Splitters.SplitterWithSameLoader2.class.getCanonicalName());
presenters.add(presenter3);
EventElement event = new EventElement();
event.setHandlers(new String[] { "presenter1", "presenter2", "presenter3" });
configuration.getEvents().add(event);
configuration.validateSplitters();
assertEquals(3, configuration.getSplitters().size());
String loader1Name = "loader" + Loaders.Loader1.class.getCanonicalName().replace(".", "_");
String loader2Name = "loader" + Loaders.Loader2.class.getCanonicalName().replace(".", "_");
String splitter1Name = Splitters.SplitterWithLoader.class.getCanonicalName().replace(".", "_");
String splitter2Name = Splitters.SplitterWithSameLoader1.class.getCanonicalName().replace(".", "_");
String splitter3Name = Splitters.SplitterWithSameLoader2.class.getCanonicalName().replace(".", "_");
Set<SplitterElement> splitters = configuration.getSplitters();
Iterator<SplitterElement> itSplitter = splitters.iterator();
SplitterElement splitter;
String splitterName;
while (itSplitter.hasNext()) {
splitter = itSplitter.next();
splitterName = splitter.getName();
if (splitter1Name.equals(splitterName)) {
assertEquals(splitter.getLoader(), loader1Name);
} else if (splitter2Name.equals(splitterName)) {
assertEquals(splitter.getLoader(), loader2Name);
} else if (splitter3Name.equals(splitterName)) {
assertEquals(splitter.getLoader(), loader2Name);
} else {
fail("Unknown splitter " + splitterName);
}
}
Set<LoaderElement> loaders = configuration.getLoaders();
assertEquals(2, loaders.size());
Iterator<LoaderElement> it = loaders.iterator();
LoaderElement next;
String name;
while (it.hasNext()) {
next = it.next();
name = next.getName();
if (name.equals(loader1Name)) {
assertEquals(Loaders.Loader1.class.getCanonicalName(), next.getClassName());
} else if (name.equals(loader2Name)) {
assertEquals(Loaders.Loader2.class.getCanonicalName(), next.getClassName());
} else {
fail("Unknown loader " + next.getName());
}
}
}
Aggregations