提交 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."
ALTER TABLE tableName ADD constraint [ CHECK | NOCHECK ]
","
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","
ALTER TABLE tableName ALTER COLUMN columnName
{ { dataType [ DEFAULT expression ] [ [ NOT ] NULL ] [ AUTO_INCREMENT | IDENTITY ] }
......
......@@ -12,7 +12,10 @@ import org.junit.Test;
* used by H2.
*/
public class TestAllJunit {
/**
* Run all the fast tests.
*/
@Test
public void testFast() throws Exception {
TestAll.main("fast");
......
......@@ -37,7 +37,8 @@ public class TestConnection extends TestBase {
}
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");
assertThrows(SQLClientInfoException.class, conn).setClientInfo("numServers", "SomeValue");
......@@ -48,7 +49,7 @@ public class TestConnection extends TestBase {
Connection conn = getConnection("clientInfo");
Properties properties = new Properties();
properties.put("ClientUser", "someuser");
properties.put("ClientUser", "someUser");
assertThrows(SQLClientInfoException.class, conn).setClientInfo(properties);
}
......@@ -58,12 +59,12 @@ public class TestConnection extends TestBase {
conn.setClientInfo("ApplicationName", "Connection Test");
Properties properties = new Properties();
properties.put("ClientUser", "someuser");
properties.put("ClientUser", "someUser");
conn.setClientInfo(properties);
// old property should have been removed
assertNull(conn.getClientInfo("ApplicationName"));
// new property has been set
assertEquals(conn.getClientInfo("ClientUser"), "someuser");
assertEquals(conn.getClientInfo("ClientUser"), "someUser");
}
private void testSetSupportedClientInfo() throws SQLException {
......@@ -75,7 +76,8 @@ public class TestConnection extends TestBase {
private void testSetUnsupportedClientInfo() throws SQLException {
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 {
......
......@@ -132,7 +132,7 @@ public class CalculateHashConstantLong implements Runnable {
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;
System.out.println("Quality of " + test);
int[] minMax;
......
......@@ -10182,13 +10182,13 @@ insert into test values(5, 'b'), (5, 'b'), (20, 'a');
> update count: 3
select 0 from ((
select 0 as f from dual u1 where null in (?, ?, ?, ?, ?)
select 0 as f from dual u1 where null in (?, ?, ?, ?, ?)
) union all (
select u2.f from (
select 0 as f from (
select 0 from dual u2f1f1 where now() = ?
) u2f1
) u2
select u2.f from (
select 0 as f from (
select 0 from dual u2f1f1 where now() = ?
) u2f1
) u2
)) where f = 12345;
{
11, 22, 33, 44, 55, null
......
......@@ -36,12 +36,17 @@ public class TestMode extends TestBase {
private void testDb2ClientInfo() {
Mode db2Mode = Mode.getInstance("DB2");
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher("ApplicationName").matches());
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher("ClientAccountingInformation").matches());
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher("ClientUser").matches());
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher("ClientCorrelationToken").matches());
assertFalse(db2Mode.supportedClientInfoPropertiesRegEx.matcher("AnyOtherValue").matches());
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher(
"ApplicationName").matches());
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher(
"ClientAccountingInformation").matches());
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher(
"ClientUser").matches());
assertTrue(db2Mode.supportedClientInfoPropertiesRegEx.matcher(
"ClientCorrelationToken").matches());
assertFalse(db2Mode.supportedClientInfoPropertiesRegEx.matcher(
"AnyOtherValue").matches());
}
private void testDerbyClientInfo() {
......@@ -61,22 +66,25 @@ public class TestMode extends TestBase {
private void testMySqlClientInfo() {
Mode mySqlMode = Mode.getInstance("MySQL");
assertTrue(mySqlMode.supportedClientInfoPropertiesRegEx.matcher("AnyString").matches());
assertTrue(mySqlMode.supportedClientInfoPropertiesRegEx.matcher(
"AnyString").matches());
}
private void testOracleClientInfo() {
Mode oracleMode = Mode.getInstance("Oracle");
assertTrue(oracleMode.supportedClientInfoPropertiesRegEx.matcher("anythingContaining.aDot").matches());
assertFalse(oracleMode.supportedClientInfoPropertiesRegEx.matcher("anythingContainingNoDot").matches());
assertTrue(oracleMode.supportedClientInfoPropertiesRegEx.matcher(
"anythingContaining.aDot").matches());
assertFalse(oracleMode.supportedClientInfoPropertiesRegEx.matcher(
"anythingContainingNoDot").matches());
}
private void testPostgresqlClientInfo() {
Mode postgresqlMode = Mode.getInstance("PostgreSQL");
assertTrue(postgresqlMode.supportedClientInfoPropertiesRegEx.matcher("ApplicationName").matches());
assertFalse(postgresqlMode.supportedClientInfoPropertiesRegEx.matcher("AnyOtherValue").matches());
assertTrue(postgresqlMode.supportedClientInfoPropertiesRegEx.matcher(
"ApplicationName").matches());
assertFalse(postgresqlMode.supportedClientInfoPropertiesRegEx.matcher(
"AnyOtherValue").matches());
}
}
......@@ -140,7 +140,7 @@ public class TestNetUtils extends TestBase {
private Task createServerSocketTask(final ServerSocket serverSocket) {
Task task = new Task() {
@Override
public void call() throws Exception {
Socket ss = null;
......@@ -148,14 +148,19 @@ public class TestNetUtils extends TestBase {
ss = serverSocket.accept();
ss.getOutputStream().write(123);
} finally {
closeSilently(ss);
closeSilently(ss);
}
}
};
return task;
}
private void closeSilently(Socket socket) {
/**
* Close a socket, ignoring errors
*
* @param socket the socket
*/
void closeSilently(Socket socket) {
try {
socket.close();
} catch (Exception e) {
......@@ -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 {
socket.close();
} catch (Exception e) {
......
......@@ -36,7 +36,7 @@ public class TestSecurity extends TestBase {
testSHA();
testAES();
testBlockCiphers();
testRemoveAnonFromLegacyAlgos();
testRemoveAnonFromLegacyAlgorithms();
//testResetLegacyAlgos();
}
......@@ -254,7 +254,7 @@ public class TestSecurity extends TestBase {
return len * r < len * 120;
}
private void testRemoveAnonFromLegacyAlgos() {
private void testRemoveAnonFromLegacyAlgorithms() {
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" +
", DH_anon, ECDH_anon, RC4_128, RC4_40, DES_CBC, DES40_CBC";
......@@ -282,13 +282,13 @@ public class TestSecurity extends TestBase {
*/
@SuppressWarnings("unused")
private void testResetLegacyAlgos() {
String legacyAlgorithmsBefore = CipherFactory.getLegacyAlgoritmsSilently();
String legacyAlgorithmsBefore = CipherFactory.getLegacyAlgorithmsSilently();
assertEquals("Failed assumption: jdk.tls.legacyAlgorithms" +
" has been modified from its initial setting",
CipherFactory.DEFAULT_LEGACY_ALGORITHMS, legacyAlgorithmsBefore);
CipherFactory.removeAnonFromLegacyAlgorithms();
CipherFactory.resetDefaultLegacyAlgorithms();
String legacyAlgorithmsAfter = CipherFactory.getLegacyAlgoritmsSilently();
String legacyAlgorithmsAfter = CipherFactory.getLegacyAlgorithmsSilently();
assertEquals(CipherFactory.DEFAULT_LEGACY_ALGORITHMS, legacyAlgorithmsAfter);
}
......
......@@ -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')");
ResultSet rs = stat.executeQuery("select t1 from test");
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();
}
......
......@@ -167,7 +167,7 @@ public class TestValueMemory extends TestBase implements DataHandler {
case Value.TIMESTAMP_UTC:
return ValueTimestampUtc.fromMillis(random.nextLong());
case Value.TIMESTAMP_TZ:
return ValueTimestampTimeZone.fromMillis(random.nextLong(), (short)0);
return ValueTimestampTimeZone.fromMillis(random.nextLong(), (short) 0);
case Value.BYTES:
return ValueBytes.get(randomBytes(random.nextInt(1000)));
case Value.STRING:
......
......@@ -6,7 +6,7 @@
*
* You can obtain a copy of the license at
* 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
* permissions and limitations under the License.
*
......
......@@ -238,7 +238,8 @@ public class Build extends BuildBase {
if (!clientOnly) {
files = files("src/test");
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",
"-d", "temp", "-sourcepath", "src/test" + File.pathSeparator + "src/tools",
"-classpath", classpath);
......
......@@ -99,8 +99,9 @@ public class CheckJavadoc {
}
if (inComment) {
if (rawLine.length() > MAX_COMMENT_LINE_SIZE
&& !line.trim().startsWith("* http://")) {
System.out.println("Long line : " + file.getAbsolutePath()
&& !line.trim().startsWith("* http://")
&& !line.trim().startsWith("* https://")) {
System.out.println("Long line: " + file.getAbsolutePath()
+ " (" + file.getName() + ":" + lineNumber + ")");
errorCount++;
}
......@@ -108,12 +109,14 @@ public class CheckJavadoc {
inComment = false;
}
}
if (!inComment && line.startsWith("//")
&& rawLine.length() > MAX_COMMENT_LINE_SIZE
&& !line.trim().startsWith("// http://")) {
System.out.println("Long line: " + file.getAbsolutePath()
+ " (" + file.getName() + ":" + lineNumber + ")");
errorCount++;
if (!inComment && line.startsWith("//")) {
if (rawLine.length() > MAX_COMMENT_LINE_SIZE
&& !line.trim().startsWith("// http://")
&& !line.trim().startsWith("// https://")) {
System.out.println("Long line: " + file.getAbsolutePath()
+ " (" + file.getName() + ":" + lineNumber + ")");
errorCount++;
}
} else if (!inComment && rawLine.length() > MAX_SOURCE_LINE_SIZE) {
System.out.println("Long line: " + file.getAbsolutePath()
+ " (" + file.getName() + ":" + lineNumber + ")");
......
......@@ -11,6 +11,8 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.h2.build.BuildBase;
import org.h2.util.StringUtils;
......@@ -72,6 +74,11 @@ public class SpellChecker {
private void run(String dictionaryFileName, String dir) throws IOException {
process(new File(dictionaryFileName));
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) {
System.out.println("USED WORDS");
String[] list = new String[used.size()];
......@@ -190,19 +197,20 @@ public class SpellChecker {
}
private String removeLinks(String fileName, String text) {
Pattern linkPattern = Pattern.compile("http[s]?://");
StringBuilder buff = new StringBuilder(text.length());
int pos = 0, last = 0;
if (fileName.endsWith(".properties")) {
text = StringUtils.replaceAll(text, "\\:", ":");
}
while (true) {
pos = text.indexOf("http://", pos);
if (pos < 0) {
Matcher m = linkPattern.matcher(text.substring(pos));
if (!m.find()) {
break;
}
int start = pos;
int start = m.start() + pos;
pos = m.end() + pos;
buff.append(text.substring(last, start));
pos += "http://".length();
while (true) {
char c = text.charAt(pos);
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论