public static void go0(String... expected) throws Exception { System.setProperty("sun.security.krb5.debug", "true"); // Make sure KDCs' ports starts with 1 and 2 and 3, // useful for checking debug output. int p1 = 10000 + new java.util.Random().nextInt(10000); int p2 = 20000 + new java.util.Random().nextInt(10000); int p3 = 30000 + new java.util.Random().nextInt(10000); FileWriter fw = new FileWriter("alternative-krb5.conf"); fw.write( "[libdefaults]\n" + "default_realm = " + OneKDC.REALM + "\n" + "kdc_timeout = " + toReal(2000) + "\n"); fw.write( "[realms]\n" + OneKDC.REALM + " = {\n" + "kdc = " + OneKDC.KDCHOST + ":" + p1 + "\n" + "kdc = " + OneKDC.KDCHOST + ":" + p2 + "\n" + "kdc = " + OneKDC.KDCHOST + ":" + p3 + "\n" + "}\n"); fw.close(); System.setProperty("java.security.krb5.conf", "alternative-krb5.conf"); Config.refresh(); // Turn on k3 only KDC k3 = on(p3); test(expected[0]); test(expected[1]); Config.refresh(); test(expected[2]); k3.terminate(); // shutdown k3 on(p2); // k2 is on test(expected[3]); on(p1); // k1 and k2 is on test(expected[4]); }
/** * Creates a new Socket connected to the given IP address. The method uses connection settings * supplied in the constructor for connecting the socket. * * @param address the IP address to connect to * @return connected socket * @throws java.net.UnknownHostException if the hostname of the address or the proxy cannot be * resolved * @throws java.io.IOException if an I/O error occured while connecting to the remote end or to * the proxy */ private Socket createSocket(InetSocketAddress address, int timeout) throws IOException { String socksProxyHost = System.getProperty("socksProxyHost"); System.getProperties().remove("socksProxyHost"); try { ConnectivitySettings cs = lastKnownSettings.get(address); if (cs != null) { try { return createSocket(cs, address, timeout); } catch (IOException e) { // not good anymore, try all proxies lastKnownSettings.remove(address); } } URI uri = addressToURI(address, "socket"); try { return createSocket(uri, address, timeout); } catch (IOException e) { // we will also try https } uri = addressToURI(address, "https"); return createSocket(uri, address, timeout); } finally { if (socksProxyHost != null) { System.setProperty("socksProxyHost", socksProxyHost); } } }
public static void main(String args[]) throws Exception { // cache the initial set of loggers before this test begins // to add any loggers Enumeration<String> e = logMgr.getLoggerNames(); List<String> defaultLoggers = getDefaultLoggerNames(); while (e.hasMoreElements()) { String logger = e.nextElement(); if (!defaultLoggers.contains(logger)) { initialLoggerNames.add(logger); } } ; String tstSrc = System.getProperty(TST_SRC_PROP); File fname = new File(tstSrc, LM_PROP_FNAME); String prop = fname.getCanonicalPath(); System.setProperty(CFG_FILE_PROP, prop); logMgr.readConfiguration(); System.out.println(); if (checkLoggers() == PASSED) { System.out.println(MSG_PASSED); } else { System.out.println(MSG_FAILED); throw new Exception(MSG_FAILED); } }
/** * Set embedded cassandra up and spawn it in a new thread. * * @throws TTransportException * @throws IOException * @throws InterruptedException */ public void start() throws TTransportException, IOException, InterruptedException, ConfigurationException { File dir = Files.createTempDir(); String dirPath = dir.getAbsolutePath(); System.out.println("Storing Cassandra files in " + dirPath); URL url = Resources.getResource("cassandra.yaml"); String yaml = Resources.toString(url, Charsets.UTF_8); yaml = yaml.replaceAll("REPLACEDIR", dirPath); String yamlPath = dirPath + File.separatorChar + "cassandra.yaml"; org.apache.commons.io.FileUtils.writeStringToFile(new File(yamlPath), yaml); // make a tmp dir and copy cassandra.yaml and log4j.properties to it copy("/log4j.properties", dir.getAbsolutePath()); System.setProperty("cassandra.config", "file:" + dirPath + yamlFilePath); System.setProperty("log4j.configuration", "file:" + dirPath + "/log4j.properties"); System.setProperty("cassandra-foreground", "true"); cleanupAndLeaveDirs(); try { executor.execute(new CassandraRunner()); } catch (RejectedExecutionException e) { log.error("RejectError", e); return; } try { TimeUnit.SECONDS.sleep(WAIT_SECONDS); } catch (InterruptedException e) { log.error("InterrputedError", e); throw new AssertionError(e); } }
public static void testNSS(PKCS11Test test) throws Exception { if (!(new File(NSS_BASE)).exists()) return; String libdir = getNSSLibDir(); if (libdir == null) { return; } if (loadNSPR(libdir) == false) { return; } String libfile = libdir + System.mapLibraryName("softokn3"); String customDBdir = System.getProperty("CUSTOM_DB_DIR"); String dbdir = (customDBdir != null) ? customDBdir : NSS_BASE + SEP + "db"; // NSS always wants forward slashes for the config path dbdir = dbdir.replace('\\', '/'); String customConfig = System.getProperty("CUSTOM_P11_CONFIG"); String customConfigName = System.getProperty("CUSTOM_P11_CONFIG_NAME", "p11-nss.txt"); String p11config = (customConfig != null) ? customConfig : NSS_BASE + SEP + customConfigName; System.setProperty("pkcs11test.nss.lib", libfile); System.setProperty("pkcs11test.nss.db", dbdir); Provider p = getSunPKCS11(p11config); test.premain(p); }
protected static void initSystemProperties(MoquiStart cl, boolean useProperties) throws IOException { Properties moquiInitProperties = new Properties(); URL initProps = cl.getResource("MoquiInit.properties"); if (initProps != null) { InputStream is = initProps.openStream(); moquiInitProperties.load(is); is.close(); } // before doing anything else make sure the moqui.runtime system property exists (needed for // config of various things) String runtimePath = System.getProperty("moqui.runtime"); if (runtimePath != null && runtimePath.length() > 0) System.out.println("Determined runtime from system property: " + runtimePath); if (useProperties && (runtimePath == null || runtimePath.length() == 0)) { runtimePath = moquiInitProperties.getProperty("moqui.runtime"); if (runtimePath != null && runtimePath.length() > 0) System.out.println("Determined runtime from MoquiInit.properties file: " + runtimePath); } if (runtimePath == null || runtimePath.length() == 0) { // see if runtime directory under the current directory exists, if not default to the current // directory File testFile = new File("runtime"); if (testFile.exists()) runtimePath = "runtime"; if (runtimePath != null && runtimePath.length() > 0) System.out.println("Determined runtime from existing runtime directory: " + runtimePath); } if (runtimePath == null || runtimePath.length() == 0) { runtimePath = "."; System.out.println("Determined runtime by defaulting to current directory: " + runtimePath); } File runtimeFile = new File(runtimePath); runtimePath = runtimeFile.getCanonicalPath(); System.out.println("Canonicalized runtimePath: " + runtimePath); if (runtimePath.endsWith("/")) runtimePath = runtimePath.substring(0, runtimePath.length() - 1); System.setProperty("moqui.runtime", runtimePath); /* Don't do this here... loads as lower-level that WEB-INF/lib jars and so can't have dependencies on those, and dependencies on those are necessary // add runtime/lib jar files to the class loader File runtimeLibFile = new File(runtimePath + "/lib"); for (File jarFile: runtimeLibFile.listFiles()) { if (jarFile.getName().endsWith(".jar")) cl.jarFileList.add(new JarFile(jarFile)); } */ // moqui.conf=conf/development/MoquiDevConf.xml String confPath = System.getProperty("moqui.conf"); if (confPath == null || confPath.length() == 0) { confPath = moquiInitProperties.getProperty("moqui.conf"); } if (confPath == null || confPath.length() == 0) { File testFile = new File(runtimePath + "/" + defaultConf); if (testFile.exists()) confPath = defaultConf; } if (confPath != null) System.setProperty("moqui.conf", confPath); }
/** Read scopes from file. */ @Before public void readScopesFromFile() { try { scopeConfigs = readScopesConfig(); readScopes(); System.setProperty("javax.net.ssl.trustStore", jksFilePath); System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon"); } catch (JAXBException e) { log.error("Error reading scopes"); } }
public void setUp() throws Exception { super.setUp(); theDaemon = getMockLockssDaemon(); tempDir = getTempDir(); String tempDirPath = tempDir.getAbsolutePath(); System.setProperty("java.io.tmpdir", tempDirPath); Properties p = new Properties(); p.setProperty(IdentityManager.PARAM_IDDB_DIR, tempDirPath + "iddb"); p.setProperty(ConfigManager.PARAM_PLATFORM_DISK_SPACE_LIST, tempDirPath); p.setProperty(IdentityManager.PARAM_LOCAL_IP, "127.0.0.1"); p.setProperty(V3LcapMessage.PARAM_REPAIR_DATA_THRESHOLD, "4096"); ConfigurationUtil.setCurrentConfigFromProps(p); IdentityManager idmgr = theDaemon.getIdentityManager(); idmgr.startService(); mPollMgr = new MockPollManager(); theDaemon.setPollManager(mPollMgr); try { m_testID = idmgr.stringToPeerIdentity("127.0.0.1"); } catch (IOException ex) { fail("can't open test host 127.0.0.1: " + ex); } m_repairProps = new CIProperties(); m_repairProps.setProperty("key1", "val1"); m_repairProps.setProperty("key2", "val2"); m_repairProps.setProperty("key3", "val3"); m_testVoteBlocks = V3TestUtils.makeVoteBlockList(10); m_testMsg = this.makeTestVoteMessage(m_testVoteBlocks); }
public ArrayList parseData(String propName) { ArrayList<String> files = new ArrayList(); String saltData = ""; try { if (System.getProperty(propName) != null) { saltData = System.getProperty(propName); } StringTokenizer fileTokens = new StringTokenizer(saltData, ","); while (fileTokens.hasMoreElements()) { String file = fileTokens.nextToken(); if (file != null && !file.equals("null") && !file.equals("")) { System.out.println("Built tab from list" + file); files.add(file); } } saltData = ""; } catch (Exception e) { System.out.println("Failed to open files "); } // just incase it was a signle node if (saltData != null && !saltData.equals("null") && !saltData.equals("")) { System.out.println("Built tab from single " + saltData); files.add(saltData); } System.setProperty(propName, ""); return files; }
void doit() { String username = args.Username; String password = args.Password; if (username != null || password != null) Authenticator.setDefault(new MyAuthenticator(username, password)); System.setProperty("java.protocol.handler.pkgs", "edu.mscd.cs"); String[] add = args.additional; if (add == null) { logger.warning("No URLs specified, exiting"); System.exit(1); } /* ** add the specified URLs to the list to be fetched. */ String[] t = new String[add.length]; for (int i = 0; i < add.length; i++) { t[i] = "<a href=\"" + add[i] + "\">"; } /* ** add to the URLs, with no base */ addToURLs(null, t); fetchAll(); /* ** shall we save the cookies to a file? */ String savecookies = args.SaveCookies; if (savecookies != null) cookies.saveCookies(savecookies); }
public void openProfiles_old() { String saltData = ""; try { if (System.getProperty("saltData") != null) { saltData = System.getProperty("saltData"); } StringTokenizer fileTokens = new StringTokenizer(saltData, ","); while (fileTokens.hasMoreElements()) { String file = fileTokens.nextToken(); if (file != null && !file.equals("null") && !file.equals("")) { System.out.println("Built tab from list" + file); buildProfileTab(file); } } saltData = ""; } catch (Exception e) { System.out.println("Failed to open files "); } // just incase it was a signle node if (saltData != null && !saltData.equals("null") && !saltData.equals("")) { System.out.println("Built tab from single " + saltData); buildProfileTab(saltData); } System.setProperty("saltData", ""); }
/** * @param args * @throws IOException */ public static void main(String args[]) throws IOException { // Enable Debugging System.setProperty("DEBUG", "1"); // Instantiate the Test Controller new TestDeviceManagerProtocol(); // ******************************************** // Prompt to enter a command // ******************************************** System.out.println("Type exit to quit"); System.out.print("SYSTEM>"); BufferedReader keyboardInput; keyboardInput = new BufferedReader(new InputStreamReader(System.in)); String command = ""; try { while (!command.equalsIgnoreCase("exit")) { command = keyboardInput.readLine(); if (!command.equalsIgnoreCase("exit")) { System.out.print("\nSYSTEM>"); } } } finally { System.out.println("\nDisconnecting from ProtocolFactory"); try { ProtocolFactory.shutdown(); } catch (Exception e) { } ; } }
private static void setSystemProperty(String name, String value) { String val = System.getProperty(name); if (val == null || val.equals("")) { System.setProperty(name, value); } }
public static void importConfigsTo(@NotNull String newConfigPath) { ConfigImportSettings settings = getConfigImportSettings(); File newConfigDir = new File(newConfigPath); File oldConfigDir = findOldConfigDir(newConfigDir, settings.getCustomPathsSelector()); do { ImportOldConfigsPanel dialog = new ImportOldConfigsPanel(oldConfigDir, settings); dialog.setModalityType(Dialog.ModalityType.TOOLKIT_MODAL); AppUIUtil.updateWindowIcon(dialog); dialog.setVisible(true); if (dialog.isImportEnabled()) { File installationHome = dialog.getSelectedFile(); oldConfigDir = getOldConfigDir(installationHome, settings); if (!validateOldConfigDir(installationHome, oldConfigDir, settings)) { continue; } assert oldConfigDir != null; doImport(newConfigDir, oldConfigDir, settings, installationHome); settings.importFinished(newConfigPath); System.setProperty(CONFIG_IMPORTED_IN_CURRENT_SESSION_KEY, Boolean.TRUE.toString()); } break; } while (true); }
public static void initApplicationDirs() throws IOException { createTrustStoreFileIfNotExists(); File appDataRoot = new File(applicationDataDir()); if (!appDataRoot.exists()) { appDataRoot.mkdirs(); } if (!appDataRoot.canWrite()) { SEAGridDialogHelper.showExceptionDialogAndWait( new Exception("Cannot Write to Application Data Dir"), "Cannot Write to Application Data Dir", null, "Cannot Write to Application Data Dir " + applicationDataDir()); } // Legacy editors use stdout and stderr instead of loggers. This is a workaround to append them // to a file System.setProperty("app.data.dir", applicationDataDir() + "logs"); logger = LoggerFactory.getLogger(SEAGridDesktop.class); File logParent = new File(applicationDataDir() + "logs"); if (!logParent.exists()) logParent.mkdirs(); PrintStream outPs = new PrintStream(applicationDataDir() + "logs/seagrid.std.out"); PrintStream errPs = new PrintStream(applicationDataDir() + "logs/seagrid.std.err"); System.setOut(outPs); System.setErr(errPs); Runtime.getRuntime() .addShutdownHook( new Thread() { public void run() { outPs.close(); errPs.close(); } }); extractLegacyEditorResources(); }
public static String getNSSLibDir() throws Exception { Properties props = System.getProperties(); String osName = props.getProperty("os.name"); if (osName.startsWith("Win")) { osName = "Windows"; NSPR_PREFIX = "lib"; } String osid = osName + "-" + props.getProperty("os.arch") + "-" + props.getProperty("sun.arch.data.model"); String ostype = osMap.get(osid); if (ostype == null) { System.out.println("Unsupported OS, skipping: " + osid); return null; // throw new Exception("Unsupported OS " + osid); } if (ostype.length() == 0) { System.out.println("NSS not supported on this platform, skipping test"); return null; } String libdir = NSS_BASE + SEP + "lib" + SEP + ostype + SEP; System.setProperty("pkcs11test.nss.libdir", libdir); return libdir; }
@Before public void setup() throws IOException { // Avoiding "restx.shell.home_IS_UNDEFINED/ dir due to logs this.initialRestxShellHomeValue = System.getProperty("restx.shell.home"); if (this.initialRestxShellHomeValue == null) { System.setProperty("restx.shell.home", workDirectory.newFolder(".restx").getAbsolutePath()); } }
///////////////////////////////////////////////////// // RUNNING THE PARSER //////////////////////////////////////////////////// public static void main(String[] args) throws FileNotFoundException, Exception { System.setProperty("java.io.tmpdir", "./tmp/"); ParserOptions options = new ParserOptions(args); System.out.println("Default temp directory:" + System.getProperty("java.io.tmpdir")); System.out.println("Separate labeling: " + options.separateLab); if (options.train) { DependencyPipe pipe = options.secondOrder ? new DependencyPipe2O(options) : new DependencyPipe(options); int[] instanceLengths = pipe.createInstances(options.trainfile, options.trainforest); pipe.closeAlphabets(); DependencyParser dp = new DependencyParser(pipe, options); // pipe.printModelStats(null); int numFeats = pipe.dataAlphabet.size(); int numTypes = pipe.typeAlphabet.size(); System.out.print("Num Feats: " + numFeats); System.out.println(".\tNum Edge Labels: " + numTypes); if (options .stackedLevel0) // Augment training data with output predictions, for stacked learning // (afm 03-03-08) { // Output data augmented with output predictions System.out.println("Augmenting training data with output predictions..."); options.testfile = options.trainfile; dp.augment( instanceLengths, options.trainfile, options.trainforest, options.augmentNumParts); // Now train the base classifier in the whole corpus, nothing being ignored System.out.println("Training the base classifier in the whole corpus..."); } // afm 03-06-08 --- To allow some instances to be ignored int ignore[] = new int[instanceLengths.length]; for (int i = 0; i < instanceLengths.length; i++) ignore[i] = 0; dp.params = new Parameters(pipe.dataAlphabet.size()); dp.train(instanceLengths, ignore, options.trainfile, options.trainforest); System.out.print("Saving model..."); dp.saveModel(options.modelName); System.out.print("done."); } if (options.test) { DependencyPipe pipe = options.secondOrder ? new DependencyPipe2O(options) : new DependencyPipe(options); DependencyParser dp = new DependencyParser(pipe, options); System.out.print("\tLoading model..."); dp.loadModel(options.modelName); System.out.println("done."); pipe.printModelStats(dp.params); pipe.closeAlphabets(); dp.outputParses(null); } System.out.println(); if (options.eval) { System.out.println("\nEVALUATION PERFORMANCE:"); DependencyEvaluator.evaluate(options.goldfile, options.outfile, options.format); } }
public static void main(String[] args) throws Exception { String keyFilename = System.getProperty("test.src", "./") + "/" + pathToStores + "/" + keyStoreFile; String trustFilename = System.getProperty("test.src", "./") + "/" + pathToStores + "/" + trustStoreFile; System.setProperty("javax.net.ssl.keyStore", keyFilename); System.setProperty("javax.net.ssl.keyStorePassword", passwd); System.setProperty("javax.net.ssl.trustStore", trustFilename); System.setProperty("javax.net.ssl.trustStorePassword", passwd); if (debug) System.setProperty("javax.net.debug", "all"); /* * Start the tests. */ new JavaxHTTPSConnection(); }
public static void main(String[] args) throws Exception { if (debug) System.setProperty("javax.net.debug", "all"); /* * Start the tests. */ new CheckMyTrustedKeystore(); }
public ParseEssay() { System.setProperty("wordnet.database.dir", "../war/dict"); synonyms = new ArrayList<String>(); database = WordNetDatabase.getFileInstance(); baos = new ByteArrayOutputStream(); lp = LexicalizedParser.loadModel("edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz"); // ?? }
public static void testGetProperty() { Properties props = new Properties(); props.setProperty("name", "Bela"); props.setProperty("key", "val"); System.setProperty("name", "Michelle"); System.setProperty("name2", "Nicole"); String retval; retval = Util.getProperty(new String[] {"name", "name2"}, props, "name", "Jeannette"); Assert.assertEquals("Bela", retval); props.setProperty("name", "Bela"); props.setProperty("key", "val"); retval = Util.getProperty(new String[] {"name2", "name"}, props, "name", "Jeannette"); Assert.assertEquals("Bela", retval); props.setProperty("name", "Bela"); props.setProperty("key", "val"); retval = Util.getProperty(new String[] {"name3", "name"}, props, "name", "Jeannette"); Assert.assertEquals("Bela", retval); props.setProperty("name", "Bela"); props.setProperty("key", "val"); retval = Util.getProperty(new String[] {"name3", "name4"}, props, "name", "Jeannette"); Assert.assertEquals("Bela", retval); props.setProperty("name", "Bela"); props.setProperty("key", "val"); retval = Util.getProperty(new String[] {"name2", "name"}, props, "name", "Jeannette"); Assert.assertEquals("Bela", retval); props.setProperty("name", "Bela"); props.setProperty("key", "val"); retval = Util.getProperty(new String[] {"name2", "name"}, props, "name2", "Jeannette"); Assert.assertEquals("Nicole", retval); props.setProperty("name", "Bela"); props.setProperty("key", "val"); retval = Util.getProperty(new String[] {"name2", "name"}, props, "name2", null); Assert.assertEquals("Nicole", retval); props.setProperty("name", "Bela"); props.setProperty("key", "val"); }
private void createConnection() throws IOException { String completeUrl = getCompleteUrl(); if (connection == null) { System.setProperty("http.keepAlive", connectionKeepAlive ? "true" : "false"); connection = (HttpURLConnection) new URL(completeUrl).openConnection(); connection.setInstanceFollowRedirects(followRedirects); } }
public static void load(File folder) throws Exception { if (!loaded) { if (!folder.exists()) folder.mkdirs(); if (folder.isDirectory()) { installNatives(folder); System.setProperty("org.lwjgl.librarypath", folder.getAbsolutePath()); } loaded = true; } }
@Override public void configureAgent() throws InstallException { // Setup XUpdate : System.setProperty( "org.xmldb.common.xml.queries.XPathQueryFactory", "org.xmldb.common.xml.queries.xalan2.XPathQueryFactoryImpl"); // For now, only web.xml to configure: configureWebXml(); configureJaasModule(); }
/** * Sets properties (codebase URLs) for policy files. JAR locations are not fixed so we have to * find the locations of the ones we want. */ @SuppressForbidden(reason = "proper use of URL") static void setCodebaseProperties() { for (URL url : JarHell.parseClassPath()) { for (Map.Entry<Pattern, String> e : SPECIAL_JARS.entrySet()) { if (e.getKey().matcher(url.getPath()).matches()) { String prop = e.getValue(); if (System.getProperty(prop) != null) { throw new IllegalStateException( "property: " + prop + " is unexpectedly set: " + System.getProperty(prop)); } System.setProperty(prop, url.toString()); } } } for (String prop : SPECIAL_JARS.values()) { if (System.getProperty(prop) == null) { System.setProperty(prop, "file:/dev/null"); // no chance to be interpreted as "all" } } }
@Override protected void setUp() throws Exception { super.setUp(); System.setProperty("netbeans.localhistory.storeChangesAsynchronously", "true"); cleanUpDataFolder(); LocalHistoryTestStore store = createStore(); store.cleanUp(1); store.getReleasedLocks().clear(); dataDir = new File(getDataDir(), getName()); FileUtils.deleteRecursively(dataDir); }
private void configureMavenProxy() { if (settings != null) { Proxy activeProxy = settings.getActiveProxy(); if (activeProxy != null) { String host = activeProxy.getHost(); int port = activeProxy.getPort(); String username = activeProxy.getUsername(); String password = activeProxy.getPassword(); System.setProperty("http.proxyHost", host); System.setProperty("http.proxyPort", String.valueOf(port)); if (username != null) { System.setProperty("http.proxyUser", username); } if (password != null) { System.setProperty("http.proxyPassword", password); } } } }
/** * Establishes an HttpURLConnection from a URL, with the correct configuration to receive content from the given URL. * * @param url The URL to set up and receive content from * @return A valid HttpURLConnection * * @throws IOException The openConnection() method throws an IOException and the calling method is responsible for handling it. */ public static HttpURLConnection openHttpConnection(URL url) throws IOException { HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoInput(true); conn.setDoOutput(false); System.setProperty("http.agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.162 Safari/535.19"); conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.162 Safari/535.19"); HttpURLConnection.setFollowRedirects(true); conn.setUseCaches(false); conn.setInstanceFollowRedirects(true); return conn; }
public static void main(String[] args) throws Exception { System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); /** * This test does not establish any connection to the specified URL, hence a dummy URL is used. */ URL foobar = new URL("https://example.com/"); HttpsURLConnection urlc = (HttpsURLConnection) foobar.openConnection(); try { urlc.getCipherSuite(); } catch (IllegalStateException e) { System.out.print("Caught proper exception: "); System.out.println(e.getMessage()); } try { urlc.getServerCertificateChain(); } catch (IllegalStateException e) { System.out.print("Caught proper exception: "); System.out.println(e.getMessage()); } try { urlc.setDefaultHostnameVerifier(null); } catch (IllegalArgumentException e) { System.out.print("Caught proper exception: "); System.out.println(e.getMessage()); } try { urlc.setHostnameVerifier(null); } catch (IllegalArgumentException e) { System.out.print("Caught proper exception: "); System.out.println(e.getMessage()); } try { urlc.setDefaultSSLSocketFactory(null); } catch (IllegalArgumentException e) { System.out.print("Caught proper exception: "); System.out.println(e.getMessage()); } try { urlc.setSSLSocketFactory(null); } catch (IllegalArgumentException e) { System.out.print("Caught proper exception"); System.out.println(e.getMessage()); } System.out.println("TESTS PASSED"); }