Beispiel #1
0
    def test_read_simple(self):
        # Act
        pom = PomReaderUtil.read('resources/simple_pom.xml')

        # Assert
        PomReaderUtilTest.check_gav(self, pom.gav, GAV,
                                    "io.missus.message-service", "api",
                                    "0.0.1-SNAPSHOT")
        self.assertEqual(None, pom.parent)

        self.assertEqual(3, len(pom.dependencies))
        PomReaderUtilTest.check_gav(self, pom.dependencies[0], GAV,
                                    "org.springframework", "spring-web")
        PomReaderUtilTest.check_gav(self, pom.dependencies[1], GAV,
                                    "io.projectreactor", "reactor-core")
        PomReaderUtilTest.check_gav(self, pom.dependencies[2], GAV,
                                    "org.projectlombok", "lombok")

        self.assertEqual(3, len(pom.dependencies_management))
        PomReaderUtilTest.check_gav(self, pom.dependencies_management[0], GAV,
                                    "org.springframework", "spring-web", "1")
        PomReaderUtilTest.check_gav(self, pom.dependencies_management[1], GAV,
                                    "io.projectreactor", "reactor-core", "2")
        PomReaderUtilTest.check_gav(self, pom.dependencies_management[2], GAV,
                                    "org.projectlombok", "lombok", "3",
                                    "sources")

        self.assertEqual(None, pom.children)
Beispiel #2
0
    def test_simple(self):
        # Arrange
        pom = PomReaderUtil.read('resources/dep_management/pom.xml')

        # Act
        result = GAVDeclaredAndDefine.get_repeated_gavs(pom)

        # Assert
        self.assertEqual(2, len(result))

        result_project1 = result[list(result.keys())[0]]
        result_project2 = result[list(result.keys())[1]]
        self.assertEqual(3, len(result_project1))
        self.assertEqual(1, len(result_project2))

        GAVDeclaredAndDefineTest.check_dep(
            self, result_project1, "group1:artifact1:1:None",
            "org.drools:drools-bom:0.0.1-SNAPSHOT:None", 1, 0, 0)
        GAVDeclaredAndDefineTest.check_dep(
            self, result_project1, "group3:artifact3:3:None",
            "org.drools:drools-bom:0.0.1-SNAPSHOT:None", 1, 1, 0)
        GAVDeclaredAndDefineTest.check_dep(
            self, result_project1, "group8:artifact8:8:None",
            "org.test:test-parent:0.0.1-SNAPSHOT:None", 1, 2, 0)

        GAVDeclaredAndDefineTest.check_dep(
            self, result_project2, "group2:artifact2:2:None",
            "org.test:test-parent:0.0.1-SNAPSHOT:None", 1, 0, 0)
Beispiel #3
0
def run_repeated_check(pom_file_path):
    print("Loading pom file from [{0}]".format(pom_file_path))
    pom = PomReaderUtil.read(pom_file_path)
    print("Running the -r checking...".format(pom_file_path))
    result = RepeatedGAVS.get_repeated_gavs(pom)
    print("------- Check finished ---------")
    print(result)
    print("")
Beispiel #4
0
def run_gdad_check(pom_file_path):
    print("Loading pom file from [{0}]".format(pom_file_path))
    pom = PomReaderUtil.read(pom_file_path)
    print("Running the -d checking...".format(pom_file_path))
    result = GAVDeclaredAndDefine.get_repeated_gavs(pom)
    print("------- Check finished ---------")
    print_gdad_check(result)
    print("")
Beispiel #5
0
    def test_true(self):
        # Arrange
        pom = PomReaderUtil.read('resources/noRepeatedDependency_pom.xml')

        # Act
        result = RepeatedGAVS.get_repeated_gavs(pom)

        # Assert
        self.assertEqual(0, len(result))
Beispiel #6
0
    def test_true(self):
        # Arrange
        pom = PomReaderUtil.read('resources/kie/pom.xml')

        # Act
        result = GAVDeclaredAndDefine.get_repeated_gavs(pom)

        # Assert
        self.assertTrue(True)
Beispiel #7
0
    def test_false(self):
        # Arrange
        pom = PomReaderUtil.read('resources/withRepeatedDependency_pom.xml')

        # Act
        result = RepeatedGAVS.get_repeated_gavs(pom)

        # Assert
        self.assertEqual(1, len(result))
        self.assertEqual("org.springframework", result[0].group_id)
        self.assertEqual("spring-web", result[0].artifact_id)
        self.assertEqual("1", result[0].version)
        self.assertEqual(None, result[0].classifier)
Beispiel #8
0
    def test_read_parent1(self):
        # Act
        pom = PomReaderUtil.read('resources/parent1_pom.xml')

        # Assert
        PomReaderUtilTest.check_gav(self, pom.gav, GAV,
                                    "io.missus.message-service", "parent",
                                    "0.0.1-SNAPSHOT")
        PomReaderUtilTest.check_gav(self, pom.parent.gav, GAV,
                                    "org.springframework.boot",
                                    "spring-boot-starter-parent",
                                    "2.1.2.RELEASE")

        self.assertEqual(None, pom.dependencies)
        self.assertEqual(None, pom.dependencies_management)

        self.assertEqual(2, len(pom.children))

        # Check children 0
        PomReaderUtilTest.check_gav(self, pom.children[0].gav, GAV,
                                    "io.missus.message-service", "core",
                                    "0.0.1-SNAPSHOT")
        PomReaderUtilTest.check_gav(self, pom.children[0].parent.gav, GAV,
                                    "io.missus.message-service", "parent",
                                    "0.0.1-SNAPSHOT")

        self.assertEqual(None, pom.children[0].dependencies)
        self.assertEqual(None, pom.children[0].dependencies_management)
        self.assertEqual(2, len(pom.children[0].children))
        self.assertIs(pom, pom.children[0].parent)

        # Check Children 0 - 0
        print(pom.children[0].children[0])
        PomReaderUtilTest.check_gav(self, pom.children[0].children[0].gav, GAV,
                                    "io.missus.message-service", "core-core",
                                    "0.0.1-SNAPSHOT")
        PomReaderUtilTest.check_gav(self,
                                    pom.children[0].children[0].parent.gav,
                                    GAV, "io.missus.message-service", "core",
                                    "0.0.1-SNAPSHOT")

        self.assertEqual(15, len(pom.children[0].children[0].dependencies))
        self.assertEqual(None,
                         pom.children[0].children[0].dependencies_management)
        self.assertEqual(None, pom.children[0].children[0].children)
        self.assertIs(pom.children[0], pom.children[0].children[0].parent)

        # Check Children 0 - 1
        print(pom.children[0].children[1])
        PomReaderUtilTest.check_gav(self, pom.children[0].children[1].gav, GAV,
                                    "io.missus.message-service", "core-api",
                                    "0.0.1-SNAPSHOT")
        PomReaderUtilTest.check_gav(self,
                                    pom.children[0].children[1].parent.gav,
                                    GAV, "io.missus.message-service", "core",
                                    "0.0.1-SNAPSHOT")

        self.assertEqual(3, len(pom.children[0].children[1].dependencies))
        self.assertEqual(None,
                         pom.children[0].children[1].dependencies_management)
        self.assertEqual(None, pom.children[0].children[1].children)
        self.assertIs(pom.children[0], pom.children[0].children[1].parent)

        # Check children 1
        PomReaderUtilTest.check_gav(self, pom.children[1].gav, GAV,
                                    "io.missus.message-service", "api",
                                    "0.0.1-SNAPSHOT")
        PomReaderUtilTest.check_gav(self, pom.children[1].parent.gav, GAV,
                                    "io.missus.message-service", "parent",
                                    "0.0.1-SNAPSHOT")

        self.assertEqual(3, len(pom.children[1].dependencies))
        PomReaderUtilTest.check_gav(self, pom.children[1].dependencies[0], GAV,
                                    "org.springframework", "spring-web")
        PomReaderUtilTest.check_gav(self, pom.children[1].dependencies[1], GAV,
                                    "io.projectreactor", "reactor-core")
        PomReaderUtilTest.check_gav(self, pom.children[1].dependencies[2], GAV,
                                    "org.projectlombok", "lombok")
        self.assertEqual(None, pom.children[1].dependencies_management)
        self.assertEqual(None, pom.children[1].children)
        self.assertIs(pom, pom.children[1].parent)