for (int i=0; i < goodArgsList.length; i++) {
try {
logger.log(Level.FINEST, "Trying good args: {0}",
Arrays.asList(goodArgsList[i]));
NonActivatableServiceDescriptor tsd =
(NonActivatableServiceDescriptor)
cons.newInstance(goodArgsList[i]);
if (!checkMainArgs(goodArgsList[i], tsd)) {
throw new TestException(
"Failed -- check args");
}
if (!checkLifeCycle((LifeCycle)goodArgsList[i][5], tsd)) {
throw new TestException(
"Failed -- check LifeCycle");
}
if (!checkPreparer((ProxyPreparer)goodArgsList[i][6], tsd)) {
throw new TestException(
"Failed -- check ProxyPreparer");
}
} catch (Exception e) {
e.printStackTrace();
throw new TestException(
"Failed -- failed good args: ["
+ i + "] " + e);
}
}
// Excercise alternate constructor
consArgs = new Class[] {
String.class, String.class, String.class, String.class,
String[].class, LifeCycle.class};
cons =
NonActivatableServiceDescriptor.class.getConstructor(consArgs);
logger.log(Level.FINEST,
"Trying constructor that takes the following args: {0}",
Arrays.asList(consArgs));
//Test bad args
ArrayList list = new ArrayList();
for (int i=0; i < badArgsList.length; i++) {
try {
list.clear();
list.add(0, badArgsList[i][0]);
list.add(1, badArgsList[i][1]);
list.add(2, badArgsList[i][2]);
list.add(3, badArgsList[i][3]);
list.add(4, badArgsList[i][4]);
list.add(5, badArgsList[i][5]);
logger.log(Level.FINEST, "Trying bad args: {0}", list);
cons.newInstance(list.toArray());
throw new TestException(
"Failed -- took bad args: " + i);
} catch (java.lang.reflect.InvocationTargetException e) {
Throwable t = e.getCause();
if (t instanceof NullPointerException) {
logger.log(Level.FINEST,
"Got expected NullPointerException", t);
} else {
logger.log(Level.FINEST,
"Got unexpected Exception", t);
throw e;
}
}
}
for (int i=0; i < goodArgsList.length; i++) {
try {
list.clear();
list.add(0, goodArgsList[i][0]);
list.add(1, goodArgsList[i][1]);
list.add(2, goodArgsList[i][2]);
list.add(3, goodArgsList[i][3]);
list.add(4, goodArgsList[i][4]);
list.add(5, goodArgsList[i][5]);
logger.log(Level.FINEST, "Trying good args: {0}", list);
Object[] args = list.toArray();
NonActivatableServiceDescriptor tsd =
(NonActivatableServiceDescriptor)
cons.newInstance(args);
if (!checkMainArgs(args, tsd)) {
throw new TestException(
"Failed -- check args");
}
if (!checkLifeCycle((LifeCycle)args[5], tsd)) {
throw new TestException(
"Failed -- check args");
}
} catch (Exception e) {
e.printStackTrace();
throw new TestException(
"Failed -- failed good args: ["
+ i + "] " + e);
}
}
// Excercise another alternate constructor
consArgs = new Class[] {
String.class, String.class, String.class, String.class,
String[].class, ProxyPreparer.class};
cons =
NonActivatableServiceDescriptor.class.getConstructor(consArgs);
logger.log(Level.FINEST,
"Trying constructor that takes the following args: {0}",
Arrays.asList(consArgs));
//Test bad args
for (int i=0; i < badArgsList.length; i++) {
try {
list.clear();
list.add(0, badArgsList[i][0]);
list.add(1, badArgsList[i][1]);
list.add(2, badArgsList[i][2]);
list.add(3, badArgsList[i][3]);
list.add(4, badArgsList[i][4]);
list.add(5, badArgsList[i][6]);
logger.log(Level.FINEST, "Trying bad args: {0}", list);
cons.newInstance(list.toArray());
throw new TestException(
"Failed -- took bad args: " + i);
} catch (java.lang.reflect.InvocationTargetException e) {
Throwable t = e.getCause();
if (t instanceof NullPointerException) {
logger.log(Level.FINEST,
"Got expected NullPointerException", t);
} else {
logger.log(Level.FINEST,
"Got unexpected Exception", t);
throw e;
}
}
}
for (int i=0; i < goodArgsList.length; i++) {
try {
list.clear();
list.add(0, goodArgsList[i][0]);
list.add(1, goodArgsList[i][1]);
list.add(2, goodArgsList[i][2]);
list.add(3, goodArgsList[i][3]);
list.add(4, goodArgsList[i][4]);
list.add(5, goodArgsList[i][6]);
logger.log(Level.FINEST, "Trying good args: {0}", list);
Object[] args = list.toArray();
NonActivatableServiceDescriptor tsd =
(NonActivatableServiceDescriptor)
cons.newInstance(args);
if (!checkMainArgs(args, tsd)) {
throw new TestException(
"Failed -- check args");
}
if (!checkPreparer((ProxyPreparer)args[5], tsd)) {
throw new TestException(
"Failed -- check ProxyPreparer");
}
} catch (Exception e) {
e.printStackTrace();
throw new TestException(
"Failed -- failed good args: ["
+ i + "] " + e);
}
}
// Excercise another alternate constructor
consArgs = new Class[] {
String.class, String.class, String.class, String.class,
String[].class};
cons =
NonActivatableServiceDescriptor.class.getConstructor(consArgs);
logger.log(Level.FINEST,
"Trying constructor that takes the following args: {0}",
Arrays.asList(consArgs));
//Test bad args
for (int i=0; i < badArgsList.length; i++) {
try {
list.clear();
list.add(0, badArgsList[i][0]);
list.add(1, badArgsList[i][1]);
list.add(2, badArgsList[i][2]);
list.add(3, badArgsList[i][3]);
list.add(4, badArgsList[i][4]);
logger.log(Level.FINEST, "Trying bad args: {0}", list);
cons.newInstance(list.toArray());
throw new TestException(
"Failed -- took bad args: " + i);
} catch (java.lang.reflect.InvocationTargetException e) {
Throwable t = e.getCause();
if (t instanceof NullPointerException) {
logger.log(Level.FINEST,
"Got expected NullPointerException", t);
} else {
logger.log(Level.FINEST,
"Got unexpected Exception", t);
throw e;
}
}
}
for (int i=0; i < goodArgsList.length; i++) {
try {
list.clear();
list.add(0, goodArgsList[i][0]);
list.add(1, goodArgsList[i][1]);
list.add(2, goodArgsList[i][2]);
list.add(3, goodArgsList[i][3]);
list.add(4, goodArgsList[i][4]);
logger.log(Level.FINEST, "Trying good args: {0}", list);
NonActivatableServiceDescriptor tsd =
(NonActivatableServiceDescriptor)
cons.newInstance(list.toArray());
if (!checkMainArgs(list.toArray(), tsd)) {
throw new TestException(
"Failed -- check args");