Author: rareddy
Date: 2010-09-17 18:13:20 -0400 (Fri, 17 Sep 2010)
New Revision: 2589
Added:
branches/7.1.x/client/src/test/java/org/teiid/net/TestTeiidURL.java
Removed:
branches/7.1.x/client/src/test/java/org/teiid/net/TestMMURL.java
Modified:
branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html
branches/7.1.x/client/src/main/java/org/teiid/jdbc/SocketProfile.java
branches/7.1.x/client/src/main/java/org/teiid/jdbc/TeiidDataSource.java
branches/7.1.x/client/src/main/java/org/teiid/net/TeiidURL.java
branches/7.1.x/client/src/test/java/org/teiid/jdbc/TestSocketProfile.java
branches/7.1.x/client/src/test/java/org/teiid/jdbc/TestTeiidDataSource.java
branches/7.1.x/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml
Log:
TEIID-951: adding support for IPv6 address based URLs in the JDBC URL. The IPv6 addresses
must be escaped with square brackets. like [address] in the URL.
Modified: branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html 2010-09-17 14:51:27
UTC (rev 2588)
+++ branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html 2010-09-17 22:13:20
UTC (rev 2589)
@@ -33,7 +33,8 @@
<LI><B>Simplified Role Usage</B> - a role can now be assigned to
any authenticated user via the any-authenticated attribute on the data-role element.
<LI><B>Materialized View Performance</B> - materialized view tables
will now automatically create and use non-unique secondary indexes for unique constraints
and indexes defined on the view.
<LI><B>Binary Web Service Calls</B> - the ws translator now
provides an invokeHttp procedure to return the blob contents and string content type of an
http/https call.
- <LI><B>Improved clustering support</B> - see the Admin Guide
chapter on clustering.
+ <LI><B>Improved clustering support</B> - see the Admin Guide
chapter on clustering.
+ <LI><B>IPv6 support</B> - Teiid can started using IPv6 bind address
and can be used with JDBC connection.
</UL>
<h2><a name="Compatibility">Compatibility
Issues</a></h2>
Modified: branches/7.1.x/client/src/main/java/org/teiid/jdbc/SocketProfile.java
===================================================================
--- branches/7.1.x/client/src/main/java/org/teiid/jdbc/SocketProfile.java 2010-09-17
14:51:27 UTC (rev 2588)
+++ branches/7.1.x/client/src/main/java/org/teiid/jdbc/SocketProfile.java 2010-09-17
22:13:20 UTC (rev 2589)
@@ -60,7 +60,7 @@
*/
// This host/port pattern allows just a . or a - to be in the host part.
- static final String HOST_PORT_PATTERN = "[\\p{Alnum}\\.\\-\\_]+:\\d+";
//$NON-NLS-1$
+ static final String HOST_PORT_PATTERN =
"\\[?[\\p{Alnum}\\.\\-\\_:]+\\]?:\\d+"; //$NON-NLS-1$
static final String URL_PATTERN =
"jdbc:teiid:([\\w-\\.]+)@mm[s]?://"+HOST_PORT_PATTERN+"(,"+HOST_PORT_PATTERN+")*(;.*)?";
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
static Pattern urlPattern = Pattern.compile(URL_PATTERN);
Modified: branches/7.1.x/client/src/main/java/org/teiid/jdbc/TeiidDataSource.java
===================================================================
--- branches/7.1.x/client/src/main/java/org/teiid/jdbc/TeiidDataSource.java 2010-09-17
14:51:27 UTC (rev 2588)
+++ branches/7.1.x/client/src/main/java/org/teiid/jdbc/TeiidDataSource.java 2010-09-17
22:13:20 UTC (rev 2589)
@@ -136,23 +136,42 @@
// Format: "mm://server1:port,server2:port,..."
String serverURL = ""; //$NON-NLS-1$
- serverURL = "" + ( this.secure ? TeiidURL.SECURE_PROTOCOL :
TeiidURL.DEFAULT_PROTOCOL ); //$NON-NLS-1$
- serverURL += "" + this.serverName; //$NON-NLS-1$
+ serverURL = "" + ( this.secure ? TeiidURL.SECURE_PROTOCOL :
TeiidURL.DEFAULT_PROTOCOL ); //$NON-NLS-1$
+
+ if (this.serverName.indexOf(':') != -1) {
+ serverURL += "["; //$NON-NLS-1$
+ }
+
+ serverURL += "" + this.serverName; //$NON-NLS-1$
+
+ if (this.serverName.indexOf(':') != -1) {
+ serverURL += "]"; //$NON-NLS-1$
+ }
+
if ( this.portNumber != 0 )
- serverURL += TeiidURL.COLON_DELIMITER + this.portNumber;
+ serverURL += TeiidURL.COLON_DELIMITER + this.portNumber;
+
if ( this.alternateServers.length() > 0 ) {
String[] as = this.alternateServers.split( TeiidURL.COMMA_DELIMITER);
- for ( int i = 0; i < as.length; i++ ) {
- String[] server = as[i].split( TeiidURL.COLON_DELIMITER );
-
- if ( server.length > 0 ) {
- serverURL += TeiidURL.COMMA_DELIMITER + server[0];
- if ( server.length > 1 ) {
- serverURL += TeiidURL.COLON_DELIMITER + server[1];
- } else {
- serverURL += TeiidURL.COLON_DELIMITER + this.portNumber;
- }
+ for ( int i = 0; i < as.length; i++ ) {
+ if (as[i].startsWith("[") && as[i].endsWith("]:"))
{ //$NON-NLS-1$ //$NON-NLS-2$
+ serverURL += (TeiidURL.COMMA_DELIMITER + as[i]);
+ }
+ else if (as[i].startsWith("[") &&
as[i].endsWith("]")) { //$NON-NLS-1$ //$NON-NLS-2$
+ serverURL += (TeiidURL.COMMA_DELIMITER +as[i] + TeiidURL.COLON_DELIMITER +
this.portNumber);
+ }
+ else {
+ String[] server = as[i].split(TeiidURL.COLON_DELIMITER );
+
+ if ( server.length > 0 ) {
+ serverURL += TeiidURL.COMMA_DELIMITER + server[0];
+ if ( server.length > 1 ) {
+ serverURL += TeiidURL.COLON_DELIMITER + server[1];
+ } else {
+ serverURL += TeiidURL.COLON_DELIMITER + this.portNumber;
+ }
+ }
}
}
}
Modified: branches/7.1.x/client/src/main/java/org/teiid/net/TeiidURL.java
===================================================================
--- branches/7.1.x/client/src/main/java/org/teiid/net/TeiidURL.java 2010-09-17 14:51:27
UTC (rev 2588)
+++ branches/7.1.x/client/src/main/java/org/teiid/net/TeiidURL.java 2010-09-17 22:13:20
UTC (rev 2589)
@@ -125,6 +125,9 @@
public TeiidURL(String host, int port, boolean secure) {
usingSSL = secure;
+ if(host.startsWith("[")) { //$NON-NLS-1$
+ host = host.substring(1, host.indexOf(']'));
+ }
hosts.add(new HostInfo(host, port));
}
@@ -232,13 +235,29 @@
throw new IllegalArgumentException(exceptionMessage);
}
while (st.hasMoreTokens()) {
- st2 = new StringTokenizer(st.nextToken(), COLON_DELIMITER);
+ String nextToken = st.nextToken();
try {
- String host = st2.nextToken().trim();
- String port = st2.nextToken().trim();
+ String host = ""; //$NON-NLS-1$
+ String port = ""; //$NON-NLS-1$
+ if (nextToken.startsWith("[")) { //$NON-NLS-1$
+ int hostEnd = nextToken.indexOf("]:"); //$NON-NLS-1$
+ host = nextToken.substring(1, hostEnd);
+ port = nextToken.substring(hostEnd+2);
+ }
+ else {
+ st2 = new StringTokenizer(nextToken, COLON_DELIMITER);
+ host = st2.nextToken().trim();
+ port = st2.nextToken().trim();
+ }
+
if (host.equals("")) { //$NON-NLS-1$
throw new IllegalArgumentException("hostname can't be
empty"); //$NON-NLS-1$
}
+
+ if (port.equals("")) { //$NON-NLS-1$
+ throw new IllegalArgumentException("port can't be
empty"); //$NON-NLS-1$
+ }
+
int portNumber;
try {
portNumber = Integer.parseInt(port);
@@ -250,11 +269,13 @@
}
HostInfo hostInfo = new HostInfo(host, portNumber);
hosts.add(hostInfo);
+
} catch (NoSuchElementException nsee) {
throw new IllegalArgumentException(exceptionMessage);
} catch (NullPointerException ne) {
throw new IllegalArgumentException(exceptionMessage);
}
+
}
}
@@ -275,7 +296,15 @@
Iterator<HostInfo> iter = hosts.iterator();
while (iter.hasNext()) {
HostInfo host = iter.next();
+
+ boolean ipv6HostName = host.getHostName().indexOf(':') != -1;
+ if (ipv6HostName) {
+ sb.append('[');
+ }
sb.append(host.getHostName());
+ if (ipv6HostName) {
+ sb.append(']');
+ }
sb.append(COLON_DELIMITER);
sb.append(host.getPortNumber());
if (iter.hasNext()) {
Modified: branches/7.1.x/client/src/test/java/org/teiid/jdbc/TestSocketProfile.java
===================================================================
--- branches/7.1.x/client/src/test/java/org/teiid/jdbc/TestSocketProfile.java 2010-09-17
14:51:27 UTC (rev 2588)
+++ branches/7.1.x/client/src/test/java/org/teiid/jdbc/TestSocketProfile.java 2010-09-17
22:13:20 UTC (rev 2589)
@@ -118,4 +118,27 @@
assertTrue(p.getProperty(BaseDataSource.APP_NAME).equals("Client"));
//$NON-NLS-1$
assertEquals(7, p.size());
}
+
+ @Test
+ public void testIPV6() throws SQLException{
+
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://[::1]:53535,127.0.0.1:1234"));
//$NON-NLS-1$
+
assertTrue(SocketProfile.acceptsURL("jdbc:teiid:vdb@mm://[3ffe:ffff:0100:f101::1]:53535,127.0.0.1:1234"));
//$NON-NLS-1$
+
+ Properties p = new Properties();
+
SocketProfile.parseURL("jdbc:teiid:BQT@mms://[3ffe:ffff:0100:f101::1]:1234;version=3",
p); //$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT"));
//$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("3"));
//$NON-NLS-1$
+
assertTrue(p.getProperty(TeiidURL.CONNECTION.SERVER_URL).equals("mms://[3ffe:ffff:0100:f101::1]:1234"));
//$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VERSION).equals("3"));
//$NON-NLS-1$
+ }
+
+ @Test
+ public void testIPV6MultipleHosts() throws SQLException{
+ Properties p = new Properties();
+
SocketProfile.parseURL("jdbc:teiid:BQT@mms://[3ffe:ffff:0100:f101::1]:1234,[::1]:31000,127.0.0.1:2134;version=3",
p); //$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT"));
//$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("3"));
//$NON-NLS-1$
+
assertTrue(p.getProperty(TeiidURL.CONNECTION.SERVER_URL).equals("mms://[3ffe:ffff:0100:f101::1]:1234,[::1]:31000,127.0.0.1:2134"));
//$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VERSION).equals("3"));
//$NON-NLS-1$
+ }
}
Modified: branches/7.1.x/client/src/test/java/org/teiid/jdbc/TestTeiidDataSource.java
===================================================================
--- branches/7.1.x/client/src/test/java/org/teiid/jdbc/TestTeiidDataSource.java 2010-09-17
14:51:27 UTC (rev 2588)
+++ branches/7.1.x/client/src/test/java/org/teiid/jdbc/TestTeiidDataSource.java 2010-09-17
22:13:20 UTC (rev 2589)
@@ -483,6 +483,43 @@
"jdbc:teiid:vdbName@mm://hostname:7001;fetchSize=500;ApplicationName=JDBC;VirtualDatabaseVersion=1.2.3;partialResultsMode=true;VirtualDatabaseName=vdbName");
//$NON-NLS-1$
}
+ public void testBuildingIPv6() {
+ final String serverName = "3ffe:ffff:0100:f101::1"; //$NON-NLS-1$
+ final String vdbName = "vdbName"; //$NON-NLS-1$
+ final String vdbVersion = "1"; //$NON-NLS-1$
+ final int portNumber = 7001;
+ final String transactionAutoWrap = null;
+ final String partialMode = "true"; //$NON-NLS-1$
+ final boolean secure = false;
+
helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,null,transactionAutoWrap,
partialMode, 500, false, secure,
+
"jdbc:teiid:vdbName@mm://[3ffe:ffff:0100:f101::1]:7001;fetchSize=500;ApplicationName=JDBC;VirtualDatabaseVersion=1;partialResultsMode=true;VirtualDatabaseName=vdbName");
//$NON-NLS-1$
+ }
+
+ public void testBuildingIPv6WithBrackets() {
+ final String serverName = "[3ffe:ffff:0100:f101::1]"; //$NON-NLS-1$
+ final String vdbName = "vdbName"; //$NON-NLS-1$
+ final String vdbVersion = "1"; //$NON-NLS-1$
+ final int portNumber = 7001;
+ final String transactionAutoWrap = null;
+ final String partialMode = "true"; //$NON-NLS-1$
+ final boolean secure = false;
+
helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,null,transactionAutoWrap,
partialMode, 500, false, secure,
+
"jdbc:teiid:vdbName@mm://[3ffe:ffff:0100:f101::1]:7001;fetchSize=500;ApplicationName=JDBC;VirtualDatabaseVersion=1;partialResultsMode=true;VirtualDatabaseName=vdbName");
//$NON-NLS-1$
+ }
+
+ public void testBuildingIPv6Alternate() {
+ final String serverName = "3ffe:ffff:0100:f101::1"; //$NON-NLS-1$
+ final String vdbName = "vdbName"; //$NON-NLS-1$
+ final String vdbVersion = "1"; //$NON-NLS-1$
+ final int portNumber = 7001;
+ final String transactionAutoWrap = null;
+ final String partialMode = "true"; //$NON-NLS-1$
+ final boolean secure = false;
+ final String alternates = "[::1],127.0.0.1:1234"; //$NON-NLS-1$
+
helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,alternates,transactionAutoWrap,
partialMode, 500, false, secure,
+
"jdbc:teiid:vdbName@mm://[3ffe:ffff:0100:f101::1]:7001,[::1]:7001,127.0.0.1:1234;fetchSize=500;ApplicationName=JDBC;VirtualDatabaseVersion=1;partialResultsMode=true;VirtualDatabaseName=vdbName");
//$NON-NLS-1$
+ }
+
public void testBuildingURL2() {
final String serverName = "hostName"; //$NON-NLS-1$
final String vdbName = "vdbName"; //$NON-NLS-1$
Deleted: branches/7.1.x/client/src/test/java/org/teiid/net/TestMMURL.java
===================================================================
--- branches/7.1.x/client/src/test/java/org/teiid/net/TestMMURL.java 2010-09-17 14:51:27
UTC (rev 2588)
+++ branches/7.1.x/client/src/test/java/org/teiid/net/TestMMURL.java 2010-09-17 22:13:20
UTC (rev 2589)
@@ -1,262 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package
org.teiid.net;
-
-import java.util.List;
-
-import org.teiid.net.HostInfo;
-import org.teiid.net.TeiidURL;
-
-import junit.framework.TestCase;
-
-
-
-/**
- * @since 4.2
- */
-public class TestMMURL extends TestCase {
-
- public static final String REQUIRED_URL = TeiidURL.FORMAT_SERVER;
-
- /**
- * Constructor for TestMMURL.
- * @param name
- */
- public TestMMURL(String name) {
- super(name);
- }
-
- public final void testMMURL() {
- String SERVER_URL = "mm://localhost:31000"; //$NON-NLS-1$
- assertTrue(TeiidURL.isValidServerURL(SERVER_URL));
-
- TeiidURL url = new TeiidURL(SERVER_URL);
- List hosts = url.getHostInfo();
- assertNotNull("MMURL should have 1 Host", hosts ); //$NON-NLS-1$
- assertEquals(1,hosts.size());
- }
-
- public final void testBogusProtocol() {
- String SERVER_URL = "foo://localhost:31000"; //$NON-NLS-1$
- assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
-
- try {
- new TeiidURL(SERVER_URL);
- fail("MM URL passed non standard protocal fine"); //$NON-NLS-1$
- } catch (RuntimeException e) {
- assertEquals(TeiidURL.INVALID_FORMAT_SERVER, e.getMessage());
- }
- }
- public final void testBogusProtocol1() {
- String SERVER_URL = "foo://localhost:31000"; //$NON-NLS-1$
- assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
-
- try {
- new TeiidURL(SERVER_URL);
- fail("MM URL passed non standard protocal fine"); //$NON-NLS-1$
- } catch (RuntimeException e) {
- assertEquals(TeiidURL.INVALID_FORMAT_SERVER, e.getMessage());
- }
- }
-
- public final void testMMURLSecure() {
- String SERVER_URL = "mms://localhost:31000"; //$NON-NLS-1$
- assertTrue(TeiidURL.isValidServerURL(SERVER_URL));
-
- TeiidURL url = new TeiidURL(SERVER_URL);
- List hosts = url.getHostInfo();
- assertNotNull("MMURL should have 1 Host", hosts ); //$NON-NLS-1$
- assertEquals(1,hosts.size());
- }
-
- public final void testMMURLBadProtocolMM() {
- String SERVER_URL = "mmm://localhost:31000"; //$NON-NLS-1$
- assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
-
- try {
- new TeiidURL(SERVER_URL);
- fail("MMURL did not throw an exception"); //$NON-NLS-1$
- } catch( IllegalArgumentException e ) {
- assertEquals(TeiidURL.INVALID_FORMAT_SERVER,e.getMessage());
- }
- }
-
- public final void testMMURLWrongSlash() {
- String SERVER_URL = "mm:\\\\localhost:31000"; //$NON-NLS-1$
- assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
-
- try {
- new TeiidURL(SERVER_URL);
- fail("MMURL did not throw an exception"); //$NON-NLS-1$
- } catch( IllegalArgumentException e ) {
- assertEquals(TeiidURL.INVALID_FORMAT_SERVER,e.getMessage());
- }
- }
-
- public final void testMMURLOneSlash() {
- String SERVER_URL = "mm:/localhost:31000"; //$NON-NLS-1$
- assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
-
- try {
- new TeiidURL(SERVER_URL);
- fail("MMURL did not throw an exception"); //$NON-NLS-1$
- } catch( IllegalArgumentException e ) {
- assertEquals(TeiidURL.INVALID_FORMAT_SERVER,e.getMessage());
- }
- }
-
- public final void testMMURLNoHost() {
- String SERVER_URL = "mm://:31000"; //$NON-NLS-1$
- assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
-
- try {
- new TeiidURL(SERVER_URL);
- fail("MMURL did not throw an exception"); //$NON-NLS-1$
- } catch( IllegalArgumentException e ) {
- assertEquals(TeiidURL.INVALID_FORMAT_SERVER,e.getMessage());
- }
- }
-
- public final void testMMURLNoHostAndPort() {
- String SERVER_URL = "mm://:"; //$NON-NLS-1$
- assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
-
- try {
- new TeiidURL(SERVER_URL);
- fail("MMURL did not throw an exception"); //$NON-NLS-1$
- } catch( IllegalArgumentException e ) {
- assertEquals(TeiidURL.INVALID_FORMAT_SERVER,e.getMessage());
- }
- }
-
- public final void testMMURLNoHostAndPort2() {
- String SERVER_URL = "mm://"; //$NON-NLS-1$
- assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
-
- try {
- new TeiidURL(SERVER_URL);
- fail("MMURL did not throw an exception"); //$NON-NLS-1$
- } catch( IllegalArgumentException e ) {
- assertEquals(TeiidURL.INVALID_FORMAT_SERVER,e.getMessage());
- }
- }
-
- public final void testMMURLBadPort() {
- String SERVER_URL = "mm://localhost:port"; //$NON-NLS-1$
- assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
-
- try {
- new TeiidURL(SERVER_URL);
- fail("MMURL did not throw an Exception"); //$NON-NLS-1$
- } catch( IllegalArgumentException e ) {
- }
- }
-
- public final void testMMURL2Hosts() {
- String SERVER_URL = "mm://localhost:31000,localhost:31001";
//$NON-NLS-1$
- assertTrue(TeiidURL.isValidServerURL(SERVER_URL));
-
- TeiidURL url = new TeiidURL(SERVER_URL);
- List hosts = url.getHostInfo();
- assertNotNull("MMURL should have 2 Host", hosts ); //$NON-NLS-1$
- assertEquals(2,hosts.size());
- }
-
- public final void testMMURL3Hosts() {
- String SERVER_URL =
"mm://localhost:31000,localhost:31001,localhost:31002"; //$NON-NLS-1$
- assertTrue(TeiidURL.isValidServerURL(SERVER_URL));
-
- TeiidURL url = new TeiidURL(SERVER_URL);
- List hosts = url.getHostInfo();
- assertNotNull("MMURL should have 3 Host", hosts ); //$NON-NLS-1$
- assertEquals(3,hosts.size());
- }
-
- public final void testGetHostInfo() {
- String SERVER_URL = "mm://localhost:31000"; //$NON-NLS-1$
- assertTrue(TeiidURL.isValidServerURL(SERVER_URL));
-
- TeiidURL url = new TeiidURL(SERVER_URL);
- assertNotNull(url.getHostInfo() );
- }
-
- public final void testGetProtocolStandalone() {
- TeiidURL url = new TeiidURL("mm://localhost:31000"); //$NON-NLS-1$
- assertNotNull(url);
- assertEquals("mm://localhost:31000",url.getAppServerURL());
//$NON-NLS-1$
- }
-
- public final void testHasMoreElements() {
- TeiidURL url = new TeiidURL("mm://localhost:31000,localhost:31001");
//$NON-NLS-1$
- assertNotNull(url);
- assertFalse(url.getHostInfo().isEmpty());
- }
-
- public final void testNextElement() {
- TeiidURL url = new TeiidURL("mm://localhost:31000,localhost:31001");
//$NON-NLS-1$
- assertEquals(2, url.getHostInfo().size());
- }
-
- public final void testHostInfoEquals() {
- HostInfo expectedResults = new HostInfo("localhost",31000);
//$NON-NLS-1$
- TeiidURL url = new TeiidURL("mm://localhost:31000"); //$NON-NLS-1$
- HostInfo actualResults = url.getHostInfo().get(0);
- assertEquals(expectedResults,actualResults);
- }
-
- public final void testWithEmbeddedSpaces() {
- HostInfo expectedResults = new HostInfo("localhost",12345);
//$NON-NLS-1$
-
- TeiidURL url = new TeiidURL("mm://localhost : 12345"); //$NON-NLS-1$
- List hosts = url.getHostInfo();
- assertNotNull("MMURL should have 1 Host", hosts ); //$NON-NLS-1$
- assertEquals(1,hosts.size());
- HostInfo actualResults = url.getHostInfo().get(0);
- assertEquals(expectedResults,actualResults);
- }
-
- public final void testHostPortConstructor() {
- HostInfo expectedResults = new HostInfo("myhost", 12345);
//$NON-NLS-1$
-
- TeiidURL url = new TeiidURL("myhost", 12345, false); //$NON-NLS-1$
- List hosts = url.getHostInfo();
- assertNotNull("MMURL should have 1 Host", hosts ); //$NON-NLS-1$
- assertEquals(1,hosts.size());
- HostInfo actualResults = url.getHostInfo().get(0);
- assertEquals(expectedResults,actualResults);
- assertEquals("mm://myhost:12345", url.getAppServerURL());
//$NON-NLS-1$
- }
-
- public final void testHostPortConstructorSSL() {
- HostInfo expectedResults = new HostInfo("myhost",12345); //$NON-NLS-1$
-
- TeiidURL url = new TeiidURL("myhost", 12345, true); //$NON-NLS-1$
- List hosts = url.getHostInfo();
- assertNotNull("MMURL should have 1 Host", hosts ); //$NON-NLS-1$
- assertEquals(1,hosts.size());
- HostInfo actualResults = url.getHostInfo().get(0);
- assertEquals(expectedResults,actualResults);
- assertEquals("mms://myhost:12345", url.getAppServerURL());
//$NON-NLS-1$
- }
-
-}
Copied: branches/7.1.x/client/src/test/java/org/teiid/net/TestTeiidURL.java (from rev
2585, branches/7.1.x/client/src/test/java/org/teiid/net/TestMMURL.java)
===================================================================
--- branches/7.1.x/client/src/test/java/org/teiid/net/TestTeiidURL.java
(rev 0)
+++ branches/7.1.x/client/src/test/java/org/teiid/net/TestTeiidURL.java 2010-09-17
22:13:20 UTC (rev 2589)
@@ -0,0 +1,298 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package
org.teiid.net;
+
+import java.util.List;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+
+public class TestTeiidURL {
+
+ public static final String REQUIRED_URL = TeiidURL.FORMAT_SERVER;
+
+ @Test
+ public final void testTeiidURL() {
+ String SERVER_URL = "mm://localhost:31000"; //$NON-NLS-1$
+ assertTrue(TeiidURL.isValidServerURL(SERVER_URL));
+
+ TeiidURL url = new TeiidURL(SERVER_URL);
+ List hosts = url.getHostInfo();
+ assertNotNull("MMURL should have 1 Host", hosts ); //$NON-NLS-1$
+ assertEquals(1,hosts.size());
+ }
+
+ @Test
+ public final void testTeiidURLIPv6() {
+ String SERVER_URL = "mm://[3ffe:ffff:0100:f101::1]:31000";
//$NON-NLS-1$
+ assertTrue(TeiidURL.isValidServerURL(SERVER_URL));
+
+ TeiidURL url = new TeiidURL(SERVER_URL);
+ List<HostInfo> hosts = url.getHostInfo();
+ assertNotNull("TeiidURL should have 1 Host", hosts ); //$NON-NLS-1$
+ assertEquals(1,hosts.size());
+ assertEquals("3ffe:ffff:0100:f101::1", hosts.get(0).getHostName());
//$NON-NLS-1$
+ assertEquals(31000, hosts.get(0).getPortNumber());
+ }
+
+ @Test
+ public final void testBogusProtocol() {
+ String SERVER_URL = "foo://localhost:31000"; //$NON-NLS-1$
+ assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
+
+ try {
+ new TeiidURL(SERVER_URL);
+ fail("MM URL passed non standard protocal fine"); //$NON-NLS-1$
+ } catch (RuntimeException e) {
+ assertEquals(TeiidURL.INVALID_FORMAT_SERVER, e.getMessage());
+ }
+ }
+
+ @Test
+ public final void testBogusProtocol1() {
+ String SERVER_URL = "foo://localhost:31000"; //$NON-NLS-1$
+ assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
+
+ try {
+ new TeiidURL(SERVER_URL);
+ fail("MM URL passed non standard protocal fine"); //$NON-NLS-1$
+ } catch (RuntimeException e) {
+ assertEquals(TeiidURL.INVALID_FORMAT_SERVER, e.getMessage());
+ }
+ }
+
+ @Test
+ public final void testTeiidURLSecure() {
+ String SERVER_URL = "mms://localhost:31000"; //$NON-NLS-1$
+ assertTrue(TeiidURL.isValidServerURL(SERVER_URL));
+
+ TeiidURL url = new TeiidURL(SERVER_URL);
+ List hosts = url.getHostInfo();
+ assertNotNull("MMURL should have 1 Host", hosts ); //$NON-NLS-1$
+ assertEquals(1,hosts.size());
+ }
+
+ @Test
+ public final void testTeiidURLBadProtocolMM() {
+ String SERVER_URL = "mmm://localhost:31000"; //$NON-NLS-1$
+ assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
+
+ try {
+ new TeiidURL(SERVER_URL);
+ fail("MMURL did not throw an exception"); //$NON-NLS-1$
+ } catch( IllegalArgumentException e ) {
+ assertEquals(TeiidURL.INVALID_FORMAT_SERVER,e.getMessage());
+ }
+ }
+
+ @Test
+ public final void testTeiidURLWrongSlash() {
+ String SERVER_URL = "mm:\\\\localhost:31000"; //$NON-NLS-1$
+ assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
+
+ try {
+ new TeiidURL(SERVER_URL);
+ fail("MMURL did not throw an exception"); //$NON-NLS-1$
+ } catch( IllegalArgumentException e ) {
+ assertEquals(TeiidURL.INVALID_FORMAT_SERVER,e.getMessage());
+ }
+ }
+
+ @Test
+ public final void testTeiidURLOneSlash() {
+ String SERVER_URL = "mm:/localhost:31000"; //$NON-NLS-1$
+ assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
+
+ try {
+ new TeiidURL(SERVER_URL);
+ fail("MMURL did not throw an exception"); //$NON-NLS-1$
+ } catch( IllegalArgumentException e ) {
+ assertEquals(TeiidURL.INVALID_FORMAT_SERVER,e.getMessage());
+ }
+ }
+
+ @Test
+ public final void testTeiidURLNoHost() {
+ String SERVER_URL = "mm://:31000"; //$NON-NLS-1$
+ assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
+
+ try {
+ new TeiidURL(SERVER_URL);
+ fail("MMURL did not throw an exception"); //$NON-NLS-1$
+ } catch( IllegalArgumentException e ) {
+ assertEquals(TeiidURL.INVALID_FORMAT_SERVER,e.getMessage());
+ }
+ }
+
+ @Test
+ public final void testTeiidURLNoHostAndPort() {
+ String SERVER_URL = "mm://:"; //$NON-NLS-1$
+ assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
+
+ try {
+ new TeiidURL(SERVER_URL);
+ fail("MMURL did not throw an exception"); //$NON-NLS-1$
+ } catch( IllegalArgumentException e ) {
+ assertEquals(TeiidURL.INVALID_FORMAT_SERVER,e.getMessage());
+ }
+ }
+
+ @Test
+ public final void testTeiidURLNoHostAndPort2() {
+ String SERVER_URL = "mm://"; //$NON-NLS-1$
+ assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
+
+ try {
+ new TeiidURL(SERVER_URL);
+ fail("MMURL did not throw an exception"); //$NON-NLS-1$
+ } catch( IllegalArgumentException e ) {
+ assertEquals(TeiidURL.INVALID_FORMAT_SERVER,e.getMessage());
+ }
+ }
+
+ @Test
+ public final void testTeiidURLBadPort() {
+ String SERVER_URL = "mm://localhost:port"; //$NON-NLS-1$
+ assertFalse(TeiidURL.isValidServerURL(SERVER_URL));
+
+ try {
+ new TeiidURL(SERVER_URL);
+ fail("MMURL did not throw an Exception"); //$NON-NLS-1$
+ } catch( IllegalArgumentException e ) {
+ }
+ }
+
+ @Test
+ public final void testTeiidURL2Hosts() {
+ String SERVER_URL = "mm://localhost:31000,localhost:31001";
//$NON-NLS-1$
+ assertTrue(TeiidURL.isValidServerURL(SERVER_URL));
+
+ TeiidURL url = new TeiidURL(SERVER_URL);
+ List hosts = url.getHostInfo();
+ assertNotNull("MMURL should have 2 Host", hosts ); //$NON-NLS-1$
+ assertEquals(2,hosts.size());
+ }
+
+ @Test
+ public final void testTeiidIPv6URL2Hosts() {
+ String SERVER_URL = "mm://[3ffe:ffff:0100:f101::1]:31000,[::1]:31001,
127.0.0.1:31003"; //$NON-NLS-1$
+ assertTrue(TeiidURL.isValidServerURL(SERVER_URL));
+
+ TeiidURL url = new TeiidURL(SERVER_URL);
+ List<HostInfo> hosts = url.getHostInfo();
+ assertNotNull("TeiidURL should have 3 Host", hosts ); //$NON-NLS-1$
+ assertEquals(3, hosts.size());
+
+ assertEquals("3ffe:ffff:0100:f101::1",
hosts.get(0).getHostName());//$NON-NLS-1$
+ assertEquals(31001, hosts.get(1).getPortNumber());
+ assertEquals("127.0.0.1", hosts.get(2).getHostName());//$NON-NLS-1$
+ }
+
+ @Test
+ public final void testTeiidURL3Hosts() {
+ String SERVER_URL =
"mm://localhost:31000,localhost:31001,localhost:31002"; //$NON-NLS-1$
+ assertTrue(TeiidURL.isValidServerURL(SERVER_URL));
+
+ TeiidURL url = new TeiidURL(SERVER_URL);
+ List hosts = url.getHostInfo();
+ assertNotNull("MMURL should have 3 Host", hosts ); //$NON-NLS-1$
+ assertEquals(3,hosts.size());
+ }
+
+ @Test
+ public final void testGetHostInfo() {
+ String SERVER_URL = "mm://localhost:31000"; //$NON-NLS-1$
+ assertTrue(TeiidURL.isValidServerURL(SERVER_URL));
+
+ TeiidURL url = new TeiidURL(SERVER_URL);
+ assertNotNull(url.getHostInfo() );
+ }
+
+ @Test
+ public final void testGetProtocolStandalone() {
+ TeiidURL url = new TeiidURL("mm://localhost:31000"); //$NON-NLS-1$
+ assertNotNull(url);
+ assertEquals("mm://localhost:31000",url.getAppServerURL());
//$NON-NLS-1$
+ }
+
+ @Test
+ public final void testHasMoreElements() {
+ TeiidURL url = new TeiidURL("mm://localhost:31000,localhost:31001");
//$NON-NLS-1$
+ assertNotNull(url);
+ assertFalse(url.getHostInfo().isEmpty());
+ }
+
+ @Test
+ public final void testNextElement() {
+ TeiidURL url = new TeiidURL("mm://localhost:31000,localhost:31001");
//$NON-NLS-1$
+ assertEquals(2, url.getHostInfo().size());
+ }
+
+ @Test
+ public final void testHostInfoEquals() {
+ HostInfo expectedResults = new HostInfo("localhost",31000);
//$NON-NLS-1$
+ TeiidURL url = new TeiidURL("mm://localhost:31000"); //$NON-NLS-1$
+ HostInfo actualResults = url.getHostInfo().get(0);
+ assertEquals(expectedResults,actualResults);
+ }
+
+ @Test
+ public final void testWithEmbeddedSpaces() {
+ HostInfo expectedResults = new HostInfo("localhost",12345);
//$NON-NLS-1$
+
+ TeiidURL url = new TeiidURL("mm://localhost : 12345"); //$NON-NLS-1$
+ List hosts = url.getHostInfo();
+ assertNotNull("MMURL should have 1 Host", hosts ); //$NON-NLS-1$
+ assertEquals(1,hosts.size());
+ HostInfo actualResults = url.getHostInfo().get(0);
+ assertEquals(expectedResults,actualResults);
+ }
+
+ @Test
+ public final void testHostPortConstructor() {
+ HostInfo expectedResults = new HostInfo("myhost", 12345);
//$NON-NLS-1$
+
+ TeiidURL url = new TeiidURL("myhost", 12345, false); //$NON-NLS-1$
+ List hosts = url.getHostInfo();
+ assertNotNull("MMURL should have 1 Host", hosts ); //$NON-NLS-1$
+ assertEquals(1,hosts.size());
+ HostInfo actualResults = url.getHostInfo().get(0);
+ assertEquals(expectedResults,actualResults);
+ assertEquals("mm://myhost:12345", url.getAppServerURL());
//$NON-NLS-1$
+ }
+
+ @Test
+ public final void testHostPortConstructorSSL() {
+ HostInfo expectedResults = new HostInfo("myhost",12345); //$NON-NLS-1$
+
+ TeiidURL url = new TeiidURL("myhost", 12345, true); //$NON-NLS-1$
+ List hosts = url.getHostInfo();
+ assertNotNull("MMURL should have 1 Host", hosts ); //$NON-NLS-1$
+ assertEquals(1,hosts.size());
+ HostInfo actualResults = url.getHostInfo().get(0);
+ assertEquals(expectedResults,actualResults);
+ assertEquals("mms://myhost:12345", url.getAppServerURL());
//$NON-NLS-1$
+ }
+
+}
Modified:
branches/7.1.x/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml
===================================================================
---
branches/7.1.x/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml 2010-09-17
14:51:27 UTC (rev 2588)
+++
branches/7.1.x/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml 2010-09-17
22:13:20 UTC (rev 2589)
@@ -53,7 +53,7 @@
the "version" property at the same time is not allowed.
</para></listitem>
<listitem><para>mm - defines Teiid JDBC protocol, mms defines a
secure channel (see the <link linkend="ssl">SSL chapter</link> for
more)</para></listitem>
- <listitem><para><host> - defines the server where
the Teiid Server is installed</para></listitem>
+ <listitem><para><host> - defines the server where
the Teiid Server is installed. If you are using IPv6 binding address as the host name,
place it in square brackets. ex:[::1]</para></listitem>
<listitem><para><port> - defines the port on which
the Teiid Server is listening for incoming JDBC
connections.</para></listitem>
<listitem><para>[prop-name=prop-value] - additionally you can
supply any number of name value pairs separated by semi-colon
[;]. All supported URL properties are defined in the <link
linkend="connection_properties">connection properties section</link>.
Property values should be URL encoded if they contain reserved characters, e.g.
('?', '=', ';', etc.)</para></listitem>
@@ -276,7 +276,8 @@
<entry>
<code>String</code>
</entry>
- <entry>Server where the Teiid runtime
installed</entry>
+ <entry>Server hostname where the Teiid runtime installed.
If you are using IPv6 binding address as the host name,
+ place it in square brackets. ex:[::1]</entry>
</row>
<row>
<entry>
@@ -285,7 +286,9 @@
<entry>
<code>String</code>
</entry>
- <entry>Optional delimited list of host:port entries. See
the <link linkend="multiple_hosts">multiple hosts</link> section for
more information.</entry>
+ <entry>Optional delimited list of host:port entries. See
the <link linkend="multiple_hosts">multiple hosts</link>
+ section for more information. If you are using IPv6 binding
address as the host name,
+ place them in square brackets. ex:[::1]</entry>
</row>
<row>
<entry>