String staticName = "DTFJ_ARRAYLET_TEST_INSTANCE";
JavaClass candidateClass = _findClassForName("org/apache/kato/tests/scenarios/ArrayletTest");
if (null != candidateClass) {
int size = 0;
JavaObject container = null;
Iterator fields = candidateClass.getDeclaredFields().iterator();
try {
while (fields.hasNext()) {
JavaField field = (JavaField) fields.next();
String fieldName = field.getName();
if (fieldName.equals(staticSizeName)) {
size = field.getInt(null);
} else if (fieldName.equals(staticName)) {
container = (JavaObject) field.get(null);
}
}
//now ensure that we actually have something to test with
if ((0 != size) && (null != container)) {
//now, pull apart the fields of the container
JavaClass containerClass = container.getJavaClass();
Iterator theseFields = containerClass.getDeclaredFields().iterator();
while (theseFields.hasNext()) {
JavaField oneField = (JavaField) theseFields.next();
if (oneField.getName().equals("DTFJ_ARRAYLET_INTS")) {
//run the int test
JavaObject array = (JavaObject) oneField.get(container);
int remote[] = new int[size];
int whole[] = new int[size];
for (int i = 0; i < size; i++) {
array.arraycopy(i, remote, i, 1);
assertTrue(remote[i] == (size -i));
}
array.arraycopy(0, whole, 0, size);
assertTrue(Arrays.equals(whole, remote));
} else if (oneField.getName().equals("DTFJ_ARRAYLET_BYTES")) {
//run the byte test
JavaObject array = (JavaObject) oneField.get(container);
byte remote[] = new byte[size];
byte whole[] = new byte[size];
for (int i = 0; i < size; i++) {
array.arraycopy(i, remote, i, 1);
assertTrue(remote[i] == ((byte)(size -i)));
}
array.arraycopy(0, whole, 0, size);
assertTrue(Arrays.equals(whole, remote));
} else if (oneField.getName().equals("DTFJ_ARRAYLET_STRINGCONTAINER")) {
//run the byte test
JavaObject array = (JavaObject) oneField.get(container);
JavaObject whole[] = new JavaObject[size];
array.arraycopy(0, whole, 0, size);
JavaField stringField = null;
Iterator iter = whole[0].getJavaClass().getDeclaredFields().iterator();
while(iter.hasNext()) {
JavaField testField = (JavaField) iter.next();