Skip to content

Bugfix/issue 157 missing line break after suite #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -142,10 +142,11 @@ Please file your bug reports, enhancement requests, questions and other support
3. [Create a branch](https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/), commit and publish your changes and enhancements
4. [Create a pull request](https://help.github.com/articles/creating-a-pull-request/)

## How to Build
## How to Build

1. [Download](http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html) and install SQL Developer 21.4.2
2. [Download](https://maven.apache.org/download.cgi) and install Apache Maven 3.8.3
1. [Download](http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html) and install SQL Developer 21.4.3
2. [Download](https://maven.apache.org/download.cgi) and install Apache Maven 3.8.6
3. [Download](https://git-scm.com/downloads) and install a git command line client
4. Clone the utPLSQL-SQLDeveloper repository
5. Open a terminal window in the utPLSQL-SQLDeveloper root folder and type
@@ -154,7 +155,7 @@ Please file your bug reports, enhancement requests, questions and other support

6. Run maven build by the following command

mvn -Dsqldev.basedir=/Applications/SQLDeveloper21.4.2.app/Contents/Resources/sqldeveloper -DskipTests=true clean package
mvn -Dsqldev.basedir=/Applications/SQLDeveloper21.4.3.app/Contents/Resources/sqldeveloper -DskipTests=true clean package

Amend the parameter sqldev.basedir to match the path of your SQL Developer installation. This folder is used to reference Oracle jar files which are not available in public Maven repositories
7. The resulting file ```utplsql_for_SQLDev_x.x.x-SNAPSHOT.zip``` in the ```target``` directory can be installed within SQL Developer
116 changes: 73 additions & 43 deletions sqldev/pom.xml
Original file line number Diff line number Diff line change
@@ -10,10 +10,11 @@
<packaging>bundle</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.version>1.8</jdk.version>
<jdk.version.test>1.8</jdk.version.test>
<jdk.version>8</jdk.version>
<jdk.test.version>17</jdk.test.version>
<!-- requires SQL Developer 4.1.0 or higher (first version based on JDK 1.8) -->
<sqldev.basedir>/Applications/SQLDeveloper21.4.2.app/Contents/Resources/sqldeveloper</sqldev.basedir>
<!-- last version of SQL Developer that uses JDK 8 is 21.4.3 -->
<sqldev.basedir>/Applications/SQLDeveloper21.4.3.app/Contents/Resources/sqldeveloper</sqldev.basedir>
<final.name>utplsql_for_SQLDev_${project.version}</final.name>
<!-- arguments to by added by jacoco plugin for test runs with coverage -->
<!-- -noverify is required in some environments to avoid java.lang.VerifyError -->
@@ -206,19 +207,19 @@
<!-- used mainly to access the database via JdbcTemplate -->
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.3.16</version>
<version>5.3.22</version>
</dependency>
<dependency>
<!-- transitive reference, but IntelliJ wants to have it explicit (to avoid warnings) -->
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.20</version>
<version>5.3.22</version>
</dependency>
<dependency>
<!-- used for HtmlUtils.htmlEscape in RunnerPanel -->
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.3.16</version>
<version>5.3.22</version>
</dependency>
<dependency>
<!-- optional, for RunGenerator and TestGenerator -->
@@ -244,7 +245,6 @@
<!-- Build Settings -->
<build>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
@@ -253,36 +253,16 @@
</includes>
</resource>
</resources>
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>3.10.0</version>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<!-- used by Maven build -->
<testSource>${jdk.version.test}</testSource>
<testTarget>${jdk.version.test}</testTarget>
<includes>
<include>**/*.java</include>
</includes>
</configuration>
<executions>
<!-- used by Eclipse when updating project -->
<execution>
<id>test-compile</id>
<phase>process-test-sources</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<source>${jdk.version.test}</source>
<target>${jdk.version.test}</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
@@ -316,7 +296,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.0.0</version><!--$NO-MVN-MAN-VER$-->
<version>3.1.0</version><!--$NO-MVN-MAN-VER$-->
<executions>
<execution>
<phase>prepare-package</phase>
@@ -337,7 +317,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
<executions>
<execution>
<phase>initialize</phase>
@@ -357,7 +337,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.1.0</version>
<version>3.3.0</version>
<executions>
<execution>
<id>parse-version</id>
@@ -427,7 +407,7 @@
<!-- - Error:osgi: [org.utplsql.sqldev] Invalid value for Bundle-Version, ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion} does not match \d{1,9}(\.\d{1,9}(\.\d{1,9}(\.[-\w]+)?)?)? -->
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>4.2.1</version>
<version>5.1.7</version> <!-- Classes found in the wrong director warning with 5.1.7, TODO: find solution to remove it -->
<extensions>true</extensions>
<configuration>
<finalName>${project.name}</finalName>
@@ -497,7 +477,7 @@
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version><!--$NO-MVN-MAN-VER$-->
<version>3.4.1</version><!--$NO-MVN-MAN-VER$-->
<configuration>
<finalName>${final.name}</finalName>
<appendAssemblyId>false</appendAssemblyId>
@@ -519,7 +499,7 @@
<plugin>
<groupId>net.nicoulaj.maven.plugins</groupId>
<artifactId>checksum-maven-plugin</artifactId>
<version>1.9</version>
<version>1.11</version>
<executions>
<execution>
<id>calculate-checksums</id>
@@ -533,7 +513,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<version>0.8.8</version>
<executions>
<execution>
<goals>
@@ -645,4 +625,54 @@
<tag>master</tag>
<url>https://github.com/utPLSQL/utPLSQL-SQLDeveloper</url>
</scm>

<!-- Profiles as workaround for https://youtrack.jetbrains.com/issue/IDEA-85478 as described in -->
<!-- https://intellij-support.jetbrains.com/hc/en-us/community/posts/360009767720-I-want-to-run-tests-with-different-java-version-than-my-source-java-version -->
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>3.10.1</version>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<!-- different Java version for main and test -->
<!-- works with Maven builder from IDE or command line -->
<release>${jdk.version}</release>
<testRelease>${jdk.test.version}</testRelease>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>idea</id>
<activation>
<activeByDefault>false</activeByDefault>
<property>
<name>idea.maven.embedder.version</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>3.10.1</version>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<!-- IDEA requires same Java version for main and test -->
<!-- see https://youtrack.jetbrains.com/issue/IDEA-85478 -->
<release>${jdk.test.version}</release>
<testRelease>${jdk.test.version}</testRelease>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -190,7 +190,7 @@ private void run() {
PreferenceModel preferences;
try {
preferences = PreferenceModel.getInstance(Preferences.getPreferences());
} catch (NoClassDefFoundError error) {
} catch (NoClassDefFoundError | ExceptionInInitializerError error) {
// not running in SQL Developer (in tests)
preferences = PreferenceModel.getInstance(null);
}
Original file line number Diff line number Diff line change
@@ -41,9 +41,9 @@ public String generateSpec() {
final String packageName = context.getTestPackagePrefix() + objectName + context.getTestPackageSuffix();
sb.append("create or replace package ");
sb.append(packageName);
sb.append(" is\n\n");
sb.append(" is\n");
if (context.isGenerateComments()) {
sb.append("\t-- generated by utPLSQL for SQL Developer on ");
sb.append("\n\t-- generated by utPLSQL for SQL Developer on ");
sb.append(today);
sb.append("\n\n");
}
@@ -53,8 +53,9 @@ public String generateSpec() {
if (!context.getSuitePath().isEmpty()) {
sb.append("\t--%suitepath(");
sb.append(context.getSuitePath());
sb.append(")\n\n");
sb.append(")\n");
}
sb.append("\n");
for (final String u : units) {
final String unit = u.toLowerCase();
if (context.getNumberOfTestsPerUnit() > 1
Original file line number Diff line number Diff line change
@@ -77,30 +77,30 @@ private CharSequence getCode() {
StringBuilder sb = new StringBuilder();
if (!debug) {
if (preferences.isResetPackage()) {
sb.append("EXECUTE dbms_session.reset_package;\n");
sb.append("execute dbms_session.reset_package;\n");
}
sb.append("SET SERVEROUTPUT ON SIZE UNLIMITED\n");
sb.append("set serveroutput on size unlimited\n");
if (preferences.isClearScreen()) {
sb.append("CLEAR SCREEN\n");
sb.append("clear screen\n");
}
if (pathList.size() == 1) {
sb.append("EXECUTE ut.run('");
sb.append("execute ut.run('");
sb.append(pathList.get(0));
sb.append("');\n");
} else {
// we want a horizontal dense output because we resize the worksheet to fit the command in common cases
sb.append("EXECUTE ut.run(ut_varchar2_list(");
sb.append("execute ut.run(ut_varchar2_list(");
sb.append(StringTools.getCSV(pathList, "").replace("\n", ""));
sb.append("));\n");
}
} else {
sb.append("BEGIN\n");
sb.append("begin\n");
sb.append(" ut.run(\n");
sb.append(" ut_varchar2_list(\n");
sb.append(StringTools.getCSV(pathList, 9));
sb.append(" )\n");
sb.append(" );\n");
sb.append("END;\n");
sb.append("end;\n");
}
return sb;
}
Original file line number Diff line number Diff line change
@@ -568,7 +568,7 @@ private void syncDetailTab() {
private PreferenceModel getPreferenceModel() {
try {
return PreferenceModel.getInstance(Preferences.getPreferences());
} catch (NoClassDefFoundError e) {
} catch (NoClassDefFoundError | ExceptionInInitializerError e) {
// running outside of SQL Developer
return PreferenceModel.getInstance(null);
}
Original file line number Diff line number Diff line change
@@ -46,7 +46,12 @@ public void setupDefaultPreferences() {
preferences = PreferenceModel.getInstance(null);
// the second call will call will succeed and use preferences from user.home
// this ensures that the test and the runner use the same preferences
preferences = PreferenceModel.getInstance(Preferences.getPreferences());
try {
preferences = PreferenceModel.getInstance(Preferences.getPreferences());
} catch (NoClassDefFoundError e2) {
// the second call also failed. no other option left (new behavior with Java17)
preferences = PreferenceModel.getInstance(null);
}
} finally {
// set defaults manually, since all tests are using the same preference store
preferences.setShowSuccessfulTests(true);
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
package org.utplsql.sqldev.test.template;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.utplsql.sqldev.model.oddgen.GenContext;
import org.utplsql.sqldev.oddgen.TestTemplate;
import org.utplsql.sqldev.test.AbstractJdbcTest;
import org.utplsql.sqldev.test.coverage.CodeCoverageReporterTest;

import java.sql.SQLException;

public class TemplateTest extends AbstractJdbcTest {

@Before
public void setup() {
executeAndIgnore(jdbcTemplate, """
create or replace package junit_pkg is
procedure proc;
end;
""");
}


@After
public void teardown() {
executeAndIgnore(jdbcTemplate, "drop package junit_pkg");
}

@Test
public void spec_no_comment_no_disable_no_path() throws SQLException {
// arrange
var context = new GenContext();
context.setConn(dataSource.getConnection());
context.setObjectType("PACKAGE");
context.setObjectName("JUNIT_PKG");
context.setTestPackagePrefix("");
context.setTestPackageSuffix("_test");
context.setTestUnitPrefix("");
context.setTestUnitSuffix("");
context.setNumberOfTestsPerUnit(1);
context.setGenerateComments(false);
context.setDisableTests(false);
context.setSuitePath("");
context.setIndentSpaces(3);

// act
var template = new TestTemplate(context);
var actual = template.generateSpec();

// assert
var expected = """
create or replace package junit_pkg_test is
--%suite(junit_pkg_test)
--%test
procedure proc;
end junit_pkg_test;
/
""".trim();
Assert.assertEquals(expected, actual);
}

@Test
public void spec_no_comment_no_disable_with_path() throws SQLException {
// arrange
var context = new GenContext();
context.setConn(dataSource.getConnection());
context.setObjectType("PACKAGE");
context.setObjectName("JUNIT_PKG");
context.setTestPackagePrefix("");
context.setTestPackageSuffix("_test");
context.setTestUnitPrefix("");
context.setTestUnitSuffix("");
context.setNumberOfTestsPerUnit(1);
context.setGenerateComments(false);
context.setDisableTests(false);
context.setSuitePath("org.utplsql");
context.setIndentSpaces(3);

// act
var template = new TestTemplate(context);
var actual = template.generateSpec();

// assert
var expected = """
create or replace package junit_pkg_test is
--%suite(junit_pkg_test)
--%suitepath(org.utplsql)
--%test
procedure proc;
end junit_pkg_test;
/
""".trim();
Assert.assertEquals(expected, actual);
}

@Test
public void spec_no_comment_disable_with_path() throws SQLException {
// arrange
var context = new GenContext();
context.setConn(dataSource.getConnection());
context.setObjectType("PACKAGE");
context.setObjectName("JUNIT_PKG");
context.setTestPackagePrefix("");
context.setTestPackageSuffix("_test");
context.setTestUnitPrefix("");
context.setTestUnitSuffix("");
context.setNumberOfTestsPerUnit(1);
context.setGenerateComments(false);
context.setDisableTests(true);
context.setSuitePath("org.utplsql");
context.setIndentSpaces(3);

// act
var template = new TestTemplate(context);
var actual = template.generateSpec();

// assert
var expected = """
create or replace package junit_pkg_test is
--%suite(junit_pkg_test)
--%suitepath(org.utplsql)
--%test
--%disabled
procedure proc;
end junit_pkg_test;
/
""".trim();
Assert.assertEquals(expected, actual);
}

@Test
public void spec_comment_disable_with_path() throws SQLException {
// arrange
var context = new GenContext();
context.setConn(dataSource.getConnection());
context.setObjectType("PACKAGE");
context.setObjectName("JUNIT_PKG");
context.setTestPackagePrefix("");
context.setTestPackageSuffix("_test");
context.setTestUnitPrefix("");
context.setTestUnitSuffix("");
context.setNumberOfTestsPerUnit(1);
context.setGenerateComments(true);
context.setDisableTests(true);
context.setSuitePath("org.utplsql");
context.setIndentSpaces(3);

// act
var template = new TestTemplate(context);
var actual = template.generateSpec()
.replaceAll("[0-9]{4}-[0-9]{2}-[0-9]{2}[ ]{1}[0-9]{2}:[0-9]{2}:[0-9]{2}", "datetime");

// assert
var expected = """
create or replace package junit_pkg_test is
-- generated by utPLSQL for SQL Developer on datetime
--%suite(junit_pkg_test)
--%suitepath(org.utplsql)
--%test
--%disabled
procedure proc;
end junit_pkg_test;
/
""".trim();
Assert.assertEquals(expected, actual);
}

@Test
public void spec_comment_disable_with_path_two_units() throws SQLException {
// arrange
var context = new GenContext();
context.setConn(dataSource.getConnection());
context.setObjectType("PACKAGE");
context.setObjectName("JUNIT_PKG");
context.setTestPackagePrefix("");
context.setTestPackageSuffix("_test");
context.setTestUnitPrefix("");
context.setTestUnitSuffix("");
context.setNumberOfTestsPerUnit(2);
context.setGenerateComments(true);
context.setDisableTests(true);
context.setSuitePath("org.utplsql");
context.setIndentSpaces(3);

// act
var template = new TestTemplate(context);
var actual = template.generateSpec()
.replaceAll("[0-9]{4}-[0-9]{2}-[0-9]{2}[ ]{1}[0-9]{2}:[0-9]{2}:[0-9]{2}", "datetime");

// assert
var expected = """
create or replace package junit_pkg_test is
-- generated by utPLSQL for SQL Developer on datetime
--%suite(junit_pkg_test)
--%suitepath(org.utplsql)
--%context(proc)
--%test
--%disabled
procedure proc1;
--%test
--%disabled
procedure proc2;
--%endcontext
end junit_pkg_test;
/
""".trim();
Assert.assertEquals(expected, actual);
}
}