def test_load_doxygen(self): f = FilteredJavaFile( os.path.join('sample', 'VersionInfoBeanDoxygen1.java')) f.load() self.assertEqual('/** Doxygen block', f.contents[0].strip()) f = FilteredJavaFile( os.path.join('sample', 'VersionInfoBeanDoxygen2.java')) f.load() self.assertEqual('/*! Doxygen block', f.contents[0].strip())
def test_add_license(self): f = FilteredJavaFile( os.path.join('sample', 'VersionInfoBeanLicensed.java')) f.load() self.assertEqual('package it.is.just.a.test;', f.contents[0].strip()) first_line = f.contents[0] license = ['this', 'is', 'it'] f.add_license(license) for i in range(0, len(license)): self.assertEqual(license[i], f.contents[i]) self.assertEqual(first_line, f.contents[3])
sys.exit(1) src_file = sys.argv[1] # Check the license file license_file = FilteredTextFile(LICENSE_FILE) try: license_file.load() except: print('License file {} could not be loaded.'.format( license_file.file_name)) sys.exit(2) # Load the java file java_file = FilteredJavaFile(src_file) try: java_file.load() except: print('Java file {} could not be loaded.'.format(java_file.file_name)) sys.exit(3) if len(java_file.contents) == 0: print('The Java file {} is empty or broken.'.format(java_file.file_name)) sys.exit(4) # Save the backup file try: java_file.save(java_file.file_name + '.bak') except: print('Unable to create the backup for the file {}.'.format( java_file.file_name)) sys.exit(5)
def test_load_no_license(self): f = FilteredJavaFile(os.path.join('sample', 'VersionInfoBean.java')) f.load() self.assertEqual('package it.is.just.a.test;', f.contents[0].strip())
def test_load_with_comment3_and_license(self): f = FilteredJavaFile( os.path.join('sample', 'VersionInfoBeanWithComment3Licensed.java')) f.load() self.assertEqual('/* This should not be ignored */', f.contents[0].strip())