Generate IllegalAccessException
I am testing an algorithm for StringSearch and the algorithm has many IllegalAccessExceptions in it.
I wanted to test that the code is working fine with the exceptions...and it is important also to test them as they call some functions when the exception occurs.
I just wanted to know how can i implicitly generate the exception.
I am trying to use the Java Security Manager but don't know how to use it to revoke the program's access to String class.
below is the code that I am testing:
#[code = java]
try {
int o = offset.getInt(text);
char[] t = (char[]) value.get(text);
return instance.searchChars(t, textStart + o, textEnd + o, getChars(pattern), processed) - o;
} catch (IllegalAccessException ex) {
synchronized (activeStringAccess) {
activeStringAccess = new StringAccess();
}
}
[/code]
in above code "offset.getInt(text)" generates the IllegalAccessException
I have tried to use MockIt but MockIt cannot mock the class for getInt i.e. Field.
Re: Generate IllegalAccessException
If you want more, then, your going to have to post more code. What type is "offset"?
On an unrelated note post code using the # [code=java][/code] tags for formatting and making the code easier to read.
Re: Generate IllegalAccessException
Quote:
Originally Posted by
aesguitar
If you want more, then, your going to have to post more code. What type is "offset"?
On an unrelated note post code using the
# [code=java][/code] tags for formatting and making the code easier to read.
The offset is of type Field.
Re: Generate IllegalAccessException
Re: Generate IllegalAccessException
Quote:
Originally Posted by
aesguitar
If you want more, then, your going to have to post more code. What type is "offset"?
On an unrelated note post code using the
# [code=java][/code] tags for formatting and making the code easier to read.
The text and pattern both are of type String