File tree Expand file tree Collapse file tree 3 files changed +58
-3
lines changed
main/java/io/vertx/mssqlclient
test/java/io/vertx/mssqlclient Expand file tree Collapse file tree 3 files changed +58
-3
lines changed Original file line number Diff line number Diff line change @@ -41,12 +41,14 @@ public class MSSQLConnectOptions extends SqlConnectOptions {
41
41
public static final String DEFAULT_USER = "sa" ;
42
42
public static final String DEFAULT_PASSWORD = "" ;
43
43
public static final String DEFAULT_SCHEMA = "" ;
44
+ public static final String DEFAULT_APP_NAME = "vertx-mssql-client" ;
45
+ public static final String DEFAULT_CLIENT_INTERFACE_NAME = "Vert.x" ;
44
46
public static final Map <String , String > DEFAULT_PROPERTIES ;
45
47
46
48
static {
47
49
Map <String , String > defaultProperties = new HashMap <>();
48
- defaultProperties .put ("appName" , "vertx-mssql-client" );
49
- defaultProperties .put ("clientInterfaceName" , "Vert.x" );
50
+ defaultProperties .put ("appName" , DEFAULT_APP_NAME );
51
+ defaultProperties .put ("clientInterfaceName" , DEFAULT_CLIENT_INTERFACE_NAME );
50
52
DEFAULT_PROPERTIES = defaultProperties ;
51
53
}
52
54
@@ -58,7 +60,7 @@ public MSSQLConnectOptions(JsonObject json) {
58
60
super (json );
59
61
MSSQLConnectOptionsConverter .fromJson (json , this );
60
62
}
61
-
63
+
62
64
public MSSQLConnectOptions (SqlConnectOptions other ) {
63
65
super (other );
64
66
}
Original file line number Diff line number Diff line change 13
13
14
14
import io .netty .buffer .ByteBuf ;
15
15
import io .netty .channel .ChannelHandlerContext ;
16
+ import io .vertx .mssqlclient .MSSQLConnectOptions ;
16
17
import io .vertx .mssqlclient .impl .protocol .MessageStatus ;
17
18
import io .vertx .mssqlclient .impl .protocol .MessageType ;
18
19
import io .vertx .mssqlclient .impl .protocol .TdsMessage ;
@@ -116,6 +117,9 @@ private void sendLoginMessage() {
116
117
117
118
// AppName
118
119
CharSequence appName = properties .get ("appName" );
120
+ if (appName == null || appName .length () == 0 ) {
121
+ appName = MSSQLConnectOptions .DEFAULT_APP_NAME ;
122
+ }
119
123
int appNameOffsetLengthIdx = packet .writerIndex ();
120
124
packet .writeShortLE (0x00 ); // offset
121
125
packet .writeShortLE (appName .length ());
@@ -133,6 +137,9 @@ private void sendLoginMessage() {
133
137
134
138
// CltIntName
135
139
CharSequence interfaceLibraryName = properties .get ("clientInterfaceName" );
140
+ if (interfaceLibraryName == null || interfaceLibraryName .length () == 0 ) {
141
+ interfaceLibraryName = MSSQLConnectOptions .DEFAULT_CLIENT_INTERFACE_NAME ;
142
+ }
136
143
int cltIntNameOffsetLengthIdx = packet .writerIndex ();
137
144
packet .writeShortLE (0x00 ); // offset
138
145
packet .writeShortLE (interfaceLibraryName .length ());
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
7
+ * which is available at https://www.apache.org/licenses/LICENSE-2.0.
8
+ *
9
+ * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
10
+ */
11
+
12
+ package io .vertx .mssqlclient ;
13
+
14
+ import io .vertx .core .Vertx ;
15
+ import io .vertx .ext .unit .TestContext ;
16
+ import io .vertx .ext .unit .junit .VertxUnitRunner ;
17
+ import io .vertx .sqlclient .SqlConnection ;
18
+ import org .junit .After ;
19
+ import org .junit .Before ;
20
+ import org .junit .Test ;
21
+ import org .junit .runner .RunWith ;
22
+
23
+ import java .util .HashMap ;
24
+
25
+ @ RunWith (VertxUnitRunner .class )
26
+ public class MSSQLConnectionTest extends MSSQLTestBase {
27
+ Vertx vertx ;
28
+ MSSQLConnectOptions options ;
29
+
30
+ @ Before
31
+ public void setup () {
32
+ vertx = Vertx .vertx ();
33
+ options = new MSSQLConnectOptions (MSSQLTestBase .options );
34
+ }
35
+
36
+ @ After
37
+ public void tearDown (TestContext ctx ) {
38
+ vertx .close (ctx .asyncAssertSuccess ());
39
+ }
40
+
41
+ @ Test
42
+ public void testConnectWithEmptyProperties (TestContext ctx ) {
43
+ options .setProperties (new HashMap <>());
44
+ MSSQLConnection .connect (vertx , options , ctx .asyncAssertSuccess (SqlConnection ::close ));
45
+ }
46
+ }
You can’t perform that action at this time.
0 commit comments