Skip to content

Commit e1dd902

Browse files
authored
Merge pull request #7 from utPLSQL/feature/v3.0.4_compatibility
Feature/v3.0.4 compatibility
2 parents 86d3fed + 2969a12 commit e1dd902

File tree

7 files changed

+195
-18
lines changed

7 files changed

+195
-18
lines changed

.travis.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,37 @@ env:
2626
# project variables
2727
- DB_USER=ut3_demo
2828
- DB_PASS=LHZYPbWvYdu2ctp8
29+
- CACHE_DIR=$HOME/.cache
2930
##utPLSQL variables
3031
- UTPLSQL_DIR="utPLSQL"
3132
- UTPLSQL_V2_DIR="utPLSQL_V2"
33+
- MAVEN_HOME=/usr/local/maven
34+
- MAVEN_CFG=$HOME/.m2
35+
- UTPLSQL_CLI_VERSION="3.0.4"
36+
matrix:
37+
- UTPLSQL_3_VERSION='v3.0.0' RELEASE_ID=6394329 UTPLSQL_DIR='utPLSQLv3.0.0'
38+
- UTPLSQL_3_VERSION='v3.0.1' RELEASE_ID=6716262
39+
- UTPLSQL_3_VERSION='v3.0.2' RELEASE_ID=7085296
40+
- UTPLSQL_3_VERSION='v3.0.3' RELEASE_ID=7293900
41+
- UTPLSQL_3_VERSION='v3.0.4' RELEASE_ID=8372513
42+
- UTPLSQL_3_VERSION='latest' RELEASE_ID='latest'
43+
3244
before_install:
3345
# download travis-oracle
3446
- wget 'https://github.com/cbandy/travis-oracle/archive/v2.0.3.tar.gz'
3547
- mkdir -p .travis/oracle
3648
- tar x -C .travis/oracle --strip-components=1 -f v2.0.3.tar.gz
3749
# download latest utPLSQL release
38-
- curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/latest | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g')
39-
- unzip -q utPLSQL.zip
50+
- curl -Lk -o utPLSQL_v3.zip $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/${RELEASE_ID} | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g')
51+
- unzip -q utPLSQL_v3.zip
4052
# download utPLSQL v.2.3.1 release
41-
- curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/3608515 | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g')
42-
- unzip -d ${UTPLSQL_V2_DIR} -q utplsql-2-3-1.zip
53+
- curl -Lk -o utPLSQL_v2.zip $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/3608515 | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g')
54+
- unzip -d ${UTPLSQL_V2_DIR} -q utPLSQL_v2.zip
4355
# download utPLSQL-cli
44-
- curl -Lk -o utPLSQL-cli.zip https://bintray.com/viniciusam/utPLSQL-cli/download_file?file_path=utPLSQL-cli-develop-201706191645.zip
45-
- unzip -q utPLSQL-cli.zip
56+
- curl -Lk -o utPLSQL-cli.zip https://github.com/utPLSQL/utPLSQL-cli/releases/download/v${UTPLSQL_CLI_VERSION}/utPLSQL-cli.zip
57+
- unzip -q utPLSQL-cli.zip && chmod -R u+x utPLSQL-cli
58+
#Download Oracle jdbc using maven
59+
- bash .travis/maven_cfg.sh
4660
# download Oracle XE installer for Travis
4761
- .travis/oracle/download.sh
4862

.travis/maven_cfg.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -ev
3+
cp .travis/settings.xml $MAVEN_CFG/settings.xml
4+
5+
cd $(dirname $(readlink -f $0))
6+
7+
# Download wagon-http recommended by Oracle.
8+
# On maven latest version this is not needed, but travis doesn't have it.
9+
if [ ! -f $CACHE_DIR/wagon-http-2.8-shaded.jar ]; then
10+
curl -L -O "http://central.maven.org/maven2/org/apache/maven/wagon/wagon-http/2.8/wagon-http-2.8-shaded.jar"
11+
mv wagon-http-2.8-shaded.jar $CACHE_DIR/
12+
sudo cp $CACHE_DIR/wagon-http-2.8-shaded.jar $MAVEN_HOME/lib/ext/
13+
else
14+
echo "Using cached wagon-http..."
15+
sudo cp $CACHE_DIR/wagon-http-2.8-shaded.jar $MAVEN_HOME/lib/ext/
16+
fi
17+
18+
mvn dependency:copy-dependencies -DoutputDirectory=../utPLSQL-cli/lib

.travis/pom.xml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<!--Used to obtain ojdbc8 and orai18n files that are needed for client-->
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>org.utplsql</groupId>
6+
<artifactId>utplsql</artifactId>
7+
<version>3.0.4-SNAPSHOT</version>
8+
<packaging>jar</packaging>
9+
10+
<name>utPLSQL</name>
11+
<url>https://github.com/utPLSQL/utPLSQL</url>
12+
13+
<properties>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
</properties>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>com.oracle.jdbc</groupId>
20+
<artifactId>ojdbc8</artifactId>
21+
<version>12.2.0.1</version>
22+
<scope>compile</scope>
23+
</dependency>
24+
<dependency>
25+
<groupId>com.oracle.jdbc</groupId>
26+
<artifactId>orai18n</artifactId>
27+
<version>12.2.0.1</version>
28+
<scope>compile</scope>
29+
</dependency>
30+
</dependencies>
31+
32+
<repositories>
33+
<repository>
34+
<id>maven.oracle.com</id>
35+
<releases>
36+
<enabled>true</enabled>
37+
</releases>
38+
<snapshots>
39+
<enabled>false</enabled>
40+
</snapshots>
41+
<url>https://maven.oracle.com</url>
42+
<layout>default</layout>
43+
</repository>
44+
</repositories>
45+
46+
<pluginRepositories>
47+
<pluginRepository>
48+
<id>maven.oracle.com</id>
49+
<url>https://maven.oracle.com</url>
50+
</pluginRepository>
51+
</pluginRepositories>
52+
53+
<build>
54+
<extensions>
55+
<extension>
56+
<groupId>io.packagecloud.maven.wagon</groupId>
57+
<artifactId>maven-packagecloud-wagon</artifactId>
58+
<version>0.0.6</version>
59+
</extension>
60+
</extensions>
61+
</build>
62+
</project>

.travis/settings.xml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
23+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
24+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
25+
26+
<servers>
27+
<server>
28+
<id>maven.oracle.com</id>
29+
<username>${env.ORACLE_OTN_USER}</username>
30+
<password>${env.ORACLE_OTN_PASSWORD}</password>
31+
<configuration>
32+
<basicAuthScope>
33+
<host>ANY</host>
34+
<port>ANY</port>
35+
<realm>OAM 11g</realm>
36+
</basicAuthScope>
37+
<httpConfiguration>
38+
<all>
39+
<params>
40+
<property>
41+
<name>http.protocol.allow-circular-redirects</name>
42+
<value>%b,true</value>
43+
</property>
44+
</params>
45+
</all>
46+
</httpConfiguration>
47+
</configuration>
48+
</server>
49+
</servers>
50+
51+
</settings>

source/install.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ grant execute on utassert2 to public;
100100
grant execute on ut_v2_migration to public;
101101

102102
set echo off
103+
set feedback off
104+
whenever sqlerror continue
105+
create or replace public synonym ut_annotation_parser for &&utplsql_v3_owner..ut_annotation_parser;
106+
grant execute on &&utplsql_v3_owner..ut_annotation_parser to public;
107+
create or replace public synonym ut_annotations for &&utplsql_v3_owner..ut_annotations;
108+
grant execute on &&utplsql_v3_owner..ut_annotations to public;
109+
103110
prompt &&sep
104111
PROMPT Installation completed successfully
105112
prompt &&sep

source/migration/ut3.ut_v2_migration.pkb

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ create or replace package body ut_v2_migration is
2424
l_setup_proc varchar2(128 char) := upper(a_package_prefix || 'setup');
2525
l_teardown_proc varchar2(128 char) := upper(a_package_prefix || 'teardown');
2626
l_replace_pattern varchar2(50);
27-
l_annotations ut_annotations.typ_annotated_package;
2827
l_suite_desc varchar2(4000);
2928
l_suite_package varchar2(4000);
3029
begin
@@ -36,10 +35,31 @@ create or replace package body ut_v2_migration is
3635

3736
l_source := dbms_metadata.get_ddl('PACKAGE', l_resolved_object_name, l_resolved_owner);
3837

39-
l_annotations := ut_annotations.parse_package_annotations(l_source);
40-
41-
if l_annotations.package_annotations.exists('suite') then
42-
raise_application_error(-20400, 'Package '||a_packge_name||' is already version 3 compatible');
38+
if ut.version like '%v3.0.0%' or ut.version like '%v3.0.1%' or ut.version like '%v3.0.2%' or ut.version like '%v3.0.3%' then
39+
execute immediate q'[
40+
declare
41+
l_annotations ut_annotations.typ_annotated_package := ut_annotations.parse_package_annotations(:l_source);
42+
begin
43+
if l_annotations.package_annotations.exists('suite') then
44+
raise_application_error(-20400, 'Package '||:a_packge_name||' is already version 3 compatible');
45+
end if;
46+
end;
47+
]' using l_source, a_packge_name;
48+
else
49+
execute immediate q'[
50+
declare
51+
l_exists integer;
52+
begin
53+
dbms_output.put_line('checking annotations');
54+
select 1
55+
into l_exists
56+
from table( ut_annotation_parser.parse_object_annotations( :l_source ) )
57+
where name = 'suite';
58+
raise_application_error(-20400, 'Package '||:a_packge_name||' is already version 3 compatible');
59+
exception
60+
when no_data_found then
61+
null;
62+
end;]' using l_source, a_packge_name;
4363
end if;
4464

4565
if trim(a_package_desc) is not null then
@@ -110,28 +130,29 @@ create or replace package body ut_v2_migration is
110130
dbms_metadata.set_transform_param(dbms_metadata.session_transform,'BODY',false);
111131

112132
for rec in (select p.owner
113-
,upper(case when p.samepackage='N' then p.prefix end || p.name) as name
133+
,p.name
114134
,p.description as package_desc
115135
,nvl(p.prefix, c.prefix) prefix
116136
,s.name suite_name
117137
,s.description as suite_desc
118138
,o.status
119-
from utp.ut_package p
120-
,utp.ut_suite s
121-
,utp.ut_config c
139+
from UTP.ut_package p
140+
,UTP.ut_suite s
141+
,UTP.ut_config c
122142
,all_objects o
123143
where p.id in (select max(p2.id) keep(dense_rank first order by p2.suite_id desc nulls last)
124-
from utp.ut_package p2
144+
from UTP.ut_package p2
125145
group by upper(p2.owner)
126-
,upper(case when p2.samepackage='N' then p.prefix end || p2.name))
146+
,upper(p2.name))
127147
and p.suite_id = s.id(+)
128148
and p.owner = c.username(+)
129149
and p.owner = o.owner
130-
and upper(case when p.samepackage='N' then p.prefix end || p.name) = o.object_name
150+
and p.name = o.object_name
131151
and o.object_type in ('PACKAGE')
132152
and p.owner = nvl(a_owner_name, p.owner)
133153
and p.name = nvl(a_package_name, p.name)
134154
and (s.name = a_suite_name or a_suite_name is null)
155+
and upper(p.name) like upper(nvl(p.prefix, c.prefix))||'%'
135156
) loop
136157
begin
137158
l_items_processed := l_items_processed +1;

test/migration_test/test_migration.pkb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ end;
8989
end;
9090

9191
procedure register_ut_v2_packages is
92+
l_lines dbmsoutput_linesarray;
93+
l_numlines integer;
9294
pragma autonomous_transaction;
9395
begin
9496
dbms_output.put_line('register_ut_v2_packages');
@@ -97,6 +99,8 @@ end;
9799
utSuite.add ('MIGRATION');
98100
utPackage.add('MIGRATION', 'UT_BETWNSTR_NEW', samepackage_in => true);
99101
utplsql.testsuite ('MIGRATION');
102+
103+
dbms_output.get_lines ( l_lines, l_numlines );
100104
commit;
101105
end;
102106

0 commit comments

Comments
 (0)