Skip to content

Commit

Permalink
Updating connectionResiliency branch with the changes from dev branch (
Browse files Browse the repository at this point in the history
…microsoft#540)

* update readme to master

* updated changelog for dev

* update changelog for master

* Update CHANGELOG.md

“more Junit tests for Always Encrypted” instead of “AlwaysEncrpyted “

* Update CHANGELOG.md

“more Junit tests for Always Encrypted” instead of “AlwaysEncrpyted “.

* Adding another value that will let the users specify default

* Replace explicit types with <> (The diamond operator).

This removes duplicated information when instantiating variables, and increases the readability. For example:

```Java
EnumMap<CallableHandles, HandleAssociation> handleMap =
      new EnumMap<CallableHandles, HandleAssociation>(CallableHandles.class);
```

becomes

```Java
EnumMap<CallableHandles, HandleAssociation> handleMap =
            new EnumMap<>(CallableHandles.class);
```

and

```Java
private static final EnumMap<SSType.Category, EnumSet<JDBCType.Category>> conversionMap =
            new EnumMap<SSType.Category, EnumSet<JDBCType.Category>>(SSType.Category.class);
```

becomes

```Java
private static final EnumMap<SSType.Category, EnumSet<JDBCType.Category>> conversionMap =
                new EnumMap<>(SSType.Category.class);
```

* Replace for and while loops with foeach loops

This increases the overall readability of the code, and has been supported since Java 5.

* make TLS keyword default

* minor fixes

* fix issue when calling getString() on unique identifier parameter

* Update SQLServerResource.java

Replace tabs with spaces

* Update SSLProtocolTest.java

* add test

* better fix

* fix an issue

* use properties to specify versions in pom file

* modify pom file to skip tests that are taged as slow

* use tag to skip certain tests, e.g. mvn clean install -Pbuild42 -DskipTestTag=slow

* Applying formatting

* Reverting back to tabs

* Minor fix

* Update SSLProtocolTest.java

* Junit changes - added CallableStatementTest and PrecisionScaleTest. Removed RandomData inside jdbc.datatypes beacuse it's redundant

* Fix timezone issues with testing

* Fix more issues with timezone

* update readme on master

* update readme on master

* update readme on dev

* Update README.md

* Update README.md

* Add 6.2.1 to README

* Update README.md

* Update 6.2 download link

* Update 6.2 download link

* Update README.md

* Add javadoc/fix issues

* Got rid of all the underscores in method names

* Add datetime/smalldatetime support for tvp
Merge branch 'dev' of https://github.com/Microsoft/mssql-jdbc into tvpDatetimeSmallDateTime

# Conflicts:
#	src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
#	src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java

* fixed issue with sql_variant

* Updated version to 6.3.1 and updated the changelog

* setNull depends on sendStringParameterAsUnicode

* make sendStringParameterAsUnicode impact updateNull() as well

* do not override the maxlength type in sql_variant when reading the values

* add snapshot to pom file

* Fixed issue with throwing error message for unsupported datatype.
Fixed issue with returning class type of time object in sql_variant

* update version number

* add test

* rename a variable

* update error messages for localization

* fix misspelled words

* adding one error message back

* too bad.. I forgot to fix the misspelled word....

* fix tests

* change cancellded to canceled

* Fix typo in Javadoc

* Fixes all statement leaks in the driver.

* Fix issues with resultset getting closed before it's consumed / closing statements when it's return type

* test

* Removed logic for closing a statement that is still used somewhere, and added a statement field that can be closed after the prepared statement is closed.

* remove unnecessary import

* Throw the initial batch exception

* Change formatting

* updated test file

* added test for the fix.

* Setting the loginTimout to default in case of a zero value (microsoft#456)

* fix indentation of SQLServerResource.java

* added test

* Fix classloader leak issue

* comment change

* add slow tag to tests

* Fixing a few mistakes in SQLServerResource (microsoft#459)

* Fixing a few mistakes in SQLServerResource

* Fix the test

* Removing connection property - fipsProvider (microsoft#460)

* Removing fipsProvider connection property

* Minor fix

* Update IOBuffer.java

Fix typo

* update FipsTest

* Add a way to remove the entries in the map after they're finished being used

* Replace explicit types with <>

* Revert "Replace explicit types with <>"

This reverts commit e277087.

* Remove explicit extends object

All objects in Java implicity extend `java.lang.Object` so `extends Object` is redundant.

Removing it will reduce confusion, and increase code readability.

* Removes redundant if/else statements. For example:
```
if (foo()) {
   return true;
} else {
   return false;
}
```

can be simplified to:
```
return foo();
```

* Remove unnecessary return statements

`return;` is unnecessary if it is the last statement in a `void` method

* Simplify overly complex boolean expressions

|Example|Replacement|
|-|-|
|`condition ? true : false`|`condition`|
|`condition ? false : true`|`!condition`|
|`value == null ? null : value`|`value`|
|`result != 0 ? result : 0`|`result`|
|`a == b ? a : b`|`b`|

* Add missing newlines to appveyor.yml

* Add missing newline to .travis.yml

* Remove comment from .travis.yml

* TimeoutTimer: Check for destroyed TheadGroup

Running a query that uses a timer can cause an
IllegalThreadStateException if the underlying ThreadGroup has been
destroyed

* TimeoutTimer: Forgot reference

Forgot to add AtomicReference

* Use ConcurrentHashMap instead

* update 6.3.1 to 6.3.2

* update changelog

* update changelog format

* increase version with SNAPSHOT after release

* refactor checkAndInitActivityId

* removing java.xml.bind.DatatypeConverter packages

* modified open source tests to run with java 9

* removed redundant methods

* remove extra line

* indentation

* works now, need comments and clean

* added comments

* add support for ""

* removing unused import

* removing deprecated APIs in java 9

* fix getExportedKeys()

* add switchCatalogs() from the current implementation

* fix getCrossReference()

* adding tests

* fix scenario when catalog is "" and add some tests for it

* add tests for getCrossReference()

* use batch instead of each statement.execute to reduce performance impact

* change column names as JDBC required

* fixed the exception thrown by getters on null

* replace [ with '

* use PreparedStatement to populate temp table #fkeys_results

* change String to Int for some columns

* refactor a bit

* Add connection properties for specifying custom TrustManager (microsoft#74)

* Add connection properties to specify a custom TrustManager

Adds two new connection properties that can be used to specify a custom
TrustManager implementation:

trustManagerClass - Class name of the custom TrustManager

trustManagerConstructorArg - Optional argument to pass to the constructor
constructor of the custom TrustManager.

If encryption is enabled and the trustManagerClass property is specified,
it will be retrieved via Class.forName(...).

If the optional property trustManagerConstructorArg is specified, then a
constructor will be retrieved via getDeclaredConstructors(String.class).
The TrustManager will then be instantiated by specified the optional
argument as a parameter.

If the optional property trustManagerConstructorArg is not specfied,
then the default no argument constructor of the class will be retrieved
and instantiated.

* Adding a few simple test to verify the newly added connection properties

* Rename custom trustmanager test package name

Previous package name used camel case. Corrects naming to be lower case.

* Add missing newlines to trustmanager test classes

* Refactor references to trust managers in tests

* Refactor whitespace and unneeded extends Object

* Add resource cleanup to trust manager tests

* Refactor failure handling for trust manager test

* Rename tmClazz to tmClass

* Add new trust manager properties to SQLServerDataSource

* Reword comment

* Format custom trustmanager changes with auto formatter

* recognize CallableStatement parameter names with leading '@'

* Revert "removing javax.xml.bind package dependency "

* Revert "Removing deprecated APIs in java 9"

* Replace manual array copy

Replace manual array copying with System.arraycopy().

* Remove redundant String.toString()

Calling toString() on a String object is redundant

* Replace bare literals

Replace bare literals with magic constants. For example:

`cal.set(1, 1, 577738, 0, 0, 0);`

becomes

`cal.set(1, Calendar.FEBRUARY, 577738, 0, 0, 0);`

* release process PR

* Revert "Remove redundant if/else statements"

* remove PR 470 from changelist, and modify the readme file

* remove preview from pom

* make urls work

* remove developer name from POM file

* cleanup tables after test

* more cleaning of tables and procedures

* add snapshot to pom.xml

* Make it 6.3.4

* Implement checkDuplicateColumnName to check duplicate columns

* Revert "Implement checkDuplicateColumnName to check duplicate columns"

This reverts commit e77a046.

* Revert "Revert "Implement checkDuplicateColumnName to check duplicate columns""

This reverts commit 8f69956.

* Apply same logic for TVP

* update changelog and readme for dev branch

* Committing fixes for Junit Tests

* Failing tests disabled temporarily

* Faoling tests disabled temporarily

* use try with resources

* add another try-with-resource

* drop a not needed method

* try-with-resources implementation commit 1

* Update .travis.yml

Updated docker image tag for mssql-server-linux

* Updating travis build script to use :2017-latest tag for SQL Server docker image

* Update .travis.yml

Updating docker run command as well.

* Update docker run command as well

* Fix AESetup issue with dropCEK

* try-with-resources implementation commit 2

* avoid creating connection for termination

* remove null check and change Set object name

* tweak to preserve original parameter name for exception message

* Refactoring the logic for checking duplicate column into Util class and adding a test case for this

* Remove explicit interface reference

* Modified bvtTests to be able to test resultSet closing explicitly.

* updates gradle dependencies

* update

* newline

* 6.3.4 release (microsoft#528)

* 6.3.4-preview release

* Add 6.3.5-SNAPSHOT to pom file (microsoft#530)

* add snapshot to pom file

* revise the way that pom file uses version number

* add -preview

* temporarily skipping amedParamMultiPartTest.update5 and amedParamMultiPartTest.update6

* Adding @disabled tag for failing tests
  • Loading branch information
ulvii authored Nov 9, 2017
1 parent 57b292c commit 06abd7f
Show file tree
Hide file tree
Showing 197 changed files with 28,563 additions and 4,577 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ build/
*~.nib
local.properties
.classpath
.vscode/
.settings/
.gradle/
.loadpath

# External tool builders
Expand Down
30 changes: 22 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sudo: required
sudo: required

language: java
jdk:
Expand All @@ -8,23 +8,37 @@ services:
- docker

env:
global:
- mssql_jdbc_test_connection_properties='jdbc:sqlserver://localhost:1433;databaseName=master;username=sa;password=<YourStrong!Passw0rd>;'

- mssql_jdbc_logging='true'
# Enabling logging with console / file handler for JUnit Test Framework.
#- mssql_jdbc_logging_handler='console'|'file'

#Cache the .m2 folder
cache:
directories:
- $HOME/.m2

before_install:
- mkdir AE_Certificates

install:
- cd AE_Certificates
- openssl req -newkey rsa:2048 -x509 -keyout cakey.pem -out cacert.pem -days 3650 -subj "/C=US/ST=WA/L=Redmond/O=Microsoft Corporation/OU=SQL Server/CN=JDBC Driver" -nodes
- openssl pkcs12 -export -in cacert.pem -inkey cakey.pem -out identity.p12 -password pass:password
- keytool -importkeystore -destkeystore clientcert.jks -deststorepass password -srckeystore identity.p12 -srcstoretype PKCS12 -srcstorepass password
- keytool -list -v -keystore clientcert.jks -storepass "password" > JavaKeyStore.txt
- cd ..
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild41
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Pbuild42

before_script:
- docker pull microsoft/mssql-server-linux
- docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' -p 1433:1433 -d microsoft/mssql-server-linux
- docker pull microsoft/mssql-server-linux:2017-latest
- docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' -p 1433:1433 -d microsoft/mssql-server-linux:2017-latest

script:
- docker ps -a

##Test for JDBC Specification 41 & 42 and submit coverage report.
- mvn test -B -Pbuild41 jacoco:report && bash <(curl -s https://codecov.io/bash) -cF JDBC41
- mvn test -B -Pbuild42 jacoco:report && bash <(curl -s https://codecov.io/bash) -cF JDBC42

#after_success:
# instead of after success we are using && operator for conditional submitting coverage report.
# - bash <(curl -s https://codecov.io/bash)
674 changes: 674 additions & 0 deletions AppVeyorJCE/LICENSE

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions AppVeyorJCE/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# JCE chocolatey package

### Disclaimers:
1. All contents within this directory originate from [this GitHub project](https://github.com/TobseF/jce-chocolatey-package). This project was added to allow us to test the Always Encrypted feature on AppVeyor builds.

2. This is not an official project of Oracle. It\`s only easy of the manual installation: It downloads the JCE from oracle.com and unpacks it to the installed JDK.


[Chocolatey](https://chocolatey.org/) package for the [JCE (Unlimited Strength Java Cryptography Extension Policy Files)](http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html)

This chocolatey package adds the JCE to latest installed Java SDK. The The `JAVA_HOME` environment variable has to point to the JDK. If `JAVA_HOME` is not set, nothing will be changed. The original files are backuped (renamed to `*_old`) and can be reverted at any time. This package is a perfect addion to the [JDK8 package](https://chocolatey.org/packages/jdk8).

#### Install with [Chocolatey](https://chocolatey.org/)
```PowerShell
choco install jce -y
```

#### Build from source:
1. Install [Chocolatey](https://chocolatey.org/).
2. Open cmd with admin rights in jce package directory.
3. Pack NuGet Package (.nupkg).
```PowerShell
cpack
```
4. Install JCE NuGet Package.
```PowerShell
choco install jce -fdv -s . -y
```



28 changes: 28 additions & 0 deletions AppVeyorJCE/jce.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<!-- Read this before publishing packages to chocolatey.org: https://github.com/chocolatey/chocolatey/wiki/CreatePackages -->
<id>jce</id>
<title>JCE (Java Cryptography Extension)</title>
<version>7.0.0</version>
<authors>Sun Microsystems/Oracle Corporation</authors>
<owners>Tobse Fritz</owners>
<summary>Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 7</summary>
<description>Downloads and installs the Java Cryptography Extension (JCE) to the lastest JDK. The The JAVA_HOME environment variable has to point to the JDK. If JAVA_HOME is not set, nothing will be changed. The original files are backuped (renamed to *_old) and can be reverted at any time.</description>
<projectUrl>https://github.com/TobseF/jce-chocolatey-package</projectUrl>
<tags>java jce admin</tags>
<copyright></copyright>
<licenseUrl>http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<iconUrl>http://cdn.rawgit.com/chocolatey/chocolatey-coreteampackages/50fd97744110dcbce1acde889c0870599c9d5584/icons/java.svg</iconUrl>
<!--<dependencies>
<dependency id="" version="__VERSION__" />
<dependency id="" />
</dependencies>-->
<releaseNotes></releaseNotes>
</metadata>
<files>
<file src="tools\**" target="tools" />
</files>
</package>
15 changes: 15 additions & 0 deletions AppVeyorJCE/tools/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$script_path = $(Split-Path -parent $MyInvocation.MyCommand.Definition)
$common = $(Join-Path $script_path "common.ps1")
. $common

#installs JCE
try {
chocolatey-install
} catch {
if ($_.Exception.InnerException) {
$msg = $_.Exception.InnerException.Message
} else {
$msg = $_.Exception.Message
}
throw
}
14 changes: 14 additions & 0 deletions AppVeyorJCE/tools/chocolateyUninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$script_path = $(Split-Path -parent $MyInvocation.MyCommand.Definition)
$common = $(Join-Path $script_path "common.ps1")
. $common

function Uninstall-ChocolateyPath {
param(
[string] $pathToUninstall,
[System.EnvironmentVariableTarget] $pathType = [System.EnvironmentVariableTarget]::User
)
Write-Debug "Running 'Uninstall-ChocolateyPath' with pathToUninstall:`'$pathToUninstall`'";

#get the PATH variable
$envPath = $env:PATH
}
85 changes: 85 additions & 0 deletions AppVeyorJCE/tools/common.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
$jce_version = '7'
$zipFolder = 'UnlimitedJCEPolicy'
$script_path = $(Split-Path -parent $MyInvocation.MyCommand.Definition)

function has_file($filename) {
return Test-Path $filename
}

function download-from-oracle($url, $output_filename) {
if (!(has_file($output_fileName))) {
Write-Host "Downloading JCE from $url"

try {
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
$client = New-Object Net.WebClient
$dummy = $client.Headers.Add('Cookie', 'gpw_e24=http://www.oracle.com; oraclelicense=accept-securebackup-cookie')
$dummy = $client.DownloadFile($url, $output_filename)
} finally {
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = $null
}
}
}

function download-jce-file($url, $output_filename) {
$dummy = download-from-oracle $url $output_filename
}

function download-jce() {
$filename = "UnlimitedJCEPolicyJDK$jce_version.zip"
$url = "http://download.oracle.com/otn-pub/java/jce/$jce_version/$filename"
$output_filename = Join-Path $script_path $filename
If(!(Test-Path $output_filename)){
$dummy = download-jce-file $url $output_filename
}
return $output_filename
}

function get-java-home(){
return Get-EnvironmentVariable 'JAVA_HOME' -Scope 'Machine' -PreserveVariables
}

function get-jce-dir($java_home) {
return Join-Path $java_home 'jre\lib\security'
}

function chocolatey-install() {
$java_home = get-java-home
if (!$java_home) {
Write-Host "Couldnt find JAVA_HOME environment variable"
Write-Host "Skipping installation"
}else{
$jce_dir = get-jce-dir $java_home
$already_patched_file = Join-Path $jce_dir 'local_policy_old.jar'

If(Test-Path $already_patched_file){
Write-Host "JCE already installed: $jce_dir"
Write-Host "Skipping installation"
}else{
Write-Host "JCE is not installed ($already_patched_file) is not present"
Write-Host "Starting installation"
install-jce $jce_dir
}
}
}

function install-jce($jce_dir) {
$jce_zip_file = download-jce
$temp_dir = Get-EnvironmentVariable 'TEMP' -Scope User -PreserveVariables
$local_policy = Join-Path $jce_dir 'local_policy.jar'
$export_policy = Join-Path $jce_dir 'US_export_policy.jar'

Write-Host "Downloading JCE ($jce_zip_file)"
Install-ChocolateyZipPackage -PackageName 'jce7' -Url $jce_zip_file -UnzipLocation $temp_dir

If(Test-Path $local_policy){
Rename-Item -Path $local_policy -NewName 'local_policy_old.jar' -Force
}

If(Test-Path $export_policy){
Rename-Item -Path $export_policy -NewName 'US_export_policy_old.jar' -Force
}

$unzippedFolder = Join-Path $temp_dir $zipFolder
Copy-Item $unzippedFolder\*.jar $jce_dir -force
}
Loading

0 comments on commit 06abd7f

Please sign in to comment.