This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple code to create an embedded H2 server and launch associated web console. | |
*/ | |
import java.sql.*; | |
import org.h2.jdbcx.JdbcConnectionPool; | |
import org.h2.tools.Server; | |
private static final String URL = "jdbc:h2:~/test;AUTO_SERVER=TRUE"; | |
private static final String USERNAME = "sa"; | |
private static final String PASSWORD = ""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.io.InvalidObjectException; | |
import java.io.ObjectInputStream; | |
import java.io.ObjectOutputStream; | |
import java.io.Serializable; | |
import java.util.Arrays; | |
import javax.crypto.Cipher; | |
import javax.crypto.Mac; | |
import javax.crypto.spec.IvParameterSpec; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AdvancedTestCase extends TestCase { | |
public void run(TestResult result) { | |
AdvancedTestListener l = AdvancedTestListenerFactory.INSTANCE.newInstance(); | |
result.addListener(l); | |
l.setName(getName()); | |
// normally do this with reflection | |
MyTestedClass orig = ((MyAdvancedTest) this).obj; | |
MyFacadeClass facade = new MyFacadeClass(orig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.invariantproperties.sandbox.securityManager; | |
import java.net.InetSocketAddress; | |
import java.net.SocketPermission; | |
import java.security.Permission; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import javax.security.auth.kerberos.KerberosPrincipal; | |
import javax.security.auth.login.LoginContext; | |
import javax.security.auth.login.LoginException; | |
import org.junit.BeforeClass; | |
import org.junit.ClassRule; | |
import org.junit.Test; | |
import org.junit.rules.TemporaryFolder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Define custom enum type containing supported encoding algorithms | |
-- | |
CREATE TYPE encoding AS ENUM ('BASE64', 'ESCAPE', 'HEX'); | |
-- | |
-- Type-safe alternative to encode(bytea, text) | |
-- | |
CREATE OR REPLACE FUNCTION encode (value bytea, alg encoding) RETURNS text AS $$ | |
#print_strict_params on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION get_gluon(color color) RETURNS TEXT AS $$ | |
#print_strict_params on | |
DECLARE | |
duck TEXT; | |
BEGIN | |
CASE color | |
WHEN 'RED'::color THEN | |
duck := 'Huey'; | |
WHEN 'GREEN'::color THEN | |
duck := 'Dewey'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Create user-defined enum type. | |
-- (List details with '\dT+ color' in psql) | |
-- | |
CREATE TYPE color AS ENUM ('RED', 'GREEN', 'BLUE'); | |
-- | |
-- Create a table using the user-defined enum type. | |
-- | |
CREATE TABLE quark ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE color ( | |
color TEXT CHECK (color IN ('RED', 'GREEN', 'BLUE')) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Function that needs to explicitly check whether the 'color' value is valid | |
-- | |
CREATE OR REPLACE FUNCTION get_gluon(color text) RETURNS TEXT AS $$ | |
#print_strict_params on | |
DECLARE | |
duck TEXT; | |
BEGIN | |
IF color not in ('red', 'green', 'blue') THEN | |
RAISE EXCEPTION 'unknown color %', color; |
OlderNewer