input
stringlengths
10
828
output
stringlengths
5
107
private int find resource xaresource xa res a linear search may seem slow but please note that the number of xa resources registered with a transaction are usually low note this searches backwards intentionally it ensures that if this resource was enlisted multiple times then the last one will be returned all others should be in the state rs ended this allows resource managers that always return false from is same rm to be enlisted and delisted multiple times for int idx resource count 1 idx 0 idx if xa res resources idx return idx return 1
return index of xaresource or code 1 code if not found
public void check notification id timer notification p notification integer p notification id if p notification null fail notification is null if p notification get notification id equals p notification id fail wrong notification id received p notification get notification id expected p notification id
checks if the given notification id is the same as the
private long calc time long offset return system current time millis offset
calculate the time using an offset from the current time
public void test invoke qualified unqualified invoke property 1 my domain property 1
test invoke qualified unqualifed
private void update role role role array list old role value roles put role get role name role try check service proxy service proxy update role map relation id role old role value service proxy send role update notification relation id role old role value catch exception e throw new runtime exception e to string
update the role
public void test integer throws exception value exp one query value 10 value exp two query value 20 value exp div query value 2 value exp minus query value 10 value exp mult query value 200 value exp plus query value 30 equals test one two operation test one two div minus mult plus comparison test one two between test one two plus attr test new number test 10 query attr number one two attr test new number test 10 query attr number test class get name number one two in test one two div minus mult plus
test a int
public void test default notification filter support nfs new notification filter support assert equals false nfs is notification enabled n1 assert equals false nfs is notification enabled n2 assert equals false nfs is notification enabled n3 assert equals false nfs is notification enabled n4 assert equals false nfs is notification enabled n5
by default all types are disabled
public void test string constructor object instance instance null try instance new object instance test type test class name catch exception e fail e to string did it work assert equals test type test instance get object name to string assert equals class name instance get class name
test string constructor
public void test object name constructor object instance instance null object name object name null try object name new object name type test instance new object instance object name class name catch exception e fail e to string did it work assert equals object name instance get object name assert equals class name instance get class name
test object name constructor
public void test enable type notification filter support nfs new notification filter support nfs enable type type1plus assert equals false nfs is notification enabled n1 assert equals false nfs is notification enabled n2 assert equals true nfs is notification enabled n3 assert equals false nfs is notification enabled n4 assert equals false nfs is notification enabled n5
enable a single type all others should be disabled
public void test invoke unqualified unqualified invoke property 1 property 1
test invoke unqualified unqualified
public void test disable all types notification filter support nfs new notification filter support nfs enable type type1 nfs enable type type2 nfs disable all types assert equals false nfs is notification enabled n1 assert equals false nfs is notification enabled n2 assert equals false nfs is notification enabled n3 assert equals false nfs is notification enabled n4 assert equals false nfs is notification enabled n5
enable some types then disable everyting
public void test disable type notification filter support nfs new notification filter support nfs enable type type1 nfs enable type type2 nfs disable type type1 assert equals false nfs is notification enabled n1 assert equals false nfs is notification enabled n2 assert equals false nfs is notification enabled n3 assert equals true nfs is notification enabled n4 assert equals true nfs is notification enabled n5
enable some types the disable one of them
public void test prefix notification filter support nfs new notification filter support nfs enable type type1 assert equals true nfs is notification enabled n1 assert equals true nfs is notification enabled n2 assert equals true nfs is notification enabled n3 assert equals false nfs is notification enabled n4 assert equals false nfs is notification enabled n5
enable a prefix that matched multiple types
public void test add nlunqualified name listener register qualified add nlname listener my domain property 1 property 1
add notification listenter
public void test long throws exception value exp one query value 10l value exp two query value 20l value exp div query value 2l value exp minus query value 10l value exp mult query value 200l value exp plus query value 30l equals test one two operation test one two div minus mult plus comparison test one two between test one two plus attr test new number test 10l query attr number one two attr test new number test 10l query attr number test class get name number one two in test one two div minus mult plus
test a long
public void test add nlqualified name listener register unqualified add nlname listener property 1 my domain property 1
add notification listenter
public void test add nlunqualified name listener register unqualified add nlname listener property 1 property 1
add notification listenter
public void test add nlunqualified qualified register unqualified qualified add nlname name property 1 my domain property 2 property 1 my domain property 2
add notification listenter
public void test add nlunqualified qualified register qualified qualified add nlname name property 1 my domain property 2 my domain property 1 my domain property 2
add notification listenter
public void test add nlqualified qualified register unqualified qualified add nlname name my domain property 1 my domain property 2 property 1 my domain property 2
add notification listenter
public void test add nlqualified unqualified register qualified unqualified add nlname name my domain property 1 property 2 my domain property 1 property 2
add notification listenter
private void do before completion unlock try for int i 0 i sync count i try if trace log trace calling sync i sync i end of if sync i before completion catch throwable t if trace log trace failed before completion t status status status marked rollback save the cause off so the user can inspect it cause t break finally lock
call synchronization code before completion code
public void test and true both throws exception new query test new mbean new mbean new number test 0 domain1 type instance1 new mbean 0 query and query eq query value 10 query value 10 query eq query value hello query value hello test
test and is true both
public void test add nlqualified unqualified register qualified qualified add nlname name my domain property 1 property 2 my domain property 1 my domain property 2
add notification listenter
public void test add nlqualified qualified register qualified unqualified add nlname name my domain property 1 my domain property 2 my domain property 1 property 2
add notification listenter
public void test and false first throws exception new query test new mbean 0 new mbean new mbean new number test 0 domain1 type instance1 query and query eq query value 10 query value 20 query eq query value hello query value hello test
test and is false first parameter
private void do after completion assert status indicates too late to add new synchronizations unlock try for int i 0 i sync count i try sync i after completion status catch throwable t if trace log trace failed after completion t finally lock
call synchronization code after completion code
public void test and false second throws exception new query test new mbean 0 new mbean new mbean new number test 0 domain1 type instance1 query and query eq query value 10 query value 10 query eq query value hello query value goodbye test
test and is false second parameter
private void add nlname listener string register string test mbean server server null object name register name null object name test name null try server mbean server factory create mbean server my domain register name new object name register test name new object name test server register mbean new broadcaster register name catch exception e fail e to string try server add notification listener test name new relation service true null null catch exception e fail e to string if server null mbean server factory release mbean server server
add notification listenter
public void test and false both throws exception new query test new mbean 0 new mbean new mbean new number test 0 domain1 type instance1 query and query eq query value 10 query value 20 query eq query value hello query value goodbye test
test and is false both parameters
public void test or true both throws exception new query test new mbean new mbean new number test 0 domain1 type instance1 new mbean 0 query or query eq query value 10 query value 10 query eq query value hello query value hello test
test or is true both
public void test or false first throws exception new query test new mbean new mbean new number test 0 domain1 type instance1 new mbean 0 query or query eq query value 10 query value 20 query eq query value hello query value hello test
test or is false first parameter
public void test or false second throws exception new query test new mbean 0 new mbean new mbean new number test 0 domain1 type instance1 query and query eq query value 10 query value 10 query eq query value hello query value goodbye test
test or is false second parameter
public void test or false both throws exception new query test new mbean 0 new mbean new mbean new number test 0 domain1 type instance1 query or query eq query value 10 query value 20 query eq query value hello query value goodbye test
test or is false both parameters
public void test class attribute throws exception new query test new mbean new mbean new number test 0 domain1 type instance1 new mbean new mbean new trivial domain1 type instance2 query eq query classattr query value number test class get name test
test class attribute
private xid create xid branch long branch id last branch id return xid factory new branch xid branch id
create an xid representing a new branch of this transaction
public void test instantiate with default constructor throws exception mbean server server mbean server factory new mbean server object o server instantiate test compliance server support test assert true o instanceof test compliance server support test
tests instantiate string class name
private boolean is one resource if resource count 1 return true first xaresource surely has 1 it s the first for int i 1 i resource count i if resource same rm i 1 this one is not the same rm as previous ones there must be at least 2 return false all rms are the same one one phase commit is ok return true
check if we can do one phase optimization
public void test instantiate with default constructor and application exception throws exception try mbean server server mbean server factory new mbean server object o server instantiate test compliance server support constructor test shouldn t get here fail instantiate should have thrown an mbean exception catch mbean exception e this is expected
tests instantiate string class name with constructor that throws a checked application exception
public void test instantiate with default constructor and runtime exception throws exception try mbean server server mbean server factory new mbean server object o server instantiate test compliance server support constructor test2 shouldn t get here fail instantiate should have thrown a runtime mbean exception catch runtime mbean exception e this is expected
tests instantiate string class name with constructor that throws an unchecked application exception
public void test instantiate with default constructor and error throws exception try mbean server server mbean server factory new mbean server object o server instantiate test compliance server support constructor test3 shouldn t get here fail instantiate should have thrown a runtime error exception catch runtime error exception e this is expected
tests instantiate string class name with constructor that throws an error
public void test descriptor support default constructor try descriptor d1 new descriptor support catch assertion failed error e throw e catch throwable t fail unexpected error t to string
tests the tt descriptor support tt default constructor
public void test descriptor support copy constructor try descriptor support d1 new descriptor support d1 set field foo bar d1 set field wombat new integer 666 descriptor support d2 new descriptor support d1 assert true d2 get field value foo equals bar assert true d2 get field value wombat equals new integer 666 descriptor support d4 null descriptor support d3 new descriptor support d4 catch assertion failed error e throw e catch throwable t t print stack trace fail unexpected error t to string
tests the tt descriptor support tt copy constructor
public void test match question beginning throws exception new query test new mbean new mbean new string test hello domain1 type instance1 new mbean new string test hello domain1 type instance2 new mbean new string test ello domain1 type instance3 new mbean new mbean new string test ello domain2 type instance1 new mbean new string test ello domain2 type instance2 new mbean new string test hhello domain2 type instance3 query match query attr string query value ello test
test match question beginning
public void test different for int i 0 i types length 1 i for int j i 1 j types length j if types i equals types j fail relation notifications types not unique
make sure all the constants are different
public void test instantiate with default constructor and unknown class throws exception try mbean server server mbean server factory new mbean server object o server instantiate foo bar should not get here fail instantiate should have thrown a reflection exception catch reflection exception e this is expected assert true e get target exception instanceof class not found exception
tests instantiate string class name with unfound class
public void test different for int i 0 i statii length 1 i for int j i 1 j statii length j if statii i statii j fail role status constants are not unique
make sure all the constants are different
public void test role status role status test new role status for int i 0 i statii length i if test is role status statii i false fail statii desc is not a role status
make sure all the constants are accepted
public void test instantiate with missing default constructor throws exception try mbean server server mbean server factory new mbean server object o server instantiate test compliance server support constructor test6 should not get here fail instantiate should have thrown a reflection exception catch reflection exception e this is expected
tests instantiate string class name with class that doesnt have a default constructor
public void test basic constructor set up roles array list roles new array list roles add role1 roles add role2 role list full new role list roles assert equals 2 full size assert equals role1 full get 0 assert equals role2 full get 1 iterator iterator full iterator assert equals role1 iterator next assert equals role2 iterator next
basic constructor test
public void test basic constructor ordering set up roles array list roles new array list roles add role2 roles add role1 role list full new role list roles assert equals 2 full size assert equals role2 full get 0 assert equals role1 full get 1 iterator iterator full iterator assert equals role2 iterator next assert equals role1 iterator next
basic constructor test ordering
public void test basic constructor set up role unresolveds array list role unresolveds new array list role unresolveds add role unresolved1 role unresolveds add role unresolved2 role unresolved list full new role unresolved list role unresolveds assert equals 2 full size assert equals role unresolved1 full get 0 assert equals role unresolved2 full get 1 iterator iterator full iterator assert equals role unresolved1 iterator next assert equals role unresolved2 iterator next
basic constructor test
public void test instantiate with inaccessible no args constructor throws exception try mbean server server mbean server factory new mbean server object o server instantiate test compliance server support constructor test7 should not get here fail instantiate should have thrown a reflection exception catch reflection exception e this is expected
tests instantiate string class name with protected no access no args constructor
public void test basic constructor duplicates set up roles check duplicates allowed array list roles new array list roles add role1 roles add role1 role list full new role list roles assert equals 2 full size assert equals role1 full get 0 assert equals role1 full get 1 iterator iterator full iterator assert equals role1 iterator next assert equals role1 iterator next
basic constructor test allows duplicates
public void test basic constructor ordering set up role unresolveds array list role unresolveds new array list role unresolveds add role unresolved2 role unresolveds add role unresolved1 role unresolved list full new role unresolved list role unresolveds assert equals 2 full size assert equals role unresolved2 full get 0 assert equals role unresolved1 full get 1 iterator iterator full iterator assert equals role unresolved2 iterator next assert equals role unresolved1 iterator next
basic constructor test ordering
public void test basic constructor duplicates set up role unresolveds check duplicates allowed array list role unresolveds new array list role unresolveds add role unresolved1 role unresolveds add role unresolved1 role unresolved list full new role unresolved list role unresolveds assert equals 2 full size assert equals role unresolved1 full get 0 assert equals role unresolved1 full get 1 iterator iterator full iterator assert equals role unresolved1 iterator next assert equals role unresolved1 iterator next
basic constructor test allows duplicates
public void test instantiate with null class name throws exception try mbean server server mbean server factory new mbean server object o server instantiate null should not reach here fail incorrect exception behavior catch runtime operations exception e expected check that it wraps iae assert true e get target exception instanceof illegal argument exception
tests instantiate string class name with null class name
public void test delegate constructor mbean server server create mbean server object name service create relation service test type service null create roles b null relation support support null try support new relation support id service server relation type b roles b catch exception e fail e to string assert equals id support get relation id assert equals relation type b support get relation type name assert equals test type service support get relation service name to string role list role list support retrieve all roles compare roles b role list
test the delegate constructor
public void test creation removal errors2 relation notification rn null object name object name null try object name new object name a a catch exception e fail e to string array list unregs new array list boolean caught false try rn new relation notification null new relation service true 21 23 message relation id relation type name object name unregs catch null pointer exception e fail fails in ri throws the wrong exception type catch illegal argument exception e caught true catch exception e fail e to string if caught false fail creation removal accepts an a null type
test creation removal error handling
public void test instantiate with empty class name throws exception try mbean server server mbean server factory new mbean server object o server instantiate should not reach here fail incorrect exception classloading behavior catch reflection exception e expected check that it wraps cnfe assert true e get target exception instanceof class not found exception
tests instantiate string class name with empty class name string
public void test escaping asterisk throws exception new query test new mbean new mbean new string test hello domain1 type instance1 new mbean new mbean new string test helloz domain2 type instance1 query match query attr string query value hello test
test match escaping asterisk
public void test get referenced mbeans not registered mbean server server create mbean server object name service create relation service test type service null create relation type c service create roles c server map result null try relation support support new relation support id service server relation type c roles c result support get referenced mbeans catch exception e fail e to string check mbeans result roles c
test get referenced mbeans when not registered in service
public void test get referenced mbeans when registered mbean server server create mbean server object name service create relation service test type service server create relation type c service create roles c server map result null try relation support support new relation support id service server relation type c roles c add relation server service support test type support result support get referenced mbeans catch exception e fail e to string check mbeans result roles c
test get referenced mbeans when registered in service
public void test escaping open bracket throws exception new query test new mbean new mbean new string test hello ab domain1 type instance1 new mbean new mbean new string test helloa domain2 type instance1 new mbean new string test hello a domain2 type instance2 query match query attr string query value hello ab test
test match escaping open bracket
public void test instantiate with null class name2 throws exception try mbean server server mbean server factory new mbean server object o server instantiate null null should not reach here fail incorrect exception behavior catch runtime operations exception e expected check that it wraps iae assert true e get target exception instanceof illegal argument exception
tests instantiate string class name object name loader with null class name
public void test constructor try mbean feature info info new mbean feature info name this is a description assert true info get name equals name assert true info get description equals this is a description catch assertion failed error e throw e catch throwable t t print stack trace fail unexpected error t to string
tests tt mbean operation info string descr method m tt constructor
public void test get role cardinality unregistered mbean server server create mbean server object name service create relation service test type service null create roles c null integer result null relation support support null try support new relation support id service server relation type c roles c result support get role cardinality role c1 catch exception e fail e to string assert equals 2 result int value try result support get role cardinality role c2 catch exception e fail e to string assert equals 3 result int value
test get role cardinality when not registered
public void test minus in character set throws exception try new query test new mbean new mbean new string test hello domain1 type instance1 new mbean new mbean new string test hello ab domain2 type instance1 query match query attr string query value hello ab test catch assertion failed error e fail fails in ri expected hello to match hello ab
test match minus in character set
public void test constructor throws exception relation service rs null rs new relation service true assert equals true rs get purge flag rs new relation service false assert equals false rs get purge flag
test the constructor
public void test constructor with method try class c this get class method m c get method test constructor with method new class 0 mbean operation info info new mbean operation info this is a description m assert true info get description equals this is a description assert true info get name equals m get name assert true info get return type equals void assert true info get signature length 0 assert true info get impact mbean operation info unknown catch assertion failed error e throw e catch throwable t t print stack trace fail unexpected error t to string
tests tt mbean operation info string descr method m tt constructor
public void test instantiate with empty class name2 throws exception try mbean server server mbean server factory new mbean server object o server instantiate null should not reach here fail incorrect exception classloading behavior catch reflection exception e expected check that it wraps cnfe assert true e get target exception instanceof class not found exception
tests instantiate string class name object name loader with empty class name string
public void test relation service flag mbean server server create mbean server object name service create relation service test type service null create roles b null relation support support null try support new relation support id service server relation type b roles b catch exception e fail e to string assert equals false support is in relation service boolean value support set relation service management flag new boolean true assert equals true support is in relation service boolean value support set relation service management flag new boolean false assert equals false support is in relation service boolean value
test relation service flag
public void test instantiate with null class name3 throws exception try mbean server server mbean server factory new mbean server object o server instantiate null null null should not reach here fail incorrect exception behavior catch runtime operations exception e expected check that it wraps iae assert true e get target exception instanceof illegal argument exception
tests instantiate string class name object args string sign with null
public void test retrieve all roles un registered mbean server server create mbean server object name service create relation service test type service null create roles b null role list result null try relation support support new relation support id service server relation type b roles b result support retrieve all roles catch exception e fail e to string compare roles b result
test retrieve all roles when unregistered
public void test instantiate with empty class name3 throws exception try mbean server server mbean server factory new mbean server object o server instantiate null null should not reach here fail incorrect exception classloading behavior catch reflection exception e expected check that it wraps cnfe assert true e get target exception instanceof class not found exception
tests instantiate string class name object args string sign with
public void test instantiate with null class name4 throws exception try mbean server server mbean server factory new mbean server object o server instantiate null null null null should not reach here fail incorrect exception behavior catch runtime operations exception e expected check that it wraps iae assert true e get target exception instanceof illegal argument exception
tests instantiate string class name object name loader object args string sign
public void test instantiate with empty class name4 throws exception try mbean server server mbean server factory new mbean server object o server instantiate null null null should not reach here fail incorrect exception classloading behavior catch reflection exception e expected check that it wraps cnfe assert true e get target exception instanceof class not found exception
tests instantiate string class name object name loader object args string sign
public void test instantiate with default loader repository throws exception note the urls used here are relative to the location of the build xml mbean server server mbean server factory new mbean server mlet mlet new mlet mlet cl to dlr mlet add url file output etc test compliance server test jar server register mbean mlet new object name test test try object o server instantiate test compliance server support aclass catch exception e fail fails in elbamx ulr3 loads from tcl should be dlr assert true o get class get class loader equals mlet
tests instantiate string class name classloading behaviour
public void set phone numbers string numbers this numbers numbers
describe code set phone numbers code method here
public string print info return user get name n address get address n phone get phone numbers 0 n phone get phone numbers 1 n phone get phone numbers 2 n
describe code print info code method here
public void test register null object name boolean caught false try mbean server server mbean server factory new mbean server server register mbean new test null catch runtime operations exception e if e get target exception instanceof illegal argument exception caught true else fail wrong wrapped exception e get target exception catch exception e fail e to string if caught false fail allowed to register with a null object name
tests registering with null object name
public void add phone number string number for int i 0 i numbers length i if numbers i null numbers i number break
describe code add phone number code method here
public void remove phone number int index if index 0 index numbers length return numbers index null
describe code remove phone number code method here
public void test register pattern object name boolean caught false try mbean server server mbean server factory new mbean server server register mbean new test new object name domai type test catch runtime operations exception e if e get target exception instanceof illegal argument exception caught true else fail wrong wrapped exception e get target exception catch exception e fail e to string if caught false fail allowed to register with a pattern object name
tests registering with a pattern object name
private void stop timer timer remove all notifications timer stop
stop the timer does a small wait to avoid problems with the ri
private integer add notification long offset long period long occurs return timer add notification timer type message user data time offset offset period occurs
add a notification
public void test create relation throws exception mbean server server mbean server factory create mbean server try object name service create relation service test type service server create relation type b service create roles b server relation support support null listener listener new listener relation notification relation basic creation relation service rs relation service services get service server add notification listener service listener null null rs create relation id relation type b roles b boolean result rs has relation id boolean value assert equals true result listener check 1 finally mbean server factory release mbean server server
test create relation
public void test register jmimplementation object name boolean caught false try mbean server server mbean server factory new mbean server server register mbean new test new object name jmimplementation type test catch runtime operations exception e if e get target exception instanceof illegal argument exception caught true else fail wrong wrapped exception e get target exception catch exception e fail e to string if caught false fail allowed to register into jmimplementation
tests registering into jmimplementation
public dynamic mbean get mbean return invoker
retrieve the invoker for the mbean
public string get resource class name return resource class name
retrieve the class name for the mbean
public object get resource instance return resource
retrieve the mbean
public void test register jmimplementation default domain object name boolean caught false try mbean server server mbean server factory new mbean server jmimplementation server register mbean new test new object name type test catch runtime operations exception e if e get target exception instanceof illegal argument exception caught true else fail wrong wrapped exception e get target exception catch exception e fail e to string if caught false fail allowed to register into jmimplementation
tests registering into jmimplementation using default domain
public class loader get class loader return cl
retrieve the context class loader with which to invoke the mbean
public object get value string key if value map null return value map get key return null
retrieve a value from the map
public void test register mbean on exception from pre register throws exception mbean server server mbean server factory new mbean server object name name new object name test foo bar try server register mbean new test2 name should not reach here fail test2 registered despite of throwing an exception from the pre register method catch mbean registration exception e expected assert true server is registered name assert true e get target exception instanceof java lang runtime exception catch runtime mbean exception e fail fails in ri runtime mbean exception instead of mbean registration exception
tests register for an mbean that throws unchecked exception from pre register
protected boolean domain matches string src string pat if src equals no point doing more that we have to return true return domain matches src to char array 0 pat to char array 0
compare the src and pat strings where and chars are significant
public void test register mbean on exception from pre register2 throws exception mbean server server mbean server factory new mbean server object name name new object name test foo bar try server register mbean new test3 name should not reach here fail test3 registered despite of throwin an exception from the pre register method catch mbean registration exception e expected assert true server is registered name assert true e get target exception instanceof my screaming exception
tests register for an mbean that throws checked exception from pre register
public void test register mbean on exception from pre register3 throws exception mbean server server mbean server factory new mbean server object name name new object name test foo bar try server register mbean new test4 name should not reach here fail test4 registered despite of throwing an exception from the pre register method catch mbean registration exception e expected assert true server is registered name assert true e get target exception instanceof my screaming exception
tests register for an mbean that throws an mbean registration exception from
protected object name qualify name object name name if name null throw new runtime operations exception new illegal argument exception null object name try if name get domain length 0 return new object name default domain name get canonical key property list string else return name catch malformed object name exception e throw new runtime operations exception new illegal argument exception e to string
qualify an object name with the default domain p