Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1a9ea46

Browse files
committed
Merge branch 'version3' into feature/unit_tests
2 parents f2f954a + 62c4522 commit 1a9ea46

155 files changed

Lines changed: 1394 additions & 76 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
sudo: required
2+
3+
language: bash
4+
5+
env:
6+
global:
7+
- ORACLE_COOKIE=sqldev
8+
- ORACLE_FILE=oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip
9+
- ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
10+
- NLS_LANG=AMERICAN_AMERICA.AL32UTF8
11+
- ORACLE_BASE=/u01/app/oracle
12+
- LD_LIBRARY_PATH=$ORACLE_HOME/lib
13+
- PATH=$PATH:$ORACLE_HOME/jdbc/lib:$ORACLE_HOME/bin
14+
- DATABASE_VERSION=11.2.0.2
15+
- ORACLE_SID=XE
16+
- DATABASE_NAME=XE
17+
- ORA_SDTZ='Europe/London' #Needed as a client parameter
18+
- TZ='Europe/London' #Needed as a DB Server parameter
19+
20+
addons:
21+
apt:
22+
packages:
23+
#packages required by oracle
24+
- bc
25+
- rpm
26+
- unzip
27+
# - libaio1
28+
29+
30+
cache:
31+
directories:
32+
- .cache
33+
- $HOME/.cache
34+
35+
before_install:
36+
# On trusty, download the zip file into a cachable directory
37+
- test "$DIST" = precise || export ORACLE_ZIP_DIR=$HOME/.cache
38+
# If the zip file already exists, do not download it again
39+
- test -f "$ORACLE_ZIP_DIR"/$(basename $ORACLE_FILE) || bash .travis/oracle/download.sh
40+
41+
install:
42+
- bash .travis/oracle/install.sh
43+
44+
script:
45+
- bash install.sh
46+
- bash examples.sh
47+
- bash test.sh
48+
49+
notifications:
50+
slack: utplsql:oiMuXO95TvKeAUENuDt4cPrB
51+

.travis/oracle/LICENSE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Copyright (c) 2013, Christopher Bandy
2+
3+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
4+
5+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

.travis/oracle/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
[![Build](https://travis-ci.org/cbandy/travis-oracle.svg?branch=master)](https://travis-ci.org/cbandy/travis-oracle)
2+
3+
Use [Oracle Database Express Edition][] in your builds on [Travis CI][].
4+
5+
[Oracle Database Express Edition]: http://www.oracle.com/technetwork/database/database-technologies/express-edition/overview/index.html
6+
[Travis CI]: https://travis-ci.org/
7+
8+
9+
Usage
10+
-----
11+
12+
To use this tool, you must have an Oracle account with which you have accepted
13+
the current license agreement for [Oracle Database Express Edition][].
14+
15+
1. Add your Oracle username and password to your build [environment variables][],
16+
either as hidden repository settings or encrypted variables:
17+
18+
| Variable Name | Value |
19+
| -------------------------- | ------------- |
20+
| `ORACLE_LOGIN_ssousername` | your username |
21+
| `ORACLE_LOGIN_password` | your password |
22+
23+
2. Add the version information to your build environment variables:
24+
25+
```yaml
26+
- ORACLE_COOKIE=sqldev
27+
- ORACLE_FILE=oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip
28+
- ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
29+
- ORACLE_SID=XE
30+
```
31+
32+
3. Download and extract the [latest release][] into your project. For example,
33+
34+
```shell
35+
wget 'https://github.com/cbandy/travis-oracle/archive/v2.0.0.tar.gz'
36+
mkdir -p .travis/oracle
37+
tar xz --strip-components 1 -C .travis/oracle -f v2.0.0.tar.gz
38+
```
39+
40+
4. Enable [`sudo`](https://docs.travis-ci.com/user/workers/standard-infrastructure/):
41+
42+
```yaml
43+
sudo: required
44+
```
45+
46+
5. Finally, execute the extracted scripts as part of your build, usually
47+
during [`before_install`](https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle):
48+
49+
```yaml
50+
- .travis/oracle/download.sh
51+
- .travis/oracle/install.sh
52+
```
53+
54+
[SQL\*Plus][] is installed to `$ORACLE_HOME/bin/sqlplus`, and the current user
55+
has both normal and DBA access without a password, i.e. `/` and `/ AS SYSDBA`.
56+
57+
[OCI][] and [OCCI][] libraries and header files are in `$ORACLE_HOME/lib` and
58+
`$ORACLE_HOME/rdbms/public`, respectively.
59+
60+
[environment variables]: https://docs.travis-ci.com/user/environment-variables/
61+
[latest release]: https://github.com/cbandy/travis-oracle/releases/latest
62+
[OCCI]: http://www.oracle.com/pls/topic/lookup?ctx=xe112&id=LNCPP
63+
[OCI]: http://www.oracle.com/pls/topic/lookup?ctx=xe112&id=LNOCI
64+
[SQL\*Plus]: http://www.oracle.com/pls/topic/lookup?ctx=xe112&id=SQPUG

.travis/oracle/download.js

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
// vim: set et sw=2 ts=2:
2+
"use strict";
3+
4+
var fs = require('fs');
5+
6+
var env = process.env;
7+
var Promise = require('bluebird');
8+
var Phantom = Promise.promisifyAll(require('node-phantom-simple'));
9+
var PhantomError = require('node-phantom-simple/headless_error');
10+
11+
if (env['ORACLE_ZIP_DIR']) {
12+
var directory = env['ORACLE_ZIP_DIR'];
13+
if (!fs.existsSync(directory)) {
14+
fs.mkdirSync(directory);
15+
}
16+
process.chdir(directory);
17+
}
18+
19+
Phantom.createAsync({ parameters: { 'ssl-protocol': 'tlsv1' } }).then(function (browser) {
20+
browser = Promise.promisifyAll(browser, { suffix: 'Promise' });
21+
22+
// Configure the browser, open a tab
23+
return browser
24+
.addCookiePromise({'name': 'oraclelicense', 'value': "accept-" + env['ORACLE_COOKIE'] + "-cookie", 'domain': '.oracle.com' })
25+
.then(function () {
26+
return browser.createPagePromise();
27+
})
28+
.then(function (page) {
29+
page = Promise.promisifyAll(page, { suffix: 'Promise' });
30+
31+
// Configure the tab
32+
page.onResourceError = console.error.bind(console);
33+
return page
34+
.setPromise('settings.userAgent', env['USER_AGENT']) // PhantomJS configures the UA per tab
35+
36+
// Request the file, wait for the login page
37+
.then(function () {
38+
return page.openPromise("https://edelivery.oracle.com/akam/otn/linux/" + env['ORACLE_FILE']).then(function (status) {
39+
if (status != 'success') throw "Unable to connect to oracle.com";
40+
return page.waitForSelectorPromise('input[type=password]', 5000);
41+
})
42+
.catch(PhantomError, function (err) {
43+
return page.getPromise('plainText').then(function (text) {
44+
console.error("Unable to load login page. Last response was:\n" + text);
45+
throw err;
46+
});
47+
});
48+
})
49+
50+
// Export cookies for cURL
51+
.then(function () {
52+
return page.getPromise('cookies').then(function (cookies) {
53+
var data = "";
54+
for (var i = 0; i < cookies.length; ++i) {
55+
var cookie = cookies[i];
56+
data += cookie.domain + "\tTRUE\t" + cookie.path + "\t"
57+
+ (cookie.secure ? "TRUE" : "FALSE") + "\t0\t"
58+
+ cookie.name + "\t" + cookie.value + "\n";
59+
}
60+
return Promise.promisifyAll(require('fs')).writeFileAsync(env['COOKIES'], data);
61+
});
62+
})
63+
64+
// Submit the login form using cURL
65+
.then(function () {
66+
return page.evaluatePromise(function () {
67+
var $form = jQuery(document.forms[0]);
68+
return {
69+
action: $form.prop('action'),
70+
data: $form.serialize()
71+
};
72+
})
73+
.then(function (form) {
74+
return browser.exitPromise().then(function () {
75+
for (var key in env) {
76+
if (key.indexOf('ORACLE_LOGIN_') == 0 && env.hasOwnProperty(key)) {
77+
var name = key.substr(13) + '=';
78+
form.data = form.data.replace(name, name + env[key]);
79+
}
80+
}
81+
82+
var cmd = ['curl', [
83+
'--cookie', env['COOKIES'],
84+
'--cookie-jar', env['COOKIES'],
85+
'--data', '@-',
86+
'--location',
87+
'--output', require('path').basename(env['ORACLE_FILE']),
88+
'--user-agent', env['USER_AGENT'],
89+
form.action
90+
]];
91+
92+
console.info("Executing %j", cmd);
93+
94+
var child_process = require('child_process');
95+
var child = child_process.spawn.apply(child_process, cmd.concat({ stdio: ['pipe', 1, 2] }));
96+
child.on('exit', process.exit);
97+
child.stdin.end(form.data);
98+
});
99+
});
100+
})
101+
.catch(function (err) {
102+
console.error(err);
103+
browser.on('exit', function () { process.exit(1); });
104+
browser.exit();
105+
});
106+
});
107+
})
108+
.catch(function (err) {
109+
console.error(err);
110+
process.exit(1);
111+
});

.travis/oracle/download.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh -e
2+
3+
[ -n "$ORACLE_COOKIE" ] || { echo "Missing ORACLE_COOKIE environment variable!"; exit 1; }
4+
[ -n "$ORACLE_FILE" ] || { echo "Missing ORACLE_FILE environment variable!"; exit 1; }
5+
6+
cd "$(dirname "$(readlink -f "$0")")"
7+
8+
npm install bluebird node-phantom-simple
9+
10+
export COOKIES='cookies.txt'
11+
export USER_AGENT='Mozilla/5.0'
12+
13+
echo > "$COOKIES"
14+
chmod 600 "$COOKIES"
15+
16+
exec node download.js

.travis/oracle/install.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh -e
2+
3+
[ -n "$ORACLE_FILE" ] || { echo "Missing ORACLE_FILE environment variable!"; exit 1; }
4+
[ -n "$ORACLE_HOME" ] || { echo "Missing ORACLE_HOME environment variable!"; exit 1; }
5+
6+
ORACLE_RPM="$(basename $ORACLE_FILE .zip)"
7+
8+
cd "$(dirname "$(readlink -f "$0")")"
9+
10+
sudo apt-get -qq update
11+
sudo apt-get --no-install-recommends -qq install bc libaio1 rpm unzip
12+
13+
df -B1 /dev/shm | awk 'END { if ($1 != "shmfs" && $1 != "tmpfs" || $2 < 2147483648) exit 1 }' ||
14+
( sudo rm -r /dev/shm && sudo mkdir /dev/shm && sudo mount -t tmpfs shmfs -o size=2G /dev/shm )
15+
16+
test -f /sbin/chkconfig ||
17+
( echo '#!/bin/sh' | sudo tee /sbin/chkconfig > /dev/null && sudo chmod u+x /sbin/chkconfig )
18+
19+
test -d /var/lock/subsys || sudo mkdir /var/lock/subsys
20+
21+
if [ "$ORACLE_ZIP_DIR" != "" ]; then
22+
ORACLE_ZIP="$ORACLE_ZIP_DIR/$(basename $ORACLE_FILE)"
23+
else
24+
ORACLE_ZIP="$(basename $ORACLE_FILE)"
25+
fi
26+
27+
unzip -j $ORACLE_ZIP "*/$ORACLE_RPM"
28+
29+
sudo rpm --install --nodeps --nopre "$ORACLE_RPM"
30+
31+
echo 'OS_AUTHENT_PREFIX=""' | sudo tee -a "$ORACLE_HOME/config/scripts/init.ora" > /dev/null
32+
sudo usermod -aG dba $USER
33+
34+
( echo ; echo ; echo travis ; echo travis ; echo n ) | sudo AWK='/usr/bin/awk' /etc/init.d/oracle-xe configure
35+
36+
"$ORACLE_HOME/bin/sqlplus" -L -S / AS SYSDBA <<SQL
37+
CREATE USER $USER IDENTIFIED EXTERNALLY;
38+
GRANT CONNECT, RESOURCE TO $USER;
39+
SQL

examples.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
set -ev
4+
5+
cd examples
6+
"$ORACLE_HOME/bin/sqlplus" ut3/ut3 @RunAllExamplesAsTests.sql

examples/RunAllExamples.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ prompt RunExampleTestThroughBaseClass
1313
@@RunExampleTestThroughBaseClass.sql
1414
prompt RunExampleTestSuiteWithCompositeReporter
1515
@@RunExampleTestSuiteWithCompositeReporter.sql
16+
prompt RunExampleTestAnnotationBasedForCurrentSchema
17+
@@RunExampleTestAnnotationBasedForCurrentSchema.sql

examples/RunAllExamplesAsTests.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
whenever sqlerror exit failure rollback
2+
whenever oserror exit failure rollback
3+
4+
@@RunAllExamples.sql
5+
6+
exit success

examples/RunExampleComplexSuiteWithCustomDBMSOutputReporter.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ begin
4343
end;
4444
/
4545

46-
--drop type ut_custom_reporter;
46+
drop type ut_custom_reporter;
4747
drop package ut_exampletest;
4848
drop package ut_exampletest2;

0 commit comments

Comments
 (0)