def test_unsupported(self): return_value, stderr, report = exec_pom_macro_simple(\ "%pom_remove_parent", "simple_ivy.xml", filename='ivy.xml') assertIn(self, 'Operation not supported', stderr) self.assertNotEqual(0, return_value) self.assertEqual('', report)
def test_require_skipped(self, stdout, stderr, return_value): self.assertNotEqual(return_value, 0) self.assertNotEqual(stderr, "") lines = stderr.split("\n") self.assertEqual(True, len(lines) > 1) self.assertEqual("g:skipped:UNKNOWN required by g:a1", lines[-5]) assertIn(self, "%mvn_package", lines[-3])
def test_no_match(self): return_value, stderr, _ = exec_pom_macro( '''%pom_xpath_disable "/pom:project/pom:groupId='not-there'" submodule''', {'submodule': 'minimal_pom.xml'}) assertIn(self, "Error", stderr) assertIn(self, "didn't match", stderr) self.assertNotEqual(0, return_value)
def test_recursive_missing(self): poms_tree = dict(example_tree) del poms_tree['intermediate/schemas'] return_value, stderr, _ = exec_pom_macro('%pom_remove_dep -r :commons-io', poms_tree=poms_tree) assertIn(self, "Couldn't locate", stderr) self.assertNotEqual(0, return_value)
def test_require_skipped(self, stdout, stderr, return_value): self.assertNotEqual(return_value, 0) self.assertNotEqual(stderr, '') lines = stderr.split('\n') self.assertEqual(True, len(lines) > 1) self.assertEqual("g:skipped:UNKNOWN required by g:a1", lines[-5]) assertIn(self, "%mvn_package", lines[-3])
def test_no_pom_explicit(self): package = Package("nonexistent_pom_explicit") package.append_to_prep('%pom_remove_parent nonexistent_pom.xml') _, stderr, returncode = package.run_prep() self.assertEqual(returncode, 1, stderr) assertIn(self, "Couldn't locate ", stderr)
def test_no_match(self): return_value, stderr, _ = exec_pom_macro( '''%pom_xpath_disable "/pom:project/pom:groupId='not-there'" submodule''', { 'submodule': 'minimal_pom.xml'}) assertIn(self, "Error", stderr) assertIn(self, "didn't match", stderr) self.assertNotEqual(0, return_value)
def test_submodules_partial_match(self): return_value, stderr, _ = exec_pom_macro(\ '%pom_remove_dep :commons-io submodule1 submodule2', poms_tree={'submodule1': 'minimal_pom.xml', 'submodule2': 'simple_pom.xml'}) assertIn(self, "Error", stderr) assertIn(self, "not found", stderr) self.assertNotEqual(0, return_value)
def test_usage(self): package = Package("usage") pompath = os.path.join(WORKDIR, "pom_remove_dep.xml") package.add_source(pompath, "pom.xml") package.append_to_prep('%pom_remove_dep') _, stderr, return_value = package.run_prep() self.assertEqual(return_value, 1) assertIn(self, "Usage: %pom_remove_dep "\ "[groupId]:[artifactId] [POM location]", stderr)
def test_xpath_set_fail(self, stdin, stderr, returncode, pom_path): self.assertEqual(returncode, 1, stderr) assertIn(self, "Error in processing", stderr) report, res = check_result(pom_path) self.assertEqual(res, True, report)
def test_xpath_replace_invalid_xml(self, stdin, stderr, returncode, pom_path): self.assertEqual(returncode, 1, stderr) assertIn(self, "Error in processing", stderr)
def test_xpath_inject_fail(self, stdin, stderr, returncode, pom_path): # invalid XML code self.assertEqual(returncode, 1, stderr) assertIn(self, "Error in processing", stderr)
def test_fail_on_main(self): return_value, stderr, _ = exec_pom_macro( """%pom_xpath_disable "pom:groupId='com.example'" """, poms_tree=example_tree) assertIn(self, "Main POM satisfies the condition", stderr) self.assertNotEqual(0, return_value)
def test_configuration(self, stdout, stderr, return_value): self.assertEqual(return_value, 0, stderr) sout = [x for x in stdout.split('\n') if x] self.assertEqual(len(sout), 1) assertIn(self, "MYNS-javapackages-tools", sout)
def test_recursive_no_match(self): return_value, stderr, _ = exec_pom_macro('%pom_remove_dep -r :not-there', poms_tree=example_tree) assertIn(self, "Error", stderr) assertIn(self, "not found", stderr) self.assertNotEqual(0, return_value)
def test_recursive_partial_match(self): return_value, stderr, _ = exec_pom_macro('%pom_remove_dep -r commons-ioX intermediate common', poms_tree=example_tree) assertIn(self, "Error", stderr) assertIn(self, "not found", stderr) self.assertNotEqual(0, return_value)
def test_configuration(self, stdout, stderr, return_value): self.assertEqual(return_value, 0, stderr) sout = [x for x in stdout.split('\n') if x] self.assertEqual(len(sout), 1) assertIn(self, "SCL-javapackages-tools", sout)
def test_unparsable_xml(self, stdin, stderr, returncode, pom_path): self.assertEqual(returncode, 1, stderr) assertIn(self, "Error in processing", stderr)
def test_remove_plugin_ret1(self, stdin, stderr, returncode, pom_path): self.assertEqual(returncode, 1) assertIn(self, "Error in processing", stderr)
def test_disable_module_no_effect(self, stdin, stderr, returncode, pom_path): self.assertEqual(returncode, 1) assertIn(self, "Error in processing", stderr)
def test_xpath_remove_fail(self, stdin, stderr, returncode, pom_path): self.assertEqual(returncode, 1, stderr) assertIn(self, "Error in processing", stderr)
def test_missing_jar(self): p = Package('test') p.append_to_prep("%add_maven_depmap g:a:1 this/file/doesnt/exist.jar") _, stderr, return_value = p.run_prep() self.assertEqual(1, return_value, 'bad return value') assertIn(self, 'file not found', stderr)
def test_remove_dep_no_effect(self, stdin, stderr, returncode, pom_path): self.assertEqual(returncode, 1, stderr) assertIn(self, "Error in processing", stderr)
def test_submodule_nonexistent(self): return_value, stderr, _ = exec_pom_macro('%pom_remove_parent submodule', {}) assertIn(self, "Couldn't locate ", stderr) self.assertNotEqual(0, return_value)
def test_nonexistent(self): return_value, stderr, _ = exec_pom_macro('%pom_xpath_disable nothing', {}) assertIn(self, "Couldn't locate ", stderr) self.assertNotEqual(0, return_value)
def test_unknown_dep(self, stdout, stderr, return_value): self.assertNotEqual(return_value, 0) serr = [x for x in stderr.split("\n") if x] want = "org.apache.maven:maven-project:2.2.1" assertIn(self, want, serr)
def test_unknown_dep(self, stdout, stderr, return_value): self.assertNotEqual(return_value, 0) serr = [x for x in stderr.split('\n') if x] want = ("org.apache.maven:maven-project:2.2.1") assertIn(self, want, serr)