Beispiel #1
0
def test_without_input_files(qibuild_action):
    """ Test that exception is raised if no input file is given.
    """
    # pylint: disable-msg=E1101
    with pytest.raises(Exception) as e:
        jar.jar("foo.jar", list(), get_paths())
    assert e.value[0] == "Missing arguments : Files to package"
Beispiel #2
0
def test_package(qibuild_action, qimvn_action, local_repository):
    """ Test if Maven project is correctly built
    """
    qibuild_action.add_test_project("hellojavajni")
    hellojava = qibuild_action.add_test_project("hellojava")
    add_repository(hellojava, local_repository)
    qibuild_action("configure", "hellojavajni")
    qibuild_action("make", "hellojavajni")
    jar.jar("hellojavajni.jar", ["hellojavajni"], get_paths())
    deploy.deploy("com.test", "1.0-SNAPSHOT", "hellojavajni",
                  "hellojavajni.jar", local_repository)

    assert package.package(hellojava) == 0
    path = hellojava.path
    built_jar = os.path.join(path, "target/hellojava-1.0-SNAPSHOT.jar")
    assert os.path.exists(built_jar)
Beispiel #3
0
def test_failing_deploy(qibuild_action, local_repository):
    """ Test exceptions.
    """
    qibuild_action.add_test_project("hellojavajni")
    qibuild_action("configure", "hellojavajni")
    qibuild_action("make", "hellojavajni")

    jarname = "test.jar"
    jarpath = jar.jar(jarname, ["hellojavajni"], get_paths())
    assert jarpath

    deploy_path = local_repository.replace("file://", "")
    artifactId = "hellojavajni"
    ver = "1.0"
    # pylint: disable-msg=E1101
    with pytest.raises(CommandFailedException) as e:
        deploy.deploy("", ver, artifactId, jarname, local_repository)
    assert e.value.returncode == 1

    # pylint: disable-msg=E1101
    with pytest.raises(CommandFailedException) as e:
        deploy.deploy("com.test", ver, "", jarname, local_repository)
    assert e.value.returncode == 1

    # pylint: disable-msg=E1101
    with pytest.raises(CommandFailedException) as e:
        deploy.deploy("com.test", ver, artifactId, jarname, deploy_path)
    assert e.value.returncode == 1
Beispiel #4
0
def test_package(qibuild_action, qimvn_action, local_repository):
    """ Test if Maven project is correctly built
    """
    qibuild_action.add_test_project("hellojavajni")
    hellojava = qibuild_action.add_test_project("hellojava")
    add_repository(hellojava, local_repository)
    qibuild_action("configure", "hellojavajni")
    qibuild_action("make", "hellojavajni")
    jar.jar("hellojavajni.jar", ["hellojavajni"], get_paths())
    deploy.deploy("com.test", "1.0-SNAPSHOT", "hellojavajni",
                  "hellojavajni.jar", local_repository)

    assert package.package(hellojava) == 0
    path = hellojava.path
    built_jar = os.path.join(path, "target/hellojava-1.0-SNAPSHOT.jar")
    assert os.path.exists(built_jar)
Beispiel #5
0
def test_jar_creation(qibuild_action, qimvn_action):
    """ Test if jar can find element in worktree and
        if a jar is created.
    """
    qibuild_action.add_test_project("world")
    qibuild_action.add_test_project("hello")
    qibuild_action("configure", "hello")
    qibuild_action("make", "hello")

    jarname = "test.jar"
    jarpath = jar.jar(jarname, ["hello", "world"], get_paths())
    assert jarpath
    assert os.path.exists(jarpath)
    assert os.path.exists(os.path.join("./", jarname))
Beispiel #6
0
def test_jar_creation(qibuild_action, qimvn_action):
    """ Test if jar can find element in worktree and
        if a jar is created.
    """
    qibuild_action.add_test_project("world")
    qibuild_action.add_test_project("hello")
    qibuild_action("configure", "hello")
    qibuild_action("make", "hello")

    jarname = "test.jar"
    jarpath = jar.jar(jarname, ["hello", "world"], get_paths())
    assert jarpath
    assert os.path.exists(jarpath)
    assert os.path.exists(os.path.join("./", jarname))
Beispiel #7
0
def test_jar_path(qibuild_action, qimvn_action):
    """ Test if jar command can create jar in a specified directory
    """
    project = qibuild_action.add_test_project("testjni")
    project.configure()
    project.build()

    jar_dirname = os.path.join(os.getcwd(), "./path/to/jar")
    jarname = "test.jar"
    qisys.sh.mkdir(jar_dirname, recursive=True)
    assert os.path.exists(jar_dirname)

    jar_path = os.path.join(jar_dirname, jarname)
    jar_path = jar.jar(jar_path, ["one", "two", "three", "four"], get_paths())
    assert os.path.exists(jar_path)
Beispiel #8
0
def test_jar_path(qibuild_action, qimvn_action):
    """ Test if jar command can create jar in a specified directory
    """
    project = qibuild_action.add_test_project("testjni")
    project.configure()
    project.build()

    jar_dirname = os.path.join(os.getcwd(), "./path/to/jar")
    jarname = "test.jar"
    qisys.sh.mkdir(jar_dirname, recursive=True)
    assert os.path.exists(jar_dirname)

    jar_path = os.path.join(jar_dirname, jarname)
    jar_path = jar.jar(jar_path, ["one", "two", "three", "four"], get_paths())
    assert os.path.exists(jar_path)
Beispiel #9
0
def test_package_multiple_target(qibuild_action, qimvn_action):
    """ Test if jar command can package multiple element.
    """
    project = qibuild_action.add_test_project("testjni")
    project.configure()
    project.build()

    jarname = "test.jar"
    jarpath = jar.jar(jarname, ["one", "two", "three", "four"], get_paths())
    assert jarpath
    assert os.path.exists(jarpath)
    assert qimvn_action.is_in_jar(jarpath, "idontexist") == False
    assert qimvn_action.is_in_jar(jarpath, "one")
    assert qimvn_action.is_in_jar(jarpath, "two")
    assert qimvn_action.is_in_jar(jarpath, "three")
    assert qimvn_action.is_in_jar(jarpath, "four")
Beispiel #10
0
def test_package_multiple_target(qibuild_action, qimvn_action):
    """ Test if jar command can package multiple element.
    """
    project = qibuild_action.add_test_project("testjni")
    project.configure()
    project.build()

    jarname = "test.jar"
    jarpath = jar.jar(jarname, ["one", "two", "three", "four"], get_paths())
    assert jarpath
    assert os.path.exists(jarpath)
    assert qimvn_action.is_in_jar(jarpath, "idontexist") == False
    assert qimvn_action.is_in_jar(jarpath, "one")
    assert qimvn_action.is_in_jar(jarpath, "two")
    assert qimvn_action.is_in_jar(jarpath, "three")
    assert qimvn_action.is_in_jar(jarpath, "four")
Beispiel #11
0
def test_deploy(qibuild_action, local_repository):
    """ Test if directory where jar must be deployed exists.
    """
    qibuild_action.add_test_project("hellojavajni")
    qibuild_action("configure", "hellojavajni")
    qibuild_action("make", "hellojavajni")

    jarname = "test.jar"
    jarpath = jar.jar(jarname, ["hellojavajni"], get_paths())
    assert jarpath

    deploy_path = local_repository.replace("file://", "")
    artifactId = "hellojavajni"
    ver = "1.0"
    assert deploy.deploy("com.test", ver, artifactId, jarname, local_repository) == 0
    deploy_path = os.path.join(deploy_path, "com/test")
    deploy_path = os.path.join(deploy_path, artifactId)
    deploy_path = os.path.join(deploy_path, ver)
    deployed_jar = os.path.join(deploy_path, artifactId + "-" + ver + ".jar")
    assert os.path.exists(deployed_jar)
Beispiel #12
0
def test_toolchain(tmpdir, monkeypatch, qimvn_action):
    """ Test packaging using a toolchain
    """
    monkeypatch.chdir(tmpdir)
    qibuild_action = QiBuildAction()
    qitoolchain_action = QiToolchainAction()
    build_worktree = qibuild_action.build_worktree
    qibuild_action.add_test_project("world")
    qibuild_action.add_test_project("hello")
    world_package = qibuild_action("package", "world")
    qitoolchain_action("create", "foo")
    qitoolchain_action("add-package", "-c", "foo", "world", world_package)

    qibuild_action.chdir("hello")
    qibuild_action("configure", "-c", "foo")
    qibuild_action("make", "-c", "foo")

    jarname = "test.jar"
    jarpath = jar.jar(jarname, ["hello", "world"], get_paths(config="foo"))
    assert jarpath
    assert os.path.exists(jarpath)
    assert os.path.exists(os.path.join("./", jarname))
Beispiel #13
0
def test_toolchain(tmpdir, monkeypatch, qimvn_action):
    """ Test packaging using a toolchain
    """
    monkeypatch.chdir(tmpdir)
    qibuild_action = QiBuildAction()
    qitoolchain_action = QiToolchainAction()
    build_worktree = qibuild_action.build_worktree
    qibuild_action.add_test_project("world")
    qibuild_action.add_test_project("hello")
    world_package = qibuild_action("package", "world")
    qitoolchain_action("create", "foo")
    qitoolchain_action("add-package", "-c", "foo", world_package)

    qibuild_action.chdir("hello")
    qibuild_action("configure", "-c", "foo")
    qibuild_action("make", "-c", "foo")

    jarname = "test.jar"
    jarpath = jar.jar(jarname, ["hello", "world"], get_paths(config="foo"))
    assert jarpath
    assert os.path.exists(jarpath)
    assert os.path.exists(os.path.join("./", jarname))