input
stringlengths
10
828
output
stringlengths
5
107
public void set encoding match range int encoding match range this encoding match range encoding match range
override the default max encoding match range
protected void visit article cu cached url cu if log is debug3 log debug3 visit cu article files res create article files cu if res null emit article files res
invoked on each cached url for which is article cu returns true should
protected article files create article files cached url cu article files res new article files res set full text cu cu return res
default implementation creates an article files with the full text cu
protected void check title kbart title title assert not null title check it has essential fields assert false title get field field title id equals assert not null title get field field print identifier assert false title get field field print identifier equals assert not null title get field field online identifier assert false title get field field online identifier equals no field should be null though they may be empty for field f kbart title field values assert not null title get field f
a callback for the exporter instance
public void test find volume string vol volume 221 b try tdb title title tdb test util make volume test title vol for tdb au au title get tdb aus string found vol kbart tdb au util find volume au assert not null found vol the return should be a non empty string with the correct value assert false au volume not found found vol equals assert true au wrong volume found found vol found vol equals vol catch tdb exception e fail exception encountered in test find volume e return
the aus property maps are searched for the following in the order given
public boolean is active au archival unit au string auid au get au id return auid null au map get auid au
return true iff the au is currently active
private boolean should output title kbart title title kbart export filter filter does this filter include a field which differs between the titles boolean titles differ collection util is disjoint differing fields filter get visible field order are range field included in the output boolean range fields included collection util is disjoint field range fields filter get visible field order are id field included in the output boolean id fields included collection util is disjoint field id fields filter get visible field order return title title1 titles differ range fields included range fields included id fields included
decide if the title should be shown under this filter
public void register au event handler au event handler aueh log debug2 registering au event handler aueh if au event handlers contains aueh au event handlers add aueh
register a handler for au events create delete reconfigure
public void test get issn assert equals p issn bib item1 get issn bibliographic item impl bib item1 set eissn e issn assert equals e issn bib item1 get issn bibliographic item impl bib item1 set issn l issn l assert equals issn l bib item1 get issn
issn should be the preferred available issn
public void test volume year issue setters set a new volume year issue string and see that the start and end change bibliographic item impl bib item2 set volume volume2 assert equals s vol2 bib item2 get start volume assert equals e vol2 bib item2 get end volume bibliographic item impl bib item2 set year year2 assert equals s year2 bib item2 get start year assert equals e year2 bib item2 get end year bibliographic item impl bib item2 set issue issue2 assert equals s issue2 bib item2 get start issue assert equals e issue2 bib item2 get end issue
setting the volume year or issue strings should affect the start and end
public void test to string string s fake id to string assert true s equals string fake id m id key
test for method to string
public void test remember active xxx stubbed for v3 if test msg instanceof v1 lcap message long inc pkts fake id m incr packets long tot pkts fake id m total packets fake id remember active false test msg assert equals inc pkts 1 fake id m incr packets assert equals tot pkts 1 fake id m total packets string verifier string value of b64 code encode v1 lcap message test msg get verifier integer cnt integer fake id m pkts this interval get verifier assert not null cnt assert equals 1 cnt int value
test for method remember active
public void test remember valid originator long val originator fake id m orig packets fake id remember valid originator test msg assert equals val originator 1 fake id m orig packets
test for method remember valid originator
public void test remember valid forward long val forward fake id m forw packets fake id remember valid forward test msg assert equals val forward 1 fake id m forw packets
test for method remember valid forward
public void test remember duplicate long duplicates fake id m dupl packets fake id remember duplicate test msg assert equals duplicates 1 fake id m dupl packets
test for method remember duplicate
private void assert valid proportion float val assert true val 0 assert true val 1
check that the given value represents a valid proportion that is
public void start service super start service configure current config get current config start
start the comm manager
public void stop service todo checkpoint here stop super stop service
stop the comm manager
public void send lockss datagram ld archival unit au throws ioexception if multi port 0 throw new illegal state exception multicast port not configured if group null throw new illegal state exception multicast group not configured send to ld group multi port
multicast a message to all caches holding the archival unit
public void test valid method invocation psm method msg action foo action new psm method msg action my action handlers class handle foo psm method msg action bar action new psm method msg action my action handlers class handle bar psm event foo return foo action run arg event null psm event bar return bar action run arg event null assert same foo return foo event assert same bar return bar event
ensure that valid psm method msg actions can be constructed and run
public void test non static method invocation throws try psm method msg action baz action new psm method msg action my action handlers class handle baz fail should have thrown psm method msg action exception catch psm method action illegal psm method action exception ex this is expected
ensure that a psm method msg action cannot be constructed with a
public void test no such method throws try psm method msg action no such action new psm method msg action my action handlers class no such method fail should have thrown illegal psm method action exception catch psm method action illegal psm method action exception ex this is expected
ensure that a psm method msg action cannot be constructed with a
public void test wrong return type throws try psm method msg action wrong return type new psm method msg action my action handlers class wrong return type fail should have thrown illegal psm method action exception catch psm method action illegal psm method action exception ex expected
ensure that constructing with a method that has the wrong
public void test wrong arg type throws try psm method msg action wrong argument type new psm method msg action my action handlers class wrong argument type fail should have thrown illegal psm method action exception catch psm method action illegal psm method action exception ex expected
ensure that constructing with a method that has the
public void test runtime exception declaration succeeds psm method msg action action1 new psm method msg action my action handlers class throw runtime exception psm method msg action action2 new psm method msg action my action handlers class throw psm method action exception
ensure that constructing with methods that declare
public void test non runtime exception declaration throws try psm method msg action action1 new psm method msg action my action handlers class throw io exception catch psm method action illegal psm method action exception ex expected
ensure that constructing with methods that declare
public psm event handle baz psm msg event evt psm interp interp return baz event
non static methods should cause psm method msg action exceptions
public void test string to peer identity throws exception peer1 idmgr string to peer identity 127 0 0 1 assert not null peer1 assert same peer1 idmgr string to peer identity 127 0 0 1 peer2 idmgr string to peer identity 127 0 0 2 assert not null peer2 assert not equals peer1 peer2 peer3 idmgr string to peer identity idutil ip addr to key 127 0 0 2 300 assert not null peer3 assert not equals peer3 peer2 assert not equals peer3 peer1
test for method string to peer identity
public void test valid method invocation psm method action foo action new psm method action my action handlers class handle foo psm method action bar action new psm method action my action handlers class handle bar psm event foo return foo action run arg event null psm event bar return bar action run arg event null assert same foo return foo event assert same bar return bar event
ensure that valid psm method actions can be constructed and run
public void test non static method invocation throws try psm method action baz action new psm method action my action handlers class handle baz fail should have thrown illegal psm method action exception catch psm method action illegal psm method action exception ex this is expected
ensure that a psm method action cannot be constructed with a
public void test no such method throws try psm method action no such action new psm method action my action handlers class no such method fail should have thrown illegal psm method action exception catch psm method action illegal psm method action exception ex this is expected
ensure that a psm method action cannot be constructed with a
public void test wrong return type throws try psm method action wrong return type new psm method action my action handlers class wrong return type fail should have thrown illegal psm method action exception catch psm method action illegal psm method action exception ex expected
ensure that constructing with a method that has the wrong
public void test wrong arg type throws try psm method action wrong argument type new psm method action my action handlers class wrong argument type fail should have thrown illegal psm method action exception catch psm method action illegal psm method action exception ex expected
ensure that constructing with a method that has the
public void test runtime exception declaration succeeds psm method action action1 new psm method action my action handlers class throw runtime exception psm method action action2 new psm method action my action handlers class throw psm method action exception
ensure that constructing with methods that declare
public void test non runtime exception declaration throws try psm method action action1 new psm method action my action handlers class throw io exception catch psm method action illegal psm method action exception ex expected
ensure that constructing with methods that declare
public psm event handle baz psm event evt psm interp interp return baz event
non static methods should cause illegal psm method action exceptions
public void test agree with vote throws exception peer1 idmgr string to peer identity 127 0 0 1 int rep idmgr get reputation peer1 idmgr change reputation peer1 identity manager agree vote check reputation rep idmgr reputation deltas identity manager agree vote idmgr get reputation peer1
test for method agree with vote
public void test disagree with vote throws exception peer1 idmgr string to peer identity 127 0 0 1 int rep idmgr get reputation peer1 idmgr change reputation peer1 identity manager disagree vote check reputation rep idmgr reputation deltas identity manager disagree vote idmgr get reputation peer1
test for method disagree with vote
public void test call internal poll throws exception peer1 idmgr string to peer identity 127 0 0 1 int rep idmgr get reputation peer1 idmgr change reputation peer1 identity manager call internal check reputation rep idmgr reputation deltas identity manager call internal idmgr get reputation peer1
test for method call internal poll
public void test spoof detected throws exception peer1 idmgr string to peer identity 127 0 0 1 int rep idmgr get reputation peer1 idmgr change reputation peer1 identity manager spoof detected check reputation rep idmgr reputation deltas identity manager spoof detected idmgr get reputation peer1
test for method spoof detected
public void test replay detected throws exception peer1 idmgr string to peer identity 127 0 0 1 int rep idmgr get reputation peer1 idmgr change reputation peer1 identity manager replay detected check reputation rep idmgr reputation deltas identity manager replay detected idmgr get reputation peer1
test for method replay dected
public void assert rcv header input stream ins int op throws ioexception stream util read bytes ins rcv header header len assert header op rcv header op
read header from input stream check that its a message header
public void test attack detected throws exception peer1 idmgr string to peer identity 127 0 0 1 int rep idmgr get reputation peer1 idmgr change reputation peer1 identity manager attack detected check reputation rep idmgr reputation deltas identity manager attack detected idmgr get reputation peer1
test for method acttack detected
public void assert header byte buf assert equals header check buf header off check
assert that buf contains a valid header
public void delete au configuration archival unit au throws ioexception synchronized au add del lock log debug deleting au config au update au config file au config manager empty configuration
delete au configuration from the local config file
public void assert header op byte buf int op assert header buf assert equals op buf header off op
assert that buf contains a valid header with expected op
public void test vote disown throws exception peer1 idmgr string to peer identity 127 0 0 1 int rep idmgr get reputation peer1 idmgr change reputation peer1 identity manager vote disowned check reputation rep idmgr reputation deltas identity manager vote disowned idmgr get reputation peer1
test for method vote disown
public void delete au configuration string auid throws ioexception synchronized au add del lock log debug deleting au config auid update au config file auid config manager empty configuration might be deleting an inactive au inactive au ids remove auid
delete au configuration from the local config file
public void deactivate au configuration archival unit au throws ioexception synchronized au add del lock log debug deactivating au au configuration config get stored au configuration au if config is sealed config config copy config put au param disabled true update au config file au config
deactivate an au in the config file
public void delete au archival unit au throws ioexception synchronized au add del lock delete au configuration au if is remove stopped aus stop au au au event delete
delete an au
public void deactivate au archival unit au throws ioexception synchronized au add del lock deactivate au configuration au if is remove stopped aus string auid au get au id stop au au au event deactivate inactive au ids add auid
deactivate an au
public boolean is internal au archival unit au return au instanceof registry archival unit
return true if the specified archival unit is used internally
public boolean is registry au archival unit au return au instanceof registry archival unit
return true if the specified archival unit is a plugin registry au
public boolean is internal plugin plugin plugin return plugin instanceof registry plugin
return true if the specified plugin is used internally
public boolean is loadable plugin plugin plugin plugin info info plugin info pluginfo map get get plugin key plugin if info null return false return info is on loadable path
return true if the specified plugin is a loadable plugin
public string get plugin type plugin plugin if is loadable plugin plugin return loadable else if is internal plugin plugin return internal else return builtin
return a string identifying the type of plugin loadable internally
public configuration get stored au configuration archival unit au return get stored au configuration au get au id
return the stored config info for an au from config file not from
public configuration get current au configuration string auid string aukey config key from au id auid string prefix param au tree aukey return config manager get current config get config tree prefix
return the current config info for an au from current configuration
public string to string string buffer sb new string buffer sb append if is local identity sb append l sb append mock peer sb append get key sb append return sb to string
to string results in a string describing the peer that is
public string get ui url stem int default port throw new unsupported operation exception not implemented
the original get ui url stem calls get ip addr which depends on
public plugin get plugin string plugin key return plugin map get plugin key
return the plugin with the given key
protected string get configurable plugin name string plugin name string ret default configurable plugin name for iterator it configurable plugin name map key set iterator it has next string regex string it next if plugin name matches regex ret configurable plugin name map get regex break return ret
return the class name of possibly a subclass of definable plugin
public cached url set find cached url set string au id archival unit au get au from id au id if au null return null return au get au cached url set
find an aus top level cached url set
public void test hash code throws ioexception file file test1 file test util temp file ppis file file test2 file test1 peer identity pi one m idman find peer identity k str peer identity one my persistent peer id set impl ppis equals1 new my persistent peer id set impl file test1 m idman ppis equals1 add pi one my persistent peer id set impl ppis equals2 new my persistent peer id set impl file test2 m idman ppis equals2 add pi one assert equals ppis equals1 hash code ppis equals2 hash code
test method for
public void test make poll request throws exception try cached url set cus null cus testau make cached url set new range cached url set spec rooturls 1 poll spec spec new poll spec cus lwrbnd uprbnd poll v1 content poll assert not null pollmanager call poll spec catch illegal state exception e ignore this for now
test for method make poll request
public void test find poll lets see if we can find our name poll try base poll p1 pollmanager make poll v1 testmsg 0 base poll p2 pollmanager find poll v1 testmsg 0 assert equals p1 p2 catch ioexception ex fail name poll couldn t be found
test for method find poll
public void test remove poll try base poll p1 pollmanager make poll v1 testmsg 0 assert not null p1 base poll p2 pollmanager remove poll p1 get key assert equals p1 p2 catch ioexception ex fail name poll couldn t be found
test for method remove poll
public cached url find cached url string url return find the cached url url true
searches for an au that contains the url and returns the corresponding
public void test suspend poll throws exception base poll p1 null p1 test poll create completed poll the daemon testau v1 testmsg 0 7 2 pollmanager string key p1 get key pollmanager add poll p1 give it a pointless lock to avoid a null pointer activity regulator lock lock the daemon get activity regulator testau get au activity lock 1 123 check our suspend pollmanager suspend poll key assert true pollmanager is poll suspended key assert false pollmanager is poll closed key now we resume pollmanager resume poll false key lock assert false pollmanager is poll suspended key
test for method suspend poll
public cached url find cached url string url boolean with content return find the cached url url with content
searches for an au that contains the url and returns the corresponding
public void test to array tarray fail not yet implemented
test method for
public void set hash estimate long duration this duration duration
set the duration that will be returned by estimated hash duration
public void set hash duration long duration int bytes this duration duration this bytes bytes
set the actual hash duration and size
public void tear down throws exception pollmanager stop service the daemon get lockss repository testau stop service the daemon get hash service stop service the daemon get datagram router manager stop service the daemon get router manager stop service the daemon get system metrics stop service time base set real for int i 0 i test v1msg length i if test v1msg i null pollmanager remove poll test v1msg i get key super tear down
tear down method for test case
public void test schedule vote v1 poll p test v1polls 1 assert true p instanceof v1 content poll log debug3 test schedule vote 1 p schedule vote log debug3 test schedule vote 2 assert not null p m vote time assert true p m vote time get remaining time p m deadline get remaining time log debug3 at end of test schedule vote
test for method schedule vote
public void test vote v1 poll p test v1polls 1 p m hash byte array make random bytes 20 try p cast our vote catch illegal state exception e the socket isn t inited and should squack p m pollstate v1 poll ps complete
test for method vote
public void test vote in poll v1 poll p test v1polls 1 p m tally quorum 10 p m tally num agree 5 p m tally num disagree 2 p m tally wt agree 2000 p m tally wt disagree 200 p m hash byte array make random bytes 20 try p vote in poll catch illegal state exception e the socket isn t inited and should squack p m tally num agree 20 try p vote in poll catch null pointer exception npe the socket isn t inited and should squack p m pollstate v1 poll ps complete
test for method vote in poll
private cached url find the cached url string url boolean with content maintain a small cache of url cu when icp is in use each url will likely be looked up twice in quick succession cached url res cached url recent cu map get url if log is debug3 if res null log debug3 cache hit res to string res has content with without content else log debug3 cache miss for url if res null with content res has content res find the cached url0 url with content if res null recent cu map put url res return res
find a cached url for the url
public void test stop poll v1 poll p test v1polls 1 p m tally quorum 10 p m tally num agree 7 p m tally num disagree 3 p m pollstate v1 poll ps wait tally p stop poll assert true p m pollstate v1 poll ps complete p start poll assert true p m pollstate v1 poll ps complete
test for method stop poll
public void test start vote v1 poll p test v1polls 0 p m pending votes 3 p start vote check assert equals 4 p m pending votes p m pollstate v1 poll ps complete
test for method start vote check
public void test stop vote v1 poll p test v1polls 1 p m pending votes 3 p stop vote check assert equals 2 p m pending votes p m pollstate v1 poll ps complete
test for method stop vote
public list find all titles synchronized title monitor if all titles null all titles new array list get title map key set collections sort all titles catalogue order comparator singleton return all titles
return all the known titles from the title db sorted by title
public collection get title plugins string title collection res collection get title map get title if res null return res return collections empty list
find all the plugins that support the given title
public sorted map get plugin name map sorted map p map new tree map synchronized plugin map for iterator iter get registered plugins iterator iter has next plugin p plugin iter next p map put p get plugin name p return p map
return a sorted map mapping human readable plugin name to plugin
protected void set up throws exception super set up lh new list holdings stat svc the daemon get status service ssi status service impl stat svc ssi start service
we have to set up the servlet testing environment and also some tdb
protected void init servlet runner s runner new lockss servlet runner s runner set servlet context attribute servlet manager context attr lockss app the daemon s runner set servlet context attribute servlet manager context attr servlet mgr the daemon get servlet manager tell lockss servlet to include javascript directly in the page rather than linking to it because this little servlet runner can t acess other server files s runner set servlet context attribute lockss servlet attr include script true s client s runner new client
establish a servlet runner and client
protected list get lines web response resp throws exception return get lines resp get text
break into a list of lines
protected list get lines string text buffered reader rdr new buffered reader new string reader text list lines new array list try string s while s rdr read line null lines add s catch ioexception ex won t happen here return lines
break a multiline string into a list of lines
public list get registry urls return registry urls
used only in the case that our semaphore throws an interrupted
public void test make query throws exception expect query icp factory make query mock icp message get mock requester mock icp message get mock query url false false test make query false false test make query false true test make query true false test make query true true
p tests the
public icp message make denied throws icp exception throw unsupported
p throws an
public icp message make error throws icp exception throw unsupported
p throws an
public icp message make hit throws icp exception throw unsupported
p throws an
public icp message make hit short src rtt response throws icp exception throw unsupported
p throws an
public void test change icp port throws exception int port get new port set enabled true port assert true testable icp manager is icp server running assert equals port testable icp manager get current port set config called false port get new port set enabled true port assert true set config called assert true testable icp manager is icp server running assert equals port testable icp manager get current port
p tests the behavior of the manager when the port number
public void test start icp server throws exception assert false testable icp manager is icp server running assert negative testable icp manager get current port set config called false int port get new port set enabled true port assert true set config called assert true testable icp manager is icp server running assert equals port testable icp manager get current port
p tests the behavior of the manager as it starts up
protected icp message make query request hit obj return icp factory make query mock icp message get mock sender mock icp message get mock query url false true
p makes a query message requesting a hit object
protected icp message make query request src rtt request hit obj return icp factory make query mock icp message get mock sender mock icp message get mock query url true true
p makes a query message requesting a source return trip time
public void test compute length int failed 0 for int test 0 test mock icp message count test pairs test try logger info test compute length begin test test icp message message mock icp message get test message test assert equals message get length icp util compute length message logger info test compute length passed test test catch assertion failed error afe logger info test compute length failed test test failed assert true number of failed tests failed failed 0
p tests the
public void test get ip from buffer throws exception byte array byte 0 byte 0 byte 0 byte 0 byte 12 byte 34 byte 56 byte 78 byte 0 byte 0 byte 0 byte 0 byte buffer buffer byte buffer wrap array assert equals new byte byte 12 byte 34 byte 56 byte 78 icp util get ip from buffer buffer 4 get address
p tests the