input stringlengths 10 828 | output stringlengths 5 107 |
|---|---|
public void test email from perl throws validator exception value bean info new value bean for int index 0 index test email from perl length index info set value test email from perl index item value test info test email from perl index valid | write this test based on perl mail rfc822 address |
public void tear down field null | test clean up |
public void test empty args assert equals empty args 1 0 field get args required length | test field with no arguments |
public void test default position implied field add arg create arg default position 0 field add arg create arg default position 1 field add arg create arg default position 2 assert equals test default position implied 1 3 field get args required length assert equals test default position implied 2 default position 0 field get arg required 0 get key assert equals test default position implied 3 default position 1 field get arg required 1 get key assert equals test default position implied 4 default position 2 field get arg required 2 get key | test field with only default arguments no positions specified |
public void test default using positions field add arg create arg default position 1 1 field add arg create arg default position 0 0 field add arg create arg default position 2 2 assert equals test default using positions 1 3 field get args required length assert equals test default using positions 2 default position 0 field get arg required 0 get key assert equals test default using positions 3 default position 1 field get arg required 1 get key assert equals test default using positions 4 default position 2 field get arg required 2 get key | test field with only default arguments positions specified |
public void test all valid throws validator exception create bean to run test on name bean bean create name bean validate validator results results validate bean check results check validator result results first name field required true check validator result results middle name field required true check validator result results middle name field int true check validator result results middle name field positive true check validator result results last name field required true check validator result results last name field int true | test all validations ran and passed |
public void test errors throws validator exception middle name xxx last name null create bean to run test on name bean bean create name bean validate validator results results validate bean check results check validator result results first name field required true check validator result results middle name field required true check validator result results middle name field int false check not run results middle name field positive check validator result results last name field required false check not run results last name field int | test some validations failed and some didnt run |
private void check not run validator results results string field string action validator result result results get validator result field assert not null field result result assert false field action run result contains action action system out println field action not run | check a validator has not been run for a field and the result |
private void check validator result validator results results string field string action boolean expected validator result result results get validator result field system out println field action result is valid action assert not null field result result assert true field action not run result contains action action assert equals field action result expected result is valid action | check a validator has run for a field and the result |
private arg create arg string key arg arg new arg arg set key key return arg | convenience method create argument no name or position specified |
private arg create arg string key int position arg arg create arg key arg set position position return arg | convenience method create argument no name position specified |
private arg create arg string key string name arg arg create arg key arg set name name return arg | convenience method create argument name specified no position |
private arg create arg string key string name int position arg arg create arg key name arg set position position return arg | convenience method create argument name position specified |
public void test to string regex validator single new regex validator regex assert equals single regex validator regex single to string regex validator multiple new regex validator new string regex regex assert equals multiple regex validator regex regex multiple to string | test to string method |
private void check array string label string expect string result handle nulls if expect null result null if expect null result null return valid both null else fail label null expect expect result result check length if expect length result length fail label length expect expect length result result length check values for int i 0 i expect length i assert equals label value i expect i result i | compare two arrays |
public void test pattern valid for int i 0 i pattern valid length i string text i value pattern valid i failed calendar calendar validator validate pattern valid i hh mm ss assert not null validate obj text calendar date date calendar get time assert true is valid text validator is valid pattern valid i hh mm ss assert equals compare text pattern expect i date | test valid dates with pattern validation |
public void test pattern invalid for int i 0 i pattern invalid length i string text i value pattern invalid i passed object date validator validate pattern invalid i hh mm ss assert null validate text date date assert false is valid text validator is valid pattern invalid i hh mm ss | test invalid dates with pattern validation |
public void test locale valid for int i 0 i locale valid length i string text i value locale valid i failed calendar calendar validator validate locale valid i locale uk assert not null validate text calendar date date calendar get time assert true is valid text validator is valid locale valid i locale uk assert equals compare text locale expect i date | test valid dates with locale validation |
public void test locale invalid for int i 0 i locale invalid length i string text i value locale invalid i passed object date validator validate locale invalid i locale us assert null validate text date date assert false is valid text validator is valid locale invalid i locale uk | test invalid dates with locale validation |
public void test amex option credit card validator validator new credit card validator credit card validator amex assert false invalid validator is valid error amex assert null validate validator validate error amex assert equals valid amex validator validate valid amex assert true amex validator is valid valid amex assert false diners validator is valid valid diners assert false discover validator is valid valid discover assert false mastercard validator is valid valid mastercard assert false visa validator is valid valid visa assert false visa short validator is valid valid short visa | test the amex card option |
public void test format set the default locale locale orig default locale get default locale set default locale uk object test time validator get instance validate 16 49 23 hh mm ss assert not null test date test assert equals format pattern 16 49 23 validator format test hh mm ss assert equals format locale 4 49 pm validator format test locale us assert equals format default 16 49 validator format test restore the original default locale set default orig default | test invalid dates with locale validation |
public void test diners option credit card validator validator new credit card validator credit card validator diners assert false invalid validator is valid error diners assert null validate validator validate error diners assert equals valid diners validator validate valid diners assert false amex validator is valid valid amex assert true diners validator is valid valid diners assert false discover validator is valid valid discover assert false mastercard validator is valid valid mastercard assert false visa validator is valid valid visa assert false visa short validator is valid valid short visa | test the diners card option |
public void test reserved inet addresses assert true localhost ip should be valid validator is valid 127 0 0 1 assert true broadcast ip should be valid validator is valid 255 255 255 255 | test reserved ips |
public void test broken inet addresses assert false ip with characters should be invalid validator is valid 124 14 32 abc assert false ip with three groups should be invalid validator is valid 23 64 12 assert false ip with five groups should be invalid validator is valid 26 34 23 77 234 | test obviously broken ips |
public void test date time style set the default locale locale orig default locale get default locale set default locale uk abstract calendar validator date time validator new abstract calendar validator true date format short date format short protected object process parsed value object value format formatter return value assert true validate a default date time validator is valid 31 12 05 14 23 assert true validate a locale date time validator is valid 12 31 05 2 23 pm locale us restore the original default locale set default orig default | test date time style validator there isnt an implementation for this |
public void test mastercard option credit card validator validator new credit card validator credit card validator mastercard assert false invalid validator is valid error mastercard assert null validate validator validate error mastercard assert equals valid mastercard validator validate valid mastercard assert false amex validator is valid valid amex assert false diners validator is valid valid diners assert false discover validator is valid valid discover assert true mastercard validator is valid valid mastercard assert false visa validator is valid valid visa assert false visa short validator is valid valid short visa | test the mastercard card option |
public void test invalid isbn10 format isbnvalidator validator isbnvalidator get instance pattern pattern pattern compile isbnvalidator isbn10 regex for int i 0 i invalid isbn10 format length i assert false pattern i invalid isbn10 format i pattern matcher invalid isbn10 format i matches assert false is valid isbn10 i invalid isbn10 format i validator is valid isbn10 invalid isbn10 format i assert null validate isbn10 i invalid isbn10 format i validator validate isbn10 invalid isbn10 format i | test invalid isbn 10 formats |
public void test invalid isbn13 format pattern pattern pattern compile isbnvalidator isbn13 regex isbnvalidator validator isbnvalidator get instance for int i 0 i invalid isbn13 format length i assert false pattern i invalid isbn13 format i pattern matcher invalid isbn13 format i matches assert false is valid isbn13 i invalid isbn13 format i validator is valid isbn13 invalid isbn13 format i assert null validate isbn13 i invalid isbn13 format i validator validate isbn13 invalid isbn13 format i | test invalid isbn 13 formats |
public void test conversion errors isbnvalidator validator isbnvalidator get instance string input null try input 123456789 validator convert to isbn13 input fail expected illegal argument exception for input catch illegal argument exception e expected result try input 12345678901 validator convert to isbn13 input fail expected illegal argument exception for input catch illegal argument exception e expected result try input validator convert to isbn13 input fail expected illegal argument exception for input catch illegal argument exception e expected result try input x234567890 validator convert to isbn13 input fail expected illegal argument exception for input catch illegal argument exception e expected result | test method for |
public void test email assert true validator is valid jsmith apache org | tests the e mail validation |
public void test email with numeric address assert true validator is valid someone 216 109 118 76 assert true validator is valid someone yahoo com | tests the email validation with numeric domains |
public void test email extension assert true validator is valid jsmith apache org assert true validator is valid jsmith apache com assert true validator is valid jsmith apache net assert true validator is valid jsmith apache info assert false validator is valid jsmith apache assert false validator is valid jsmith apache c assert true validator is valid someone yahoo museum assert false validator is valid someone yahoo mu seum | tests the e mail validation |
public void test email with dash assert true validator is valid andy noble data workshop com assert false validator is valid andy noble data workshop com assert false validator is valid andy noble data workshop c om assert false validator is valid andy noble data workshop co m | p tests the e mail validation with a dash in |
public void test email with dot end assert false validator is valid andy noble data workshop com | tests the e mail validation with a dot at the end of |
public void test email with commas assert false validator is valid joeblow apa che org assert false validator is valid joeblow apache o rg assert false validator is valid joeblow apache org | tests the email validation with commas |
public void test email with spaces assert false validator is valid joeblow apache org todo this should be valid assert false validator is valid joeblow apache org assert true validator is valid joeblow apache org todo this should be valid assert true validator is valid joeblow apache org assert false validator is valid joe blow apache org assert false validator is valid joeblow apa che org | tests the email validation with spaces |
public void test email with control chars for char c 0 c 32 c assert false test control char int c validator is valid foo c bar domain com assert false test control char 127 validator is valid foo char 127 bar domain com | tests the email validation with ascii control characters |
public void test pattern valid for int i 0 i pattern valid length i string text i value pattern valid i failed object date validator parse pattern valid i yy mm dd null null assert not null validate obj text date date assert true is valid text validator is valid pattern valid i yy mm dd if date instanceof calendar date calendar date get time assert equals compare text pattern expect i date | test valid dates with pattern validation |
public void test pattern invalid for int i 0 i pattern invalid length i string text i value pattern invalid i passed object date validator parse pattern invalid i yy mm dd null null assert null validate obj text date date assert false is valid text validator is valid pattern invalid i yy mm dd | test invalid dates with pattern validation |
public void test locale valid for int i 0 i locale valid length i string text i value locale valid i failed object date validator parse locale valid i null locale us null assert not null validate obj text date date assert true is valid text validator is valid locale valid i locale us if date instanceof calendar date calendar date get time assert equals compare text pattern expect i date | test valid dates with locale validation |
public void test locale invalid for int i 0 i locale invalid length i string text i value locale invalid i passed object date validator parse locale invalid i null locale us null assert null validate obj text date date assert false is valid text validator is valid locale invalid i locale us | test invalid dates with locale validation |
public void test email from perl for int index 0 index test email from perl length index string item test email from perl index item if test email from perl index valid assert true should be ok item validator is valid item else assert false should fail item validator is valid item | write this test based on perl mail rfc822 address |
public void test format create a date or calendar object test validator parse 2005 11 28 yyyy mm dd null null assert not null test date test assert equals format pattern 28 11 05 validator format test dd mm yy assert equals format locale 11 28 05 validator format test locale us | test invalid dates with locale validation |
public void test format type assert equals format type a 2 percent validator get instance get format type assert equals format type b percent validator percent format percent validator get instance get format type | test format type |
protected void tear down throws exception super tear down valid null routine null | tear down clears routine and valid codes |
protected string remove check digit string code return code substring 0 2 00 code substring 4 | returns a code with the check digit i |
protected string check digit string code if code null code length check digit lth return return code substring 2 4 | returns the check digit i |
public void test format type assert equals format type a 0 validator get format type assert equals format type b abstract number validator standard format validator get format type | test format type |
public void test validate min max decimal format fmt new decimal format if max null assert equals test max max validator parse fmt format max null assert null test max 1 validator parse fmt format max plus one null assert equals test min min validator parse fmt format min null assert null test min 1 validator parse fmt format min minus one null | test min max values allowed |
public void test invalid strict for int i 0 i invalid strict length i string text idx i value invalid strict i assert null a text strict validator parse invalid strict i null locale us assert false b text strict validator is valid invalid strict i null locale us assert null c text strict validator parse invalid strict i test pattern null assert false d text strict validator is valid invalid strict i test pattern null | test invalid strict true |
public void test invalid not strict for int i 0 i invalid length i string text idx i value invalid i assert null a text validator parse invalid i null locale us assert false b text validator is valid invalid i null locale us assert null c text validator parse invalid i test pattern null assert false d text validator is valid invalid i test pattern null | test invalid strict false |
protected string remove check digit string code if code null code length check digit lth return null return code substring 0 code length check digit lth | returns a code with the check digit i |
public void test valid not strict for int i 0 i valid length i string text idx i value valid compare i assert equals a text valid compare i validator parse valid i null locale us assert true b text validator is valid valid i null locale us assert equals c text valid compare i validator parse valid i test pattern null assert true d text validator is valid valid i test pattern null | test valid strict false |
protected string check digit string code if code null code length check digit lth return int start code length check digit lth return code substring start | returns the check digit i |
public void test format number number new big decimal 1234 5 assert equals us locale us format 1 234 5 strict validator format number locale us assert equals de locale de format 1 234 5 strict validator format number locale german assert equals pattern 0 00 12 34 50 strict validator format number 0 00 | test format methods |
public void test format type assert equals format type a 1 currency validator get instance get format type assert equals format type b currency validator currency format currency validator get instance get format type | test format type |
public void test clone | test for object clone |
public void test equals object | test for boolean equals object |
public void test to string flags f new flags string s f to string assert equals 64 s length f turn on int flag s f to string assert equals 64 s length assert equals 0000000000000000000000000000000000000000000000000000000000000100 s | test for string to string |
public void test default form string form key form prefix default us locale check form locale us form key default french locale check form locale french form key default france locale check form locale france form key default candian english locale check form locale canada form key default candian french locale check form locale canada french form key default candian french variant locale check form canada french xxx form key default | test a form defined only in the default formset |
public void test language form string form key form prefix language us locale check form locale us form key default french locale check form locale french form key fr france locale check form locale france form key fr candian english locale check form locale canada form key default candian french locale check form locale canada french form key fr candian french variant locale check form canada french xxx form key fr | test a form defined in the default formset and formsets |
public void test language country form string form key form prefix language country us locale check form locale us form key default french locale check form locale french form key fr france locale check form locale france form key fr fr candian english locale check form locale canada form key default candian french locale check form locale canada french form key fr ca candian french variant locale check form canada french xxx form key fr ca | test a form defined in the default formset formsets |
public void test language country variant form string form key form prefix language country variant us locale check form locale us form key default french locale check form locale french form key fr france locale check form locale france form key fr fr candian english locale check form locale canada form key default candian french locale check form locale canada french form key fr ca candian french variant locale check form canada french xxx form key fr ca xxx | test a form defined in all the formsets |
public void test form not found string form key invalid name us locale check form not found locale us form key french locale check form not found locale french form key france locale check form not found locale france form key candian english locale check form not found locale canada form key candian french locale check form not found locale canada french form key candian french variant locale check form not found canada french xxx form key | test a form not defined |
public void test custom resources load resources input stream in null try in this get class get resource as stream test number config xml catch exception e fail error loading resources e finally try if in null in close catch exception e | test creating a custom validator resources |
public void test double throws validator exception create bean to run test on value bean info new value bean info set value 0 value test info true | tests the double validation |
public void test double min throws validator exception create bean to run test on value bean info new value bean info set value new double double min value to string value test info true | tests the double validation |
public void test double max throws validator exception create bean to run test on value bean info new value bean info set value new double double max value to string value test info true | tests the double validation |
public void test double failure throws validator exception create bean to run test on value bean info new value bean value test info false | tests the double validation failure |
public void test float throws validator exception create bean to run test on value bean info new value bean info set value 0 value test info true | tests the float validation |
public void test float min throws validator exception create bean to run test on value bean info new value bean info set value new float float min value to string value test info true | tests the float validation |
public void test float max throws validator exception create bean to run test on value bean info new value bean info set value new float float max value to string value test info true | tests the float validation |
public void test float failure throws validator exception create bean to run test on value bean info new value bean value test info false | tests the float validation failure |
private url create upload url throws malformed urlexception if upload url null return new url upload url else if project name null throw new null pointer exception project name must be set return new url https project name googlecode com files | creates the correct url for uploading to the named google code project |
public boolean expecting message binary string separator integer max length return expected queue add new object separator max length | registers an expected message for the queue |
public void set data binary string data this data data | sets the data associated with this exception |
public boolean expecting message integer length return expected queue add length | registers an expected message for the queue |
public binary string get data return data | gets the data associated with this exception |
public void clear expected messages expected queue clear buffer n 0 position n 0 needle n 1 length 0 | clears the queue of all expected messages |
private boolean compute overflow byte buffer haystack if position n current limit positive overflow if haystack length buffer n 1 haystack buffer n 1 has remaining buffer n int offset position n current limit current haystack buffer n position n current position offset return compute overflow haystack else return false else if position n current position negative overflow int offset current position position n buffer n current haystack buffer n position n current limit offset return compute overflow haystack return true | moves the position pointer to the correct array in haystack |
protected void set separator binary string separator assert get synch lock is held by current thread this separator separator | sets the separator |
private boolean ensure length byte buffer haystack int max length int length 0 int i 0 while i buffer n length haystack i remaining i length position n haystack buffer n position return length max length | ensures there is enough room in haystack to accomodate max length |
protected binary string get separator assert get synch lock is held by current thread return separator | gets the separator |
public void set generator callable selectee selectee generator this selectee generator selectee generator | sets the selectee generator |
protected lexer get lexer return lexer get | gets the lexer |
protected void set lexer lexer lexer this lexer set lexer | sets the lexer |
protected selectee spawn selectee socket channel sc throws ioexception try return selectee selectee generator generate selectee sc catch exception e ioexception t new ioexception t init cause e throw t | generates a selectee out of the socket channel |
public sslengine engine return ssl engine | gets the sslengine |
public void ignore errors ignore errors true | tells the programmable client to ignore parsing errors otherwise we throw exceptions |
protected void on error string cause throws ioexception error list add cause if ignore errors throw new protocol exception cause | adds the error to the error list and possibly throws an exception |
private void advance position byte buffer data int advance for byte buffer b data if b remaining advance advance b remaining b position b limit else b position b position advance break | advances to the next position in the data |
protected void prepend command command to add assert synch lock is held by current thread command queue add first to add | adds the command to the beginning of the queue |
protected void prepend async command command to add async command queue add to add caller get wakeup | adds the command to the beginning of the queue |
public void set body binary string body this body body | sets the body of the message |
private void copy data byte buffer dst byte buffer src for byte buffer b dst int to copy src remaining b remaining src remaining b remaining if src has array if b has an array we can do a bulk put b put src array src array offset src position to copy src position src position to copy else for int i 0 i to copy i b put src get if src has remaining break | copies data fron src to dst |
public void add header field header binary string name header get name to lower case name trim in place for binary string singular singular headers if singular equals name headers put name header return byte index 0 name append binary string wrap index while headers contains key name index name substring in place 0 name length 1 name append binary string wrap index headers put name header | adds the header to the message |
static public binary string encode word string s try return encode word new binary string s utf 8 catch unsupported charset exception e shouldn t happen return null | encodes s into the mime encoded word format |
static public binary string encode word binary string b string for int i 0 i b string length i byte b b string byte at i if b 33 b 126 return binary string concat new binary string b string get charset to lower case b b string base64encode new binary string return b string | encodes b string to mime encoded word format |
static public binary string encode phrase string s try return encode phrase new binary string s utf 8 catch unsupported charset exception e shouldn t happen return null | encodes s according to mime encoded word format |
public void add command command to add assert synch lock is held by current thread command queue add to add | adds the command to the end of the queue |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.