log.info("---------------------------------");
String spec = TEST_COMPONENT;
String impl = TEST_COMPONENT_IMPL;
String var = "adBannerCmpVar";
YComponentInfo cmpInfo = null;
YComponentFactory cmpFac = new YComponentFactory();
// test various errors
int count = -1;
while (++count >= 0) {
String cmp = null;
Collection<ERROR_STATE> expected = null;
switch (count) {
case 0:
cmp = "<yf:component impl=\"" + impl + "\" spec=\"" + spec + "\" var=\"" + var
+ "\">";
expected = Arrays.asList(ERROR_STATE.VIEW_ID_NOT_SPECIFIED);
break;
case 1:
cmp = "<yf:component impl=\"" + impl + "\" >";
expected = Arrays.asList(ERROR_STATE.VIEW_ID_NOT_SPECIFIED,
ERROR_STATE.VIEW_VAR_NOT_SPECIFIED, ERROR_STATE.SPEC_IS_MISSING);
break;
case 2:
cmp = "<yf:component id=\"id\" impl=\"java.util.List\" var=\"var\">";
expected = Arrays.asList(ERROR_STATE.SPEC_IS_MISSING,
ERROR_STATE.IMPL_IS_INTERFACE, ERROR_STATE.IMPL_IS_NO_YCMP);
break;
case 3:
cmp = "<yf:component id=\"id\" impl=\"java.util.ArrayList\" var=\"var\">";
expected = Arrays.asList(ERROR_STATE.SPEC_IS_MISSING, ERROR_STATE.IMPL_IS_NO_YCMP);
break;
case 4:
cmp = "<yf:component id=\"id\" spec=\"java.util.List\" impl=\"java.util.ArrayList\" var=\"var\">";
expected = Arrays.asList(ERROR_STATE.SPEC_IS_NO_YCMP, ERROR_STATE.IMPL_IS_NO_YCMP);
break;
case 5:
cmp = "<yf:component id=\"id\" spec=\"java.util.ArrayList\" impl=\"java.util.ArrayList\" var=\"var\">";
expected = Arrays.asList(ERROR_STATE.SPEC_IS_NO_INTERFACE,
ERROR_STATE.SPEC_IS_NO_YCMP, ERROR_STATE.IMPL_IS_NO_YCMP);
break;
case 6:
cmp = "<yf:component id=\"id\" spec=\"java.util.Listxxx\" impl=\"java.util.ArrayListxxx\" var=\"var\">";
expected = Arrays.asList(ERROR_STATE.SPEC_NOT_LOADABLE,
ERROR_STATE.IMPL_NOT_LOADABLE);
break;
default:
count = -5;
}
if (count >= 0) {
log.info("Asserting: " + cmp);
log.info("Expecting: " + expected);
cmpInfo = cmpFac.createComponentInfo(cmp);
Set<ERROR_STATE> errors = cmpInfo.verifyComponent();
assertEquals(new HashSet<ERROR_STATE>(expected), errors);
}
}
}