Пример #1
0
 def testClasspathWithManyDirectoriesAdded(self):
     "Classpath - can add many directories to a classpath"
     path = _createFile(os.path.join("lib", "test.jar"), "polop")
     path2 = _createFile(os.path.join("lib", "test2.jar"), "polop aussi")
     classpath = Classpath("lib")
     classpath.addDirectories(["lib", "/tmp"])
     self.assertEquals('"' + path + ":" + path2 + ":lib:/tmp" + '"',
                       classpath.getClasspath())
Пример #2
0
    def run(self, directory, file=None, options=None):
        options = options or {}
        sys.path.append(directory)
        python_files = FolderTestFinder(directory).find_files()
        installation_path = os.path.split(__file__)[0]
        config = HierarchicalConfiguration([
            DictionnaryConfiguration(options),
            FileConfiguration(os.path.join(installation_path, "config.ini")),
        ])
        lib_path = os.path.join(installation_path, "lib")
        classpath = Classpath(lib_path)

        class_generator = JavaClassGenerator(directory, config)
        java_files = class_generator.run(python_files)
        if file:
            java_suite = class_generator.suite([os.path.join(directory, file)])
        else:
            java_suite = class_generator.suite(java_files)
        java_files.append(java_suite)

        executor = CommandExecutor()

        java_class_filenames = JavaFileCompiler(config, classpath,
                                                executor).compile(java_files)

        xmlRpcServer = XmlRpcServer(config, python_files)
        xmlRpcServer.launch()

        test_result = JavaTestLauncher(
            config, classpath, executor,
            directory).launch(java_suite.replace('.java', '.class'))
        xmlRpcServer.stop()

        for java_filename in java_files:
            os.remove(java_filename)
        for java_class_filename in java_class_filenames:
            internal_class = java_class_filename.replace(
                ".class", "$MyTypeFactory.class")
            if os.path.exists(internal_class):
                os.remove(internal_class)
            os.remove(java_class_filename)

        sys.exit(test_result)
Пример #3
0
 def testClasspathWithManyJar(self):
     "Classpath - can create classpath with many jars"
     path = _createFile(os.path.join("lib", "test.jar"), "polop")
     path2 = _createFile(os.path.join("lib", "test2.jar"), "polop aussi")
     self.assertEquals('"' + path + ":" + path2 + '"',
                       Classpath("lib").getClasspath())
Пример #4
0
 def testClasspathWithOneJar(self):
     "Classpath - can create classpath with one jar"
     path = _createFile(os.path.join("lib", "test.jar"), "polop")
     self.assertEquals('"' + path + '"', Classpath("lib").getClasspath())
Пример #5
0
 def testCanRemoveADirectory(self):
     "Classpath - can remove a directory"
     classpath = Classpath("lib")
     classpath.addDirectory("/tmp")
     classpath.removeDirectory("/tmp")
     self.assertEquals('""', classpath.getClasspath())
Пример #6
0
 def testCanAddADirectoryToAnEmptyClasspath(self):
     "Classpath - can add a directory to empty classpath"
     classpath = Classpath("lib")
     classpath.addDirectory("/tmp")
     self.assertEquals('"/tmp"', classpath.getClasspath())
Пример #7
0
 def testEmptyClassPath(self):
     "Classpath - can create empty classpath"
     self.assertEquals('""', Classpath("lib").getClasspath())