[arch-commits] Commit in (11 files)
Guillaume Alaux
guillaume at archlinux.org
Sat Jul 26 19:16:45 UTC 2014
Date: Saturday, July 26, 2014 @ 21:16:45
Author: guillaume
Revision: 218206
First version of Java common files
Added:
java-common/
java-common/repos/
java-common/trunk/
java-common/trunk/PKGBUILD
java-common/trunk/bin_archlinux-java
java-common/trunk/bin_java-common-wrapper
java-common/trunk/install_java-common.sh
java-common/trunk/profile_jre.csh
java-common/trunk/profile_jre.sh
java-common/trunk/test_archlinux-java
Modified:
java-meta/trunk/PKGBUILD
-------------------------------------------+
java-common/trunk/PKGBUILD | 41 +++
java-common/trunk/bin_archlinux-java | 195 ++++++++++++++++++
java-common/trunk/bin_java-common-wrapper | 2
java-common/trunk/install_java-common.sh | 9
java-common/trunk/profile_jre.csh | 4
java-common/trunk/profile_jre.sh | 4
java-common/trunk/test_archlinux-java | 300 ++++++++++++++++++++++++++++
java-meta/trunk/PKGBUILD | 2
8 files changed, 557 insertions(+)
Added: java-common/trunk/PKGBUILD
===================================================================
--- java-common/trunk/PKGBUILD (rev 0)
+++ java-common/trunk/PKGBUILD 2014-07-26 19:16:45 UTC (rev 218206)
@@ -0,0 +1,41 @@
+# Maintainer: Guillaume ALAUX <guillaume at archlinux.org>
+pkgname=java-common
+pkgver=1
+pkgrel=1
+pkgdesc='Common files for Java Environments'
+arch=('any')
+url='www.archlinux.org'
+license=('GPL')
+checkdepends=('wget')
+backup=(etc/profile.d/jre.sh
+ etc/profile.d/jre.csh)
+# TODO remove after a while
+replaces=('java-runtime-headless-meta' 'java-runtime-meta' 'java-environment-meta')
+install=install_java-common.sh
+source=(profile_jre.csh
+ profile_jre.sh
+ bin_archlinux-java
+ test_archlinux-java
+ bin_java-common-wrapper
+ https://shunit2.googlecode.com/files/shunit2-2.1.6.tgz)
+
+sha256sums=('9f0032e47705ce55a615ab3b942720b8447f490d1ff430b214038b81c3019ac2'
+ '8dbafa311f34d23c5bbef71fa942b97b224ebeb330b36195f22a1836285bbb83'
+ 'd54f54e79ee8104783a12fa7e55f9826f80c26142b1d89a34ffe2529ed78d962'
+ '90c1ca2f32aedf684048e1c072e03eff6b919a10b9b0e83b182186e7572d11c6'
+ '622927af9ec374140a878993936f7fdd4206fe069dddfcefc6d4e15fa6d67f39'
+ '65a313a76fd5cc1c58c9e19fbc80fc0e418a4cbfbd46d54b35ed5b6e0025d4ee')
+
+check() {
+ cd "${srcdir}"
+ ./test_archlinux-java
+}
+
+build() {
+ cd "${srcdir}"
+
+ install -D -m 644 profile_jre.sh "${pkgdir}/etc/profile.d/jre.sh"
+ install -D -m 644 profile_jre.csh "${pkgdir}/etc/profile.d/jre.csh"
+ install -D -m 755 bin_java-common-wrapper "${pkgdir}/usr/share/java-common-wrapper"
+ install -D -m 755 bin_archlinux-java "${pkgdir}/usr/bin/archlinux-java"
+}
Property changes on: java-common/trunk/PKGBUILD
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Added: java-common/trunk/bin_archlinux-java
===================================================================
--- java-common/trunk/bin_archlinux-java (rev 0)
+++ java-common/trunk/bin_archlinux-java 2014-07-26 19:16:45 UTC (rev 218206)
@@ -0,0 +1,195 @@
+#! /bin/bash
+
+# Arch Linux helper script to set/unset/check/fix the enabled Java environment
+# This program may be freely redistributed under the terms of the GNU General Public License
+#
+# Author: Guillaume ALAUX <guillaume at archlinux.org>
+
+JVM_DIR=/usr/lib/jvm
+DEFAULT_NAME=java-default-runtime
+DEFAULT_PATH=${JVM_DIR}/${DEFAULT_NAME}
+BIN_PATH=/usr/bin
+WRAPPER_PATH=/usr/share/java-common-wrapper
+
+
+# Utility functions
+
+check_root() {
+ if [ $(id -u) -ne 0 ]; then
+ echo 'This script must be run as root'
+ exit 1
+ fi
+}
+
+# $1: parameter count given to this script for this option
+# $2: expected parameter count for this option
+check_param_count() {
+ if [ $1 -ne $2 ]; then
+ echo 'Wrong parameter count'
+ exit 2
+ fi
+}
+
+# Second level functions
+
+get_default_java() {
+ path=$(readlink -e ${DEFAULT_PATH})
+ echo ${path/${JVM_DIR}\/}
+}
+
+get_installed_javas() {
+ if [ -d ${JVM_DIR} ]; then
+ for dir in $(find ${JVM_DIR} -mindepth 1 -maxdepth 1 -type d | sort); do
+ if [ -x ${dir}/bin/javac ]; then
+ javas+=(${dir/${JVM_DIR}\/})
+ else
+ if [ -x ${dir}/jre/bin/java ]; then
+ javas+=(${dir/${JVM_DIR}\/}/jre)
+ fi
+ fi
+ done
+ fi
+ echo ${javas[@]}
+}
+
+# $1: Java environment name to test. MUST NOT BE "${DEFAULT_NAME}"
+is_java_valid() {
+ test "x$1" != "x${DEFAULT_NAME}" && test -x ${JVM_DIR}/$1/bin/java
+}
+
+set_bin_links() {
+ find -L ${BIN_PATH} -samefile ${WRAPPER_PATH} \
+ | while read lpath; do
+ if [ ! -x "${DEFAULT_PATH}/bin/$(basename ${lpath})" ]; then
+ unlink ${lpath} 2>/dev/null
+ fi
+ done
+
+ find ${DEFAULT_PATH}/bin ! -type d -perm /a=x \
+ | while read bpath; do
+ ln -sf ${WRAPPER_PATH} ${BIN_PATH}/$(basename ${bpath}) > /dev/null 2>&1
+ done
+}
+
+# $1: Java environment name to set as default
+set_default_to() {
+ check_root
+ ln -sf $1 ${DEFAULT_PATH}
+ set_bin_links
+ parent_dir=$(dirname $1)
+ if is_java_valid ${parent_dir}; then
+ echo "Warning: '${parent_dir}' looks like a valid JDK whereas you are only setting '$1' as default"
+ echo "Fix this with 'archlinux-java --force-set ${parent_dir}'"
+ fi
+}
+
+unset_default() {
+ check_root
+ find ${DEFAULT_PATH}/bin ! -type d -perm /a=x \
+ | while read bpath; do
+ unlink ${BIN_PATH}/$(basename ${bpath}) 2>/dev/null
+ done
+ unlink ${DEFAULT_PATH} 2>/dev/null
+}
+
+# First level functions
+
+give_status() {
+ installed_java=($(get_installed_javas))
+ default_java=$(get_default_java)
+ if [ ${#installed_java[@]} -eq 0 ]; then
+ echo 'No compatible Java environment installed'
+ else
+ echo 'Available Java environments:'
+ for java in ${installed_java[@]}; do
+ if [ ${java} = "${default_java}" ]; then
+ echo -e " ${java} (default)"
+ else
+ echo " ${java}"
+ fi
+ done
+ if [ -z ${default_java} ]; then
+ echo "No Java environment set as default"
+ fi
+ fi
+}
+
+# $1: Java environment name to try to set
+try_set_default() {
+ default_java=$(get_default_java)
+ if ! is_java_valid ${default_java} || [ "x${default_java}" = "x$1/jre" ]; then
+ force_set_default $1
+ else
+ echo "The default Java environment is already set to ${default_java}"
+ echo "Please use 'archlinux-java --force-set $1' if you want to force it"
+ fi
+}
+
+# $1: Java environment name to set as default
+force_set_default() {
+ check_root
+ if is_java_valid $1; then
+ if [ "x$(get_default_java ${DEFAULT_PATH})" != "x" ]; then
+ unset_default
+ fi
+ set_default_to $1
+ else
+ echo "'${JVM_DIR}/$1' is not a valid Java environment path"
+ exit 3
+ fi
+}
+
+# $1: Java environment name to try to unset
+try_unset_default() {
+ default=$(get_default_java)
+ if [ "x${default}" != "x" -a "x${default}" = "x$1" ]; then
+ unset_default
+ else
+ echo "'$1' is not set as default Java environment"
+ fi
+}
+
+fix_default() {
+ default=$(get_default_java)
+ if is_java_valid ${default}; then
+ if is_java_valid $(dirname ${default}); then
+ unset_default
+ set_default_to $(dirname ${default})
+ fi
+ else
+ if [ "x${default}" != "x" ]; then
+ unset_default
+ fi
+ to_check=('java-7-openjdk' 'java-7-openjdk/jre' $(get_installed_javas))
+ for java in ${to_check[@]}; do
+ if ! is_java_valid $(get_default_java) && is_java_valid ${java}; then
+ set_default_to ${java}
+ fi
+ done
+ fi
+ if is_java_valid $(get_default_java); then
+ set_bin_links
+ else
+ echo 'No valid Java environment found'
+ fi
+}
+
+usage() {
+ echo "$(basename $0) [ --status | --try-set <JAVA_ENV> | --force-set <JAVA_ENV> | --try-unset <JAVA_ENV> | --fix ]"
+ echo -e "\n\t<JAVA_ENV> must be the name of a Java environment directory available in ${JVM_DIR}\n"
+ echo -e '\t--status\t\tList installed Java environments and enabled one'
+ echo -e '\t--try-set <JAVA_ENV>\tIf no Java environments is already set as default, set this one'
+ echo -e '\t--force-set <JAVA_ENV>\tForce <JAVA_ENV> as default'
+ echo -e '\t--try-unset <JAVA_ENV>\tIf <JAVA_ENV> is set as default, unset it'
+ echo -e '\t--fix\t\t\tFix an invalid default Java environment'
+}
+
+## Main
+case $1 in
+ '--status') give_status;;
+ '--try-set') check_param_count $# 2; try_set_default $2;;
+ '--force-set') check_param_count $# 2; force_set_default $2;;
+ '--try-unset') check_param_count $# 2; try_unset_default $2;;
+ '--fix') fix_default;;
+ *) usage;;
+esac
Property changes on: java-common/trunk/bin_archlinux-java
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: java-common/trunk/bin_java-common-wrapper
===================================================================
--- java-common/trunk/bin_java-common-wrapper (rev 0)
+++ java-common/trunk/bin_java-common-wrapper 2014-07-26 19:16:45 UTC (rev 218206)
@@ -0,0 +1,2 @@
+#!/bin/bash
+exec "${JAVA_HOME:-/usr/lib/jvm/java-default-runtime}/bin/${0##*/}" "$@"
Property changes on: java-common/trunk/bin_java-common-wrapper
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: java-common/trunk/install_java-common.sh
===================================================================
--- java-common/trunk/install_java-common.sh (rev 0)
+++ java-common/trunk/install_java-common.sh 2014-07-26 19:16:45 UTC (rev 218206)
@@ -0,0 +1,9 @@
+post_install() {
+ echo 'Installing multiple non-conflicting Java environments is now supported.'
+ echo 'Check the following wiki section for more info:'
+ echo ' https://wiki.archlinux.org/index.php/Java#Multiple_official_Java_environments'
+}
+
+post_upgrade() {
+ post_install "$@"
+}
Added: java-common/trunk/profile_jre.csh
===================================================================
--- java-common/trunk/profile_jre.csh (rev 0)
+++ java-common/trunk/profile_jre.csh 2014-07-26 19:16:45 UTC (rev 218206)
@@ -0,0 +1,4 @@
+# Do not change this unless you want to completely by-pass Arch Linux' way
+# of handling Java versions and vendors. Instead, please use script `archlinux-java`
+# to change what /usr/lib/jvm/java-default-runtime points at.
+setenv JAVA_HOME "/usr/lib/jvm/java-default-runtime"
Added: java-common/trunk/profile_jre.sh
===================================================================
--- java-common/trunk/profile_jre.sh (rev 0)
+++ java-common/trunk/profile_jre.sh 2014-07-26 19:16:45 UTC (rev 218206)
@@ -0,0 +1,4 @@
+# Do not change this unless you want to completely by-pass Arch Linux' way
+# of handling Java versions and vendors. Instead, please use script `archlinux-java`
+# to change what /usr/lib/jvm/java-default-runtime points at.
+export JAVA_HOME=/usr/lib/jvm/java-default-runtime
Added: java-common/trunk/test_archlinux-java
===================================================================
--- java-common/trunk/test_archlinux-java (rev 0)
+++ java-common/trunk/test_archlinux-java 2014-07-26 19:16:45 UTC (rev 218206)
@@ -0,0 +1,300 @@
+#! /bin/sh
+#
+# To run this script, ensure shunit2 (https://code.google.com/p/shunit2/)
+# is available on the local directory, then just run sh bin_archlinux-java_tests
+#
+# inotifywait -r -m -e MODIFY . | while read l; do sh bin_archlinux-java_tests; done
+
+declare test_dir
+
+. ./bin_archlinux-java > /dev/null
+
+INIT_JVM_DIR=${JVM_DIR}
+INIT_DEFAULT_PATH=${DEFAULT_PATH}
+INIT_BIN_PATH=${BIN_PATH}
+INIT_WRAPPER_PATH=${WRAPPER_PATH}
+
+# Redefining this so that tested script can be invoked without root privileges
+check_root() {
+ true
+}
+
+
+get_rand_str() {
+ echo $(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1)
+}
+
+setUp() {
+ test_dir=$(mktemp -d)
+ JVM_DIR=${test_dir}${INIT_JVM_DIR}
+ DEFAULT_PATH=${test_dir}${INIT_DEFAULT_PATH}
+ JAVA_NAME=$(get_rand_str)
+ BIN_PATH=${test_dir}${INIT_BIN_PATH}
+ mkdir -p ${BIN_PATH}
+ WRAPPER_PATH=${test_dir}${INIT_WRAPPER_PATH}
+ mkdir -p $(dirname ${WRAPPER_PATH})
+ touch ${WRAPPER_PATH}
+ chmod +x ${WRAPPER_PATH}
+}
+
+tearDown() {
+ rm -rf ${test_dir}
+}
+
+
+# $1: path of Java environment to create
+create_valid_jre_env() {
+ mkdir -p ${JVM_DIR}/$1/bin
+ touch ${JVM_DIR}/$1/bin/java
+ chmod +x ${JVM_DIR}/$1/bin/java
+}
+
+# $1: path of Java environment to create
+create_valid_jdk_env() {
+ create_valid_jre_env "$1"
+ touch ${JVM_DIR}/$1/bin/javac
+ chmod +x ${JVM_DIR}/$1/bin/javac
+ create_valid_jre_env "$1/jre"
+}
+
+set_default_for_test() {
+ ln -s $1 ${DEFAULT_PATH}
+ ln -s ${WRAPPER_PATH} ${BIN_PATH}/java
+ if [ -x ${DEFAULT_PATH}/bin/javac ]; then
+ ln -s ${WRAPPER_PATH} ${BIN_PATH}/javac
+ fi
+}
+
+assertDefaultNotSet() {
+ assertNull 'Default is set' "$(readlink ${DEFAULT_PATH})"
+ assertNull "PATH has a java binary" "$(readlink ${BIN_PATH}/java)"
+ assertNull "PATH has a javac binary" "$(readlink ${BIN_PATH}/javac)"
+}
+
+assertDefaultSetTo() {
+ assertEquals "Default is not set to $1" "$1" "$(readlink ${DEFAULT_PATH})"
+ assertEquals "PATH has no java binary" "${WRAPPER_PATH}" "$(readlink ${BIN_PATH}/java)"
+ if [ -d ${DEFAULT_PATH}/jre ]; then
+ assertEquals "PATH has no javac binary" "${WRAPPER_PATH}" "$(readlink ${BIN_PATH}/javac)"
+ fi
+}
+
+
+test_valid_java_env_valid() {
+ create_valid_jre_env "${JAVA_NAME}/jre"
+ assertTrue 'Does not detect valid Java env' "is_java_valid ${JAVA_NAME}/jre"
+}
+
+test_valid_java_env_not_valid() {
+ create_valid_jre_env "non_existing"
+ assertFalse 'Does not detect invalid Java env' "is_java_valid ${JAVA_NAME}/jre"
+}
+
+test_get_default_java() {
+ create_valid_jre_env "${JAVA_NAME}/jre"
+ set_default_for_test "${JAVA_NAME}/jre"
+ assertEquals 'Wrong default Java found' "${JAVA_NAME}/jre" "$(get_default_java)"
+}
+
+test_get_default_java_no_default() {
+ create_valid_jre_env "${JAVA_NAME}/jre"
+ assertNull 'Wrong default Java found' "$(get_default_java)"
+}
+
+test_get_installed_javas() {
+ JAVA_NAME_FIRST_ALPHA="a$(get_rand_str)"
+ JAVA_NAME_SECON_ALPHA="b$(get_rand_str)"
+ JAVA_NAME_THIRD_ALPHA="c$(get_rand_str)"
+ create_valid_jre_env "${JAVA_NAME_FIRST_ALPHA}/jre"
+ create_valid_jre_env "${JAVA_NAME_SECON_ALPHA}/jre"
+ create_valid_jdk_env "${JAVA_NAME_THIRD_ALPHA}"
+ list=($(get_installed_javas | sort))
+ expected=("${JAVA_NAME_FIRST_ALPHA}/jre" "${JAVA_NAME_SECON_ALPHA}/jre" "${JAVA_NAME_THIRD_ALPHA}")
+ assertTrue "Did not find installed Java environments" "[ '${expected[*]}' == '${list[*]}' ]"
+}
+
+test_get_installed_javas_no_env() {
+ list=($(get_installed_javas))
+ expected=()
+ assertEquals "List of installed Java envs is not 0" 0 "${#list[@]}"
+}
+
+test_set_default_to() {
+ create_valid_jre_env "${JAVA_NAME}/jre"
+ set_default_to "${JAVA_NAME}/jre"
+ assertEquals 'Success does not yield 0' 0 $?
+ assertDefaultSetTo "${JAVA_NAME}/jre"
+}
+
+test_set_default_to_jre_but_jdk() {
+ create_valid_jdk_env "${JAVA_NAME}"
+ output=$(set_default_to "${JAVA_NAME}/jre")
+ mess="Warning: '${JAVA_NAME}' looks like a valid JDK"
+ mess+=" whereas you are only setting '${JAVA_NAME}/jre' as default"
+ mess+="\nFix this with 'archlinux-java --force-set ${JAVA_NAME}'"
+ expected=$(echo -e ${mess})
+ assertEquals 'Wrong message' "${expected}" "${output}"
+ assertDefaultSetTo "${JAVA_NAME}/jre"
+}
+
+tests_unset_default() {
+ create_valid_jre_env "${JAVA_NAME}/jre"
+ set_default_for_test "${JAVA_NAME}/jre"
+ unset_default
+ assertEquals 'Success does not yield 0' 0 $?
+ assertTrue 'Link was not unset' "[ ! -e ${DEFAULT_PATH} ]"
+}
+
+test_give_status() {
+ JAVA_NAME_1="a$(get_rand_str)"
+ JAVA_NAME_2="b$(get_rand_str)"
+ create_valid_jre_env "${JAVA_NAME_1}/jre"
+ set_default_for_test "${JAVA_NAME_1}/jre"
+ create_valid_jdk_env "${JAVA_NAME_2}"
+ expected=$(echo -e "Available Java environments:\n ${JAVA_NAME_1}/jre (default)\n ${JAVA_NAME_2}")
+ assertEquals 'Wrong status output' "${expected}" "$(give_status)"
+}
+
+test_give_status_no_default() {
+ JAVA_NAME_1="a$(get_rand_str)"
+ JAVA_NAME_2="b$(get_rand_str)"
+ create_valid_jre_env "${JAVA_NAME_1}/jre"
+ create_valid_jdk_env "${JAVA_NAME_2}"
+ mess="Available Java environments:"
+ mess+="\n ${JAVA_NAME_1}/jre"
+ mess+="\n ${JAVA_NAME_2}"
+ mess+="\nNo Java environment set as default"
+ expected=$(echo -e "${mess}")
+ assertEquals 'Wrong status output' "${expected}" "$(give_status)"
+}
+
+test_give_status_no_javas() {
+ output=$(give_status)
+ assertEquals 'Wrong status output' 'No compatible Java environment installed' "${output}"
+}
+
+test_try_set_default_no_default() {
+ create_valid_jre_env "${JAVA_NAME}/jre"
+ try_set_default "${JAVA_NAME}/jre"
+ assertDefaultSetTo "${JAVA_NAME}/jre"
+}
+
+test_try_set_default_default_exists() {
+ create_valid_jre_env "${JAVA_NAME}/jre"
+ set_default_for_test "${JAVA_NAME}/jre"
+ output=$(try_set_default "${JAVA_NAME}/jre")
+ mess="The default Java environment is already set to ${JAVA_NAME}/jre"
+ mess+="\nPlease use 'archlinux-java --force-set ${JAVA_NAME}/jre' if you want to force it"
+ expected=$(echo -e "${mess}")
+ assertEquals 'Wrong message' "${expected}" "${output}"
+ assertDefaultSetTo "${JAVA_NAME}/jre"
+}
+
+test_try_set_default_default_invalid() {
+ create_valid_jre_env "${JAVA_NAME}/jre"
+ set_default_for_test "non_existing"
+ try_set_default "${JAVA_NAME}/jre"
+ assertDefaultSetTo "${JAVA_NAME}/jre"
+}
+
+test_try_set_default_jdk_where_jre_is_default() {
+ create_valid_jdk_env "${JAVA_NAME}"
+ set_default_for_test "${JAVA_NAME}/jre"
+ try_set_default "${JAVA_NAME}"
+ assertDefaultSetTo "${JAVA_NAME}"
+}
+
+test_force_set_default_no_default() {
+ create_valid_jre_env "${JAVA_NAME}/jre"
+ force_set_default "${JAVA_NAME}/jre"
+ assertDefaultSetTo "${JAVA_NAME}/jre"
+}
+
+test_force_set_default_with_default() {
+ create_valid_jre_env "${JAVA_NAME}/jre"
+ set_default_for_test "${JAVA_NAME}/jre"
+ JAVA_NAME_2="$(get_rand_str)"
+ create_valid_jre_env "${JAVA_NAME_2}/jre"
+ force_set_default "${JAVA_NAME_2}/jre"
+ assertDefaultSetTo "${JAVA_NAME_2}/jre"
+}
+
+test_force_set_default_target_invalid() {
+ create_valid_jre_env "${JAVA_NAME}/jre"
+ output=$(force_set_default "non_existing")
+ expected="'${JVM_DIR}/non_existing' is not a valid Java environment path"
+ assertEquals 'Wrong message' "${expected}" "${output}"
+ assertDefaultNotSet
+}
+
+#no_default
+test_try_unset_default_no_default() {
+ create_valid_jdk_env "${JAVA_NAME}"
+ output=$(try_unset_default "${JAVA_NAME}")
+ expected="'${JAVA_NAME}' is not set as default Java environment"
+ assertEquals 'Wrong message' "${expected}" "${output}"
+ assertDefaultNotSet
+}
+
+test_try_unset_default_default_not_target() {
+ create_valid_jre_env "${JAVA_NAME}/jre"
+ set_default_for_test "${JAVA_NAME}/jre"
+ output=$(try_unset_default "other_java")
+ expected="'other_java' is not set as default Java environment"
+ assertEquals 'Wrong message' "${expected}" "${output}"
+ assertDefaultSetTo "${JAVA_NAME}/jre"
+}
+
+test_try_unset_default_default_is_target() {
+ create_valid_jre_env "${JAVA_NAME}/jre"
+ set_default_for_test "${JAVA_NAME}/jre"
+ try_unset_default "${JAVA_NAME}/jre"
+ assertDefaultNotSet
+}
+
+test_fix_default_default_valid() {
+ create_valid_jre_env "${JAVA_NAME}/jre"
+ set_default_for_test "${JAVA_NAME}/jre"
+ fix_default
+ assertDefaultSetTo "${JAVA_NAME}/jre"
+}
+
+test_fix_default_no_default() {
+ create_valid_jre_env "${JAVA_NAME}/jre"
+ fix_default
+ assertDefaultSetTo "${JAVA_NAME}/jre"
+}
+
+test_fix_default_default_invalid_openjdk7_jdk_installed() {
+ create_valid_jdk_env "java-7-openjdk"
+ fix_default
+ assertDefaultSetTo "java-7-openjdk"
+}
+
+test_fix_default_default_invalid_openjdk7_jre_installed() {
+ create_valid_jre_env "java-7-openjdk/jre"
+ fix_default
+ assertDefaultSetTo "java-7-openjdk/jre"
+}
+
+test_fix_default_default_invalid_random_java_installed() {
+ create_valid_jdk_env "${JAVA_NAME}"
+ fix_default
+ assertDefaultSetTo "${JAVA_NAME}"
+}
+
+test_fix_default_default_invalid_no_java_installed() {
+ assertEquals 'Wrong message' "No valid Java environment found" "$(fix_default)"
+ assertDefaultNotSet
+}
+
+test_fix_default_jre_but_jdk_exists() {
+ create_valid_jdk_env "${JAVA_NAME}"
+ set_default_for_test "${JAVA_NAME}/jre"
+ fix_default
+ assertDefaultSetTo "${JAVA_NAME}"
+}
+
+
+# load shunit2
+. shunit2-2.1.6/src/shunit2
Property changes on: java-common/trunk/test_archlinux-java
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: java-meta/trunk/PKGBUILD
===================================================================
--- java-meta/trunk/PKGBUILD 2014-07-26 17:31:20 UTC (rev 218205)
+++ java-meta/trunk/PKGBUILD 2014-07-26 19:16:45 UTC (rev 218206)
@@ -9,6 +9,8 @@
checkdepends=('wget')
backup=(etc/profile.d/jre.sh
etc/profile.d/jre.csh)
+# TODO remove after a while
+replaces=('java-runtime-headless-meta' 'java-runtime-meta' 'java-environment-meta')
# TODO rename
install=install_java-runtime-headless-meta.sh
source=(profile_jre.csh
More information about the arch-commits
mailing list