提交 30dbb194 authored 作者: Thomas Mueller Graf's avatar Thomas Mueller Graf

Formatting and Javadocs

上级 11c11898
...@@ -92,6 +92,10 @@ Adds a new column to a table." ...@@ -92,6 +92,10 @@ Adds a new column to a table."
ALTER TABLE tableName ADD constraint [ CHECK | NOCHECK ] ALTER TABLE tableName ADD constraint [ CHECK | NOCHECK ]
"," ","
Adds a constraint to a table." Adds a constraint to a table."
"Commands (DDL)","ALTER TABLE RENAME CONSTRAINT","
ALTER TABLE tableName RENAME oldConstraintName TO newConstraintName
","
Renames a constraint."
"Commands (DDL)","ALTER TABLE ALTER COLUMN"," "Commands (DDL)","ALTER TABLE ALTER COLUMN","
ALTER TABLE tableName ALTER COLUMN columnName ALTER TABLE tableName ALTER COLUMN columnName
{ { dataType [ DEFAULT expression ] [ [ NOT ] NULL ] [ AUTO_INCREMENT | IDENTITY ] } { { dataType [ DEFAULT expression ] [ [ NOT ] NULL ] [ AUTO_INCREMENT | IDENTITY ] }
......
...@@ -13,6 +13,9 @@ import org.junit.Test; ...@@ -13,6 +13,9 @@ import org.junit.Test;
*/ */
public class TestAllJunit { public class TestAllJunit {
/**
* Run all the fast tests.
*/
@Test @Test
public void testFast() throws Exception { public void testFast() throws Exception {
TestAll.main("fast"); TestAll.main("fast");
......
...@@ -37,7 +37,8 @@ public class TestConnection extends TestBase { ...@@ -37,7 +37,8 @@ public class TestConnection extends TestBase {
} }
private void testSetInternalProperty() throws SQLException { private void testSetInternalProperty() throws SQLException {
// Use MySQL-mode since this allows all property names (apart from h2 internal names). // Use MySQL-mode since this allows all property names
// (apart from h2 internal names).
Connection conn = getConnection("clientInfoMySQL;MODE=MySQL"); Connection conn = getConnection("clientInfoMySQL;MODE=MySQL");
assertThrows(SQLClientInfoException.class, conn).setClientInfo("numServers", "SomeValue"); assertThrows(SQLClientInfoException.class, conn).setClientInfo("numServers", "SomeValue");
...@@ -48,7 +49,7 @@ public class TestConnection extends TestBase { ...@@ -48,7 +49,7 @@ public class TestConnection extends TestBase {
Connection conn = getConnection("clientInfo"); Connection conn = getConnection("clientInfo");
Properties properties = new Properties(); Properties properties = new Properties();
properties.put("ClientUser", "someuser"); properties.put("ClientUser", "someUser");
assertThrows(SQLClientInfoException.class, conn).setClientInfo(properties); assertThrows(SQLClientInfoException.class, conn).setClientInfo(properties);
} }
...@@ -58,12 +59,12 @@ public class TestConnection extends TestBase { ...@@ -58,12 +59,12 @@ public class TestConnection extends TestBase {
conn.setClientInfo("ApplicationName", "Connection Test"); conn.setClientInfo("ApplicationName", "Connection Test");
Properties properties = new Properties(); Properties properties = new Properties();
properties.put("ClientUser", "someuser"); properties.put("ClientUser", "someUser");
conn.setClientInfo(properties); conn.setClientInfo(properties);
// old property should have been removed // old property should have been removed
assertNull(conn.getClientInfo("ApplicationName")); assertNull(conn.getClientInfo("ApplicationName"));
// new property has been set // new property has been set
assertEquals(conn.getClientInfo("ClientUser"), "someuser"); assertEquals(conn.getClientInfo("ClientUser"), "someUser");
} }
private void testSetSupportedClientInfo() throws SQLException { private void testSetSupportedClientInfo() throws SQLException {
...@@ -75,7 +76,8 @@ public class TestConnection extends TestBase { ...@@ -75,7 +76,8 @@ public class TestConnection extends TestBase {
private void testSetUnsupportedClientInfo() throws SQLException { private void testSetUnsupportedClientInfo() throws SQLException {
Connection conn = getConnection("clientInfoDB2;MODE=DB2"); Connection conn = getConnection("clientInfoDB2;MODE=DB2");
assertThrows(SQLClientInfoException.class, conn).setClientInfo("UnsupportedName", "SomeValue"); assertThrows(SQLClientInfoException.class, conn).setClientInfo(
"UnsupportedName", "SomeValue");
} }
private void testGetUnsupportedClientInfo() throws SQLException { private void testGetUnsupportedClientInfo() throws SQLException {
......
...@@ -132,7 +132,7 @@ public class CalculateHashConstantLong implements Runnable { ...@@ -132,7 +132,7 @@ public class CalculateHashConstantLong implements Runnable {
System.out.println("Collisions: " + collisions); System.out.println("Collisions: " + collisions);
} }
static void printQuality(CalculateHashConstantLong test, long[] randomValues) { private static void printQuality(CalculateHashConstantLong test, long[] randomValues) {
int finalCount = randomValues.length * 10; int finalCount = randomValues.length * 10;
System.out.println("Quality of " + test); System.out.println("Quality of " + test);
int[] minMax; int[] minMax;
......
...@@ -36,12 +36,17 @@ public class TestMode extends TestBase { ...@@ -36,12 +36,17 @@ public class TestMode extends TestBase {
private void testDb2ClientInfo() { private void testDb2ClientInfo() {
Mode db2Mode = Mode.getInstance("DB2"); Mode db2Mode = Mode.getInstance("DB2");
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher("ApplicationName").matches()); assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher(
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher("ClientAccountingInformation").matches()); "ApplicationName").matches());
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher("ClientUser").matches()); assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher(
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher("ClientCorrelationToken").matches()); "ClientAccountingInformation").matches());
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher(
assertFalse(db2Mode.supportedClientInfoPropertiesRegEx.matcher("AnyOtherValue").matches()); "ClientUser").matches());
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher(
"ClientCorrelationToken").matches());
assertFalse(db2Mode.supportedClientInfoPropertiesRegEx.matcher(
"AnyOtherValue").matches());
} }
private void testDerbyClientInfo() { private void testDerbyClientInfo() {
...@@ -61,22 +66,25 @@ public class TestMode extends TestBase { ...@@ -61,22 +66,25 @@ public class TestMode extends TestBase {
private void testMySqlClientInfo() { private void testMySqlClientInfo() {
Mode mySqlMode = Mode.getInstance("MySQL"); Mode mySqlMode = Mode.getInstance("MySQL");
assertTrue(mySqlMode.supportedClientInfoPropertiesRegEx.matcher("AnyString").matches()); assertTrue(mySqlMode.supportedClientInfoPropertiesRegEx.matcher(
"AnyString").matches());
} }
private void testOracleClientInfo() { private void testOracleClientInfo() {
Mode oracleMode = Mode.getInstance("Oracle"); Mode oracleMode = Mode.getInstance("Oracle");
assertTrue(oracleMode.supportedClientInfoPropertiesRegEx.matcher("anythingContaining.aDot").matches()); assertTrue(oracleMode.supportedClientInfoPropertiesRegEx.matcher(
assertFalse(oracleMode.supportedClientInfoPropertiesRegEx.matcher("anythingContainingNoDot").matches()); "anythingContaining.aDot").matches());
assertFalse(oracleMode.supportedClientInfoPropertiesRegEx.matcher(
"anythingContainingNoDot").matches());
} }
private void testPostgresqlClientInfo() { private void testPostgresqlClientInfo() {
Mode postgresqlMode = Mode.getInstance("PostgreSQL"); Mode postgresqlMode = Mode.getInstance("PostgreSQL");
assertTrue(postgresqlMode.supportedClientInfoPropertiesRegEx.matcher(
assertTrue(postgresqlMode.supportedClientInfoPropertiesRegEx.matcher("ApplicationName").matches()); "ApplicationName").matches());
assertFalse(postgresqlMode.supportedClientInfoPropertiesRegEx.matcher(
assertFalse(postgresqlMode.supportedClientInfoPropertiesRegEx.matcher("AnyOtherValue").matches()); "AnyOtherValue").matches());
} }
} }
...@@ -155,7 +155,12 @@ public class TestNetUtils extends TestBase { ...@@ -155,7 +155,12 @@ public class TestNetUtils extends TestBase {
return task; return task;
} }
private void closeSilently(Socket socket) { /**
* Close a socket, ignoring errors
*
* @param socket the socket
*/
void closeSilently(Socket socket) {
try { try {
socket.close(); socket.close();
} catch (Exception e) { } catch (Exception e) {
...@@ -163,7 +168,12 @@ public class TestNetUtils extends TestBase { ...@@ -163,7 +168,12 @@ public class TestNetUtils extends TestBase {
} }
} }
private void closeSilently(ServerSocket socket) { /**
* Close a server socket, ignoring errors
*
* @param socket the server socket
*/
void closeSilently(ServerSocket socket) {
try { try {
socket.close(); socket.close();
} catch (Exception e) { } catch (Exception e) {
......
...@@ -36,7 +36,7 @@ public class TestSecurity extends TestBase { ...@@ -36,7 +36,7 @@ public class TestSecurity extends TestBase {
testSHA(); testSHA();
testAES(); testAES();
testBlockCiphers(); testBlockCiphers();
testRemoveAnonFromLegacyAlgos(); testRemoveAnonFromLegacyAlgorithms();
//testResetLegacyAlgos(); //testResetLegacyAlgos();
} }
...@@ -254,7 +254,7 @@ public class TestSecurity extends TestBase { ...@@ -254,7 +254,7 @@ public class TestSecurity extends TestBase {
return len * r < len * 120; return len * r < len * 120;
} }
private void testRemoveAnonFromLegacyAlgos() { private void testRemoveAnonFromLegacyAlgorithms() {
String legacyAlgos = "K_NULL, C_NULL, M_NULL, DHE_DSS_EXPORT" + String legacyAlgos = "K_NULL, C_NULL, M_NULL, DHE_DSS_EXPORT" +
", DHE_RSA_EXPORT, DH_anon_EXPORT, DH_DSS_EXPORT, DH_RSA_EXPORT, RSA_EXPORT" + ", DHE_RSA_EXPORT, DH_anon_EXPORT, DH_DSS_EXPORT, DH_RSA_EXPORT, RSA_EXPORT" +
", DH_anon, ECDH_anon, RC4_128, RC4_40, DES_CBC, DES40_CBC"; ", DH_anon, ECDH_anon, RC4_128, RC4_40, DES_CBC, DES40_CBC";
...@@ -282,13 +282,13 @@ public class TestSecurity extends TestBase { ...@@ -282,13 +282,13 @@ public class TestSecurity extends TestBase {
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
private void testResetLegacyAlgos() { private void testResetLegacyAlgos() {
String legacyAlgorithmsBefore = CipherFactory.getLegacyAlgoritmsSilently(); String legacyAlgorithmsBefore = CipherFactory.getLegacyAlgorithmsSilently();
assertEquals("Failed assumption: jdk.tls.legacyAlgorithms" + assertEquals("Failed assumption: jdk.tls.legacyAlgorithms" +
" has been modified from its initial setting", " has been modified from its initial setting",
CipherFactory.DEFAULT_LEGACY_ALGORITHMS, legacyAlgorithmsBefore); CipherFactory.DEFAULT_LEGACY_ALGORITHMS, legacyAlgorithmsBefore);
CipherFactory.removeAnonFromLegacyAlgorithms(); CipherFactory.removeAnonFromLegacyAlgorithms();
CipherFactory.resetDefaultLegacyAlgorithms(); CipherFactory.resetDefaultLegacyAlgorithms();
String legacyAlgorithmsAfter = CipherFactory.getLegacyAlgoritmsSilently(); String legacyAlgorithmsAfter = CipherFactory.getLegacyAlgorithmsSilently();
assertEquals(CipherFactory.DEFAULT_LEGACY_ALGORITHMS, legacyAlgorithmsAfter); assertEquals(CipherFactory.DEFAULT_LEGACY_ALGORITHMS, legacyAlgorithmsAfter);
} }
......
...@@ -39,7 +39,7 @@ public class TestTimeStampWithTimeZone extends TestBase { ...@@ -39,7 +39,7 @@ public class TestTimeStampWithTimeZone extends TestBase {
stat.execute("insert into test(t1) values('1970-01-01 12:00:00.00+00:15')"); stat.execute("insert into test(t1) values('1970-01-01 12:00:00.00+00:15')");
ResultSet rs = stat.executeQuery("select t1 from test"); ResultSet rs = stat.executeQuery("select t1 from test");
rs.next(); rs.next();
assertTrue(new TimestampWithTimeZone(36000000, 00, (short)15).equals(rs.getTimestamp(1))); assertTrue(new TimestampWithTimeZone(36000000, 00, (short) 15).equals(rs.getTimestamp(1)));
conn.close(); conn.close();
} }
......
...@@ -167,7 +167,7 @@ public class TestValueMemory extends TestBase implements DataHandler { ...@@ -167,7 +167,7 @@ public class TestValueMemory extends TestBase implements DataHandler {
case Value.TIMESTAMP_UTC: case Value.TIMESTAMP_UTC:
return ValueTimestampUtc.fromMillis(random.nextLong()); return ValueTimestampUtc.fromMillis(random.nextLong());
case Value.TIMESTAMP_TZ: case Value.TIMESTAMP_TZ:
return ValueTimestampTimeZone.fromMillis(random.nextLong(), (short)0); return ValueTimestampTimeZone.fromMillis(random.nextLong(), (short) 0);
case Value.BYTES: case Value.BYTES:
return ValueBytes.get(randomBytes(random.nextInt(1000))); return ValueBytes.get(randomBytes(random.nextInt(1000)));
case Value.STRING: case Value.STRING:
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* You can obtain a copy of the license at * You can obtain a copy of the license at
* glassfish/bootstrap/legal/CDDLv1.0.txt or * glassfish/bootstrap/legal/CDDLv1.0.txt or
* https://glassfish.dev.java.net/public/CDDLv1.0.html. * https://glassfish.dev.java.net/public/CDDLv1.0.html .
* See the License for the specific language governing * See the License for the specific language governing
* permissions and limitations under the License. * permissions and limitations under the License.
* *
......
...@@ -238,7 +238,8 @@ public class Build extends BuildBase { ...@@ -238,7 +238,8 @@ public class Build extends BuildBase {
if (!clientOnly) { if (!clientOnly) {
files = files("src/test"); files = files("src/test");
files.addAll(files("src/tools")); files.addAll(files("src/tools"));
files = files.exclude("src/test/org/h2/test/TestAllJunit.java"); //we don't use Junit for this test framework //we don't use Junit for this test framework
files = files.exclude("src/test/org/h2/test/TestAllJunit.java");
args = args("-Xlint:unchecked", "-Xlint:deprecation", args = args("-Xlint:unchecked", "-Xlint:deprecation",
"-d", "temp", "-sourcepath", "src/test" + File.pathSeparator + "src/tools", "-d", "temp", "-sourcepath", "src/test" + File.pathSeparator + "src/tools",
"-classpath", classpath); "-classpath", classpath);
......
...@@ -99,8 +99,9 @@ public class CheckJavadoc { ...@@ -99,8 +99,9 @@ public class CheckJavadoc {
} }
if (inComment) { if (inComment) {
if (rawLine.length() > MAX_COMMENT_LINE_SIZE if (rawLine.length() > MAX_COMMENT_LINE_SIZE
&& !line.trim().startsWith("* http://")) { && !line.trim().startsWith("* http://")
System.out.println("Long line : " + file.getAbsolutePath() && !line.trim().startsWith("* https://")) {
System.out.println("Long line: " + file.getAbsolutePath()
+ " (" + file.getName() + ":" + lineNumber + ")"); + " (" + file.getName() + ":" + lineNumber + ")");
errorCount++; errorCount++;
} }
...@@ -108,12 +109,14 @@ public class CheckJavadoc { ...@@ -108,12 +109,14 @@ public class CheckJavadoc {
inComment = false; inComment = false;
} }
} }
if (!inComment && line.startsWith("//") if (!inComment && line.startsWith("//")) {
&& rawLine.length() > MAX_COMMENT_LINE_SIZE if (rawLine.length() > MAX_COMMENT_LINE_SIZE
&& !line.trim().startsWith("// http://")) { && !line.trim().startsWith("// http://")
&& !line.trim().startsWith("// https://")) {
System.out.println("Long line: " + file.getAbsolutePath() System.out.println("Long line: " + file.getAbsolutePath()
+ " (" + file.getName() + ":" + lineNumber + ")"); + " (" + file.getName() + ":" + lineNumber + ")");
errorCount++; errorCount++;
}
} else if (!inComment && rawLine.length() > MAX_SOURCE_LINE_SIZE) { } else if (!inComment && rawLine.length() > MAX_SOURCE_LINE_SIZE) {
System.out.println("Long line: " + file.getAbsolutePath() System.out.println("Long line: " + file.getAbsolutePath()
+ " (" + file.getName() + ":" + lineNumber + ")"); + " (" + file.getName() + ":" + lineNumber + ")");
......
...@@ -11,6 +11,8 @@ import java.util.Arrays; ...@@ -11,6 +11,8 @@ import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.h2.build.BuildBase; import org.h2.build.BuildBase;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
...@@ -72,6 +74,11 @@ public class SpellChecker { ...@@ -72,6 +74,11 @@ public class SpellChecker {
private void run(String dictionaryFileName, String dir) throws IOException { private void run(String dictionaryFileName, String dir) throws IOException {
process(new File(dictionaryFileName)); process(new File(dictionaryFileName));
process(new File(dir)); process(new File(dir));
HashSet<String> unused = new HashSet<String>();
unused.addAll(dictionary);
unused.removeAll(used);
// System.out.println("UNUSED WORDS");
// System.out.println(unused);
if (printDictionary) { if (printDictionary) {
System.out.println("USED WORDS"); System.out.println("USED WORDS");
String[] list = new String[used.size()]; String[] list = new String[used.size()];
...@@ -190,19 +197,20 @@ public class SpellChecker { ...@@ -190,19 +197,20 @@ public class SpellChecker {
} }
private String removeLinks(String fileName, String text) { private String removeLinks(String fileName, String text) {
Pattern linkPattern = Pattern.compile("http[s]?://");
StringBuilder buff = new StringBuilder(text.length()); StringBuilder buff = new StringBuilder(text.length());
int pos = 0, last = 0; int pos = 0, last = 0;
if (fileName.endsWith(".properties")) { if (fileName.endsWith(".properties")) {
text = StringUtils.replaceAll(text, "\\:", ":"); text = StringUtils.replaceAll(text, "\\:", ":");
} }
while (true) { while (true) {
pos = text.indexOf("http://", pos); Matcher m = linkPattern.matcher(text.substring(pos));
if (pos < 0) { if (!m.find()) {
break; break;
} }
int start = pos; int start = m.start() + pos;
pos = m.end() + pos;
buff.append(text.substring(last, start)); buff.append(text.substring(last, start));
pos += "http://".length();
while (true) { while (true) {
char c = text.charAt(pos); char c = text.charAt(pos);
if (!Character.isJavaIdentifierPart(c) && if (!Character.isJavaIdentifierPart(c) &&
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论