Here are the examples of the java api class java.util.Hashtable taken from open source projects.
1. EnumerateAndModify#test()
Project: pluotsorbet
File: EnumerateAndModify.java
File: EnumerateAndModify.java
/** * test is the main test routine testing enumaration of keys and * elements of a concurrently modified hashtable. * * @param harness the current test harness. */ public void test(TestHarness harness) { Hashtable allKeys = new Hashtable(); allKeys.put("C", "c"); allKeys.put("D", "d"); allKeys.put("A", "a"); allKeys.put("B", "b"); allKeys.put("E", "e"); allKeys.put("C1", "c"); allKeys.put("D1", "d"); allKeys.put("A1", "a"); allKeys.put("B1", "b"); allKeys.put("E1", "e"); Hashtable allElements = new Hashtable(); allElements.put("c", "c"); allElements.put("d", "d"); allElements.put("a", "a"); allElements.put("b", "b"); allElements.put("e", "e"); allElements.put("c1", "c1"); allElements.put("d1", "d1"); allElements.put("a1", "a1"); allElements.put("b1", "b1"); allElements.put("e1", "e1"); Hashtable ht = new Hashtable(); ht.put("A", "a"); ht.put("B", "b"); ht.put("C", "c"); ht.put("D", "d"); ht.put("E", "e"); Throwable thrown; boolean returnedOnlyKeysThatWerePut = true; try { // should not get null or any key that was never added. for (Enumeration e = ht.keys(); e.hasMoreElements(); ) { String str = (String) e.nextElement(); if (str != null && !allKeys.containsKey(str)) { returnedOnlyKeysThatWerePut = false; } ht.put("C", "c"); ht.put("D", "d"); ht.put("A", "a"); ht.put("B", "b"); ht.put("E", "e"); ht.put("C1", "c"); ht.put("D1", "d"); ht.put("A1", "a"); ht.put("B1", "b"); ht.put("E1", "e"); } thrown = null; } catch (Throwable t) { t.printStackTrace(); thrown = t; } harness.check(thrown == null); harness.check(returnedOnlyKeysThatWerePut); ht = new Hashtable(); ht.put("A", "a"); ht.put("B", "b"); ht.put("C", "c"); ht.put("D", "d"); ht.put("E", "e"); boolean returnedOnlyElementsThatWerePut = true; try { // should not get null or any key that was never added. for (Enumeration e = ht.elements(); e.hasMoreElements(); ) { String str = (String) e.nextElement(); if (str != null && !allElements.containsKey(str)) { returnedOnlyElementsThatWerePut = false; } ht.put("C", "c"); ht.put("D", "d"); ht.put("A", "a"); ht.put("B", "b"); ht.put("E", "e"); ht.put("C1", "c1"); ht.put("D1", "d1"); ht.put("A1", "a1"); ht.put("B1", "b1"); ht.put("E1", "e1"); } thrown = null; } catch (Throwable t) { thrown = t; } harness.check(thrown == null); harness.check(returnedOnlyElementsThatWerePut); }
2. TestOptions#getDefaultOptions()
Project: che
File: TestOptions.java
File: TestOptions.java
public static Hashtable getDefaultOptions() { Hashtable result = org.eclipse.jdt.core.JavaCore.getDefaultOptions(); result.put(JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING, JavaCore.IGNORE); result.put(JavaCore.COMPILER_PB_FIELD_HIDING, JavaCore.IGNORE); result.put(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER, JavaCore.IGNORE); result.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.IGNORE); result.put(JavaCore.COMPILER_PB_RAW_TYPE_REFERENCE, JavaCore.IGNORE); result.put(JavaCore.COMPILER_PB_UNUSED_WARNING_TOKEN, JavaCore.IGNORE); result.put(JavaCore.COMPILER_PB_DEAD_CODE, JavaCore.IGNORE); // should cover all compiler settings result.putAll(TestFormatterOptions.getSettings()); return result; }
3. TestProvider#getSearch()
Project: velocity-engine
File: TestProvider.java
File: TestProvider.java
public Hashtable getSearch() { Hashtable h = new Hashtable(); h.put("Text", "this is some text"); h.put("EscText", "this is escaped text"); h.put("Title", "this is the title"); h.put("Index", "this is the index"); h.put("URL", "http://periapt.com"); ArrayList al = new ArrayList(); al.add(h); h.put("RelatedLinks", al); return h; }
4. UnitTestHandler#login()
Project: spacewalk
File: UnitTestHandler.java
File: UnitTestHandler.java
/** * Test returning a hashtable * * @return login hash * @exception Exception if an error occurs */ public Hashtable login() throws Exception { Hashtable retHash = new Hashtable(); retHash.put("X-RHN-Server-Id", "foo"); retHash.put("X-RHN-Auth-User-Id", "foo"); retHash.put("X-RHN-Auth", "foo"); retHash.put("X-RHN-Auth-Server-Time", "foo"); retHash.put("X-RHN-Auth-Expire-Offset", "foo"); retHash.put("X-RHN-Auth-Channels", "foo"); return retHash; }
5. LocalCorrectionsQuickFixTest#setUp()
Project: che
File: LocalCorrectionsQuickFixTest.java
File: LocalCorrectionsQuickFixTest.java
// // public static Test suite() { // return setUpTest(new TestSuite(THIS)); // } // // public static Test setUpTest(Test test) { // return new ProjectTestSetup(test); // } @Override @Before public void setUp() throws Exception { super.setUp(); Hashtable options = TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, String.valueOf(99)); options.put(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER, JavaCore.ERROR); options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.IGNORE); options.put(JavaCore.COMPILER_PB_MISSING_HASHCODE_METHOD, JavaCore.WARNING); JavaCore.setOptions(options); IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); StubUtility.setCodeTemplate(CodeTemplateContextType.CATCHBLOCK_ID, "", null); StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null); StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null); fJProject1 = ProjectTestSetup.getProject(); fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src"); }
6. TypeMismatchQuickFixTests#setUp()
Project: che
File: TypeMismatchQuickFixTests.java
File: TypeMismatchQuickFixTests.java
// public static Test suite() { // return setUpTest(new TestSuite(THIS)); // } // // public static Test setUpTest(Test test) { // return new ProjectTestSetup(test); // } @Before public void setUp() throws Exception { super.setUp(); Hashtable options = TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, String.valueOf(99)); options.put(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER, JavaCore.ERROR); options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.IGNORE); JavaCore.setOptions(options); IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); StubUtility.setCodeTemplate(CodeTemplateContextType.CATCHBLOCK_ID, "", null); StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null); StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null); fJProject1 = ProjectTestSetup.getProject(); fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src"); }
7. ModifierCorrectionsQuickFixTest#setUp()
Project: che
File: ModifierCorrectionsQuickFixTest.java
File: ModifierCorrectionsQuickFixTest.java
// public static Test suite() { // return setUpTest(new TestSuite(THIS)); // } // // public static Test setUpTest(Test test) { // return new ProjectTestSetup(test); // } @Before public void setUp() throws Exception { super.setUp(); Hashtable options = TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, JavaCore.DO_NOT_INSERT); options.put(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER, JavaCore.ERROR); options.put(JavaCore.COMPILER_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD, JavaCore.ERROR); JavaCore.setOptions(options); IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); fJProject1 = ProjectTestSetup.getProject(); StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null); StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null); fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src"); }
8. TomcatManagerImpl#getConnectorName()
Project: geronimo
File: TomcatManagerImpl.java
File: TomcatManagerImpl.java
private ObjectName getConnectorName(ObjectName container, String protocol, String uniqueName) { Hashtable table = new Hashtable(); table.put(NameFactory.J2EE_APPLICATION, container.getKeyProperty(NameFactory.J2EE_APPLICATION)); table.put(NameFactory.J2EE_SERVER, container.getKeyProperty(NameFactory.J2EE_SERVER)); table.put(NameFactory.J2EE_MODULE, container.getKeyProperty(NameFactory.J2EE_MODULE)); table.put(NameFactory.J2EE_TYPE, container.getKeyProperty(NameFactory.J2EE_TYPE)); table.put(NameFactory.J2EE_NAME, "TomcatWebConnector-" + protocol + "-" + uniqueName); try { return ObjectName.getInstance(container.getDomain(), table); } catch (MalformedObjectNameException e) { throw new IllegalStateException("Never should have failed: " + e.getMessage()); } }
9. JettyManagerImpl#getConnectorName()
Project: geronimo
File: JettyManagerImpl.java
File: JettyManagerImpl.java
private ObjectName getConnectorName(ObjectName container, String protocol, String uniqueName) { Hashtable table = new Hashtable(); table.put(NameFactory.J2EE_APPLICATION, container.getKeyProperty(NameFactory.J2EE_APPLICATION)); table.put(NameFactory.J2EE_SERVER, container.getKeyProperty(NameFactory.J2EE_SERVER)); table.put(NameFactory.J2EE_MODULE, container.getKeyProperty(NameFactory.J2EE_MODULE)); table.put(NameFactory.J2EE_TYPE, container.getKeyProperty(NameFactory.J2EE_TYPE)); table.put(NameFactory.J2EE_NAME, "JettyWebConnector-" + protocol + "-" + uniqueName); try { return ObjectName.getInstance(container.getDomain(), table); } catch (MalformedObjectNameException e) { throw new IllegalStateException("Never should have failed: " + e.getMessage()); } }
10. AbstractRefactoringTestSetup#setUp()
Project: che
File: AbstractRefactoringTestSetup.java
File: AbstractRefactoringTestSetup.java
/*public AbstractRefactoringTestSetup(Test test) { super(test); } */ protected void setUp() throws Exception { // super.setUp(); // fWasAutobuild= CoreUtility.setAutoBuilding(false); // if (JavaPlugin.getActivePage() != null) // JavaPlugin.getActivePage().close(); Hashtable options = TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB); options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "0"); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, String.valueOf(9999)); JavaCore.setOptions(options); TestOptions.initializeCodeGenerationOptions(); JavaPlugin.getDefault().getCodeTemplateStore().load(); StringBuffer comment = new StringBuffer(); comment.append("/**\n"); comment.append(" * ${tags}\n"); comment.append(" */"); StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORCOMMENT_ID, comment.toString(), null); }
11. HashtableTest#test_toString()
Project: j2objc
File: HashtableTest.java
File: HashtableTest.java
/** * java.util.Hashtable#toString() */ public void test_toString() { // Test for method java.lang.String java.util.Hashtable.toString() Hashtable h = new Hashtable(); assertEquals("Incorrect toString for Empty table", "{}", h.toString()); h.put("one", "1"); h.put("two", h); h.put(h, "3"); h.put(h, h); String result = h.toString(); assertTrue("should contain self ref", result.indexOf("(this") > -1); }
12. LayoutEditorPane#createEvent()
Project: chainsaw
File: LayoutEditorPane.java
File: LayoutEditorPane.java
/** * */ private void createEvent() { Hashtable hashTable = new Hashtable(); hashTable.put("key1", "val1"); hashTable.put("key2", "val2"); hashTable.put("key3", "val3"); LocationInfo li = new LocationInfo("myfile.java", "com.mycompany.util.MyClass", "myMethod", "321"); ThrowableInformation tsr = new ThrowableInformation(new Exception()); event = new LoggingEvent("org.apache.log4j.Logger", Logger.getLogger("com.mycompany.mylogger"), new Date().getTime(), org.apache.log4j.Level.DEBUG, "The quick brown fox jumped over the lazy dog", "Thread-1", tsr, "NDC string", li, hashTable); }
13. UnresolvedTypesQuickFixTest#setUp()
Project: che
File: UnresolvedTypesQuickFixTest.java
File: UnresolvedTypesQuickFixTest.java
@Before public void setUp() throws Exception { super.setUp(); Hashtable options = TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); JavaCore.setOptions(options); IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); fJProject1 = ProjectTestSetup.getProject(); String newFileTemplate = "${package_declaration}\n\n${type_declaration}"; StubUtility.setCodeTemplate(CodeTemplateContextType.NEWTYPE_ID, newFileTemplate, null); StubUtility.setCodeTemplate(CodeTemplateContextType.TYPECOMMENT_ID, "", null); StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null); fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src"); }
14. ReturnTypeQuickFixTest#setUp()
Project: che
File: ReturnTypeQuickFixTest.java
File: ReturnTypeQuickFixTest.java
// // public static Test suite() { // return setUpTest(new TestSuite(THIS)); // } // // public static Test setUpTest(Test test) { // return new ProjectTestSetup(test); // } @Before public void setUp() throws Exception { super.setUp(); Hashtable options = TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); options.put(JavaCore.COMPILER_PB_UNCHECKED_TYPE_OPERATION, JavaCore.IGNORE); JavaCore.setOptions(options); IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); fJProject1 = ProjectTestSetup.getProject(); fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src"); }
15. ReorgQuickFixTest#setUp()
Project: che
File: ReorgQuickFixTest.java
File: ReorgQuickFixTest.java
// public static Test suite() { // return setUpTest(new TestSuite(THIS)); // } // // public static Test setUpTest(Test test) { // return new ProjectTestSetup(test); // } @Before public void setUp() throws Exception { super.setUp(); Hashtable options = TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); options.put(JavaCore.COMPILER_PB_UNUSED_IMPORT, JavaCore.ERROR); JavaCore.setOptions(options); IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); fJProject1 = ProjectTestSetup.getProject(); fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src"); }
16. ModifierCorrectionsQuickFixTest17#setUp()
Project: che
File: ModifierCorrectionsQuickFixTest17.java
File: ModifierCorrectionsQuickFixTest17.java
// public static Test suite() { // return setUpTest(new TestSuite(THIS)); // } // // public static Test setUpTest(Test test) { // return new Java17ProjectTestSetup(test); // } @Before public void setUp() throws Exception { super.setUp(); Hashtable options = TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, JavaCore.DO_NOT_INSERT); JavaCore.setOptions(options); IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); fJProject1 = Java17ProjectTestSetup.getProject(); StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "", null); StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, "", null); fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src"); }
17. UDDIServiceCounter#initList()
Project: juddi
File: UDDIServiceCounter.java
File: UDDIServiceCounter.java
public void initList(Class klass, List<String> queries) { try { listObjectName = new ObjectName("apache.juddi:" + "counter=" + klass.getName()); } catch (MalformedObjectNameException mone) { log.error(mone); } queryProcessingTime = new Hashtable<String, LongHolder>(); totalQueryCounter = new Hashtable<String, IntHolder>(); successQueryCounter = new Hashtable<String, IntHolder>(); faultQueryCounter = new Hashtable<String, IntHolder>(); for (String query : queries) { queryProcessingTime.put(query + " " + PROCESSING_TIME, new LongHolder()); totalQueryCounter.put(query + " " + TOTAL_QUERIES, new IntHolder()); successQueryCounter.put(query + " " + SUCCESSFUL_QUERIES, new IntHolder()); faultQueryCounter.put(query + " " + FAILED_QUERIES, new IntHolder()); } totalApiCounter = 0; successApiCounter = 0; faultApiCounter = 0; }
18. DeadSSLLdapTimeoutTest#main()
Project: openjdk
File: DeadSSLLdapTimeoutTest.java
File: DeadSSLLdapTimeoutTest.java
public static void main(String[] args) throws Exception { InitialContext ctx = null; // // Running this test serially as it seems to tickle a problem // on older kernels // // run the DeadServerTest with connect / read timeouts set // and ssl enabled // this should exit with a SocketTimeoutException as the root cause // it should also use the connect timeout instead of the read timeout System.out.println("Running connect timeout test with 10ms connect timeout, 3000ms read timeout & SSL"); Hashtable sslenv = createEnv(); sslenv.put("com.sun.jndi.ldap.connect.timeout", "10"); sslenv.put("com.sun.jndi.ldap.read.timeout", "3000"); sslenv.put(Context.SECURITY_PROTOCOL, "ssl"); boolean testFailed = (new DeadServerTimeoutSSLTest(sslenv).call()) ? false : true; if (testFailed) { throw new AssertionError("some tests failed"); } }
19. FileMonitorActivator#start()
Project: servicemix4-kernel
File: FileMonitorActivator.java
File: FileMonitorActivator.java
// BundleActivator interface // ------------------------------------------------------------------------- public void start(BundleContext context) throws Exception { this.context = context; Hashtable properties = new Hashtable(); properties.put(Constants.SERVICE_PID, getName()); context.registerService(ManagedServiceFactory.class.getName(), this, properties); packageAdminTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null); packageAdminTracker.open(); configurationAdminTracker = new ServiceTracker(context, ConfigurationAdmin.class.getName(), null); configurationAdminTracker.open(); preferenceServiceTracker = new ServiceTracker(context, PreferencesService.class.getName(), null); preferenceServiceTracker.open(); Hashtable initialProperties = new Hashtable(); setPropertiesFromContext(initialProperties, FileMonitor.CONFIG_DIR, FileMonitor.DEPLOY_DIR, FileMonitor.GENERATED_JAR_DIR, FileMonitor.SCAN_INTERVAL); updated("initialPid", initialProperties); }
20. ResultsDbWriterTest#getContext()
Project: qpid-java
File: ResultsDbWriterTest.java
File: ResultsDbWriterTest.java
@SuppressWarnings({ "unchecked", "rawtypes" }) private Context getContext() throws NamingException { Context context = mock(Context.class); Hashtable environment = new Hashtable(); environment.put(ResultsDbWriter.DRIVER_NAME, "org.apache.derby.jdbc.EmbeddedDriver"); environment.put(ResultsDbWriter.URL, "jdbc:derby:" + _tempDbDirectory + "perftestResultsDb;create=true"); when(context.getEnvironment()).thenReturn(environment); return context; }
21. PropertiesFileInitialContextFactoryTest#testNonExistentFileHandling()
Project: qpid-java
File: PropertiesFileInitialContextFactoryTest.java
File: PropertiesFileInitialContextFactoryTest.java
public void testNonExistentFileHandling() throws Exception { Hashtable environment = new Hashtable(); // Make sure the filename does not exist File f = File.createTempFile(getTestName(), ".properties"); f.delete(); environment.put(Context.PROVIDER_URL, f.getAbsolutePath()); environment.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jndi.PropertiesFileInitialContextFactory"); try { new InitialContext(environment); fail("Expected exception not thrown."); } catch (NamingException e) { assertTrue("No IOException chained", e.getCause() instanceof IOException); } }
22. TestMetadata#testAddHashtable()
Project: oodt
File: TestMetadata.java
File: TestMetadata.java
public void testAddHashtable() { Hashtable testHash = new Hashtable(); testHash.put("key1", "val1"); testHash.put("key2", "val2"); metadata = new Metadata(); metadata.addMetadata("key3", "val3"); metadata.addMetadata(testHash); assertNotNull(metadata.getMetadata("key1")); assertNotNull(metadata.getMetadata("key2")); assertEquals("val1", metadata.getMetadata("key1")); assertEquals("val2", metadata.getMetadata("key2")); assertNotNull(metadata.getMetadata("key3")); assertEquals("val3", metadata.getMetadata("key3")); }
23. KerberosCredDelegServlet#invokeLdap()
Project: keycloak
File: KerberosCredDelegServlet.java
File: KerberosCredDelegServlet.java
private String invokeLdap(GSSCredential gssCredential) throws NamingException { Hashtable env = new Hashtable(11); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://localhost:10389"); if (gssCredential != null) { env.put(Context.SECURITY_AUTHENTICATION, "GSSAPI"); env.put(Sasl.CREDENTIALS, gssCredential); } DirContext ctx = new InitialDirContext(env); try { Attributes attrs = ctx.getAttributes("uid=hnelson,ou=People,dc=keycloak,dc=org"); String cn = (String) attrs.get("cn").get(); String sn = (String) attrs.get("sn").get(); return cn + " " + sn; } finally { ctx.close(); } }
24. KerberosCredDelegServlet#invokeLdap()
Project: keycloak
File: KerberosCredDelegServlet.java
File: KerberosCredDelegServlet.java
private String invokeLdap(GSSCredential gssCredential) throws NamingException { Hashtable env = new Hashtable(11); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://localhost:10389"); if (gssCredential != null) { env.put(Context.SECURITY_AUTHENTICATION, "GSSAPI"); env.put(Sasl.CREDENTIALS, gssCredential); } DirContext ctx = new InitialDirContext(env); try { Attributes attrs = ctx.getAttributes("uid=hnelson,ou=People,dc=keycloak,dc=org"); String cn = (String) attrs.get("cn").get(); String sn = (String) attrs.get("sn").get(); return cn + " " + sn; } finally { ctx.close(); } }
25. GSSCredentialsClient#invokeLdap()
Project: keycloak
File: GSSCredentialsClient.java
File: GSSCredentialsClient.java
private static LDAPUser invokeLdap(GSSCredential gssCredential, String username) throws NamingException { Hashtable env = new Hashtable(11); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://localhost:10389"); if (gssCredential != null) { env.put(Context.SECURITY_AUTHENTICATION, "GSSAPI"); env.put(Sasl.CREDENTIALS, gssCredential); } DirContext ctx = new InitialDirContext(env); try { Attributes attrs = ctx.getAttributes("uid=" + username + ",ou=People,dc=keycloak,dc=org"); String uid = username; String cn = (String) attrs.get("cn").get(); String sn = (String) attrs.get("sn").get(); return new LDAPUser(uid, cn, sn); } finally { ctx.close(); } }
26. HashtableTest#setUp()
Project: j2objc
File: HashtableTest.java
File: HashtableTest.java
/** * Sets up the fixture, for example, open a network connection. This method * is called before a test is executed. */ protected void setUp() { ht10 = new Hashtable(10); ht100 = new Hashtable(100); htfull = new Hashtable(10); keyVector = new Vector(10); elmVector = new Vector(10); for (int i = 0; i < 10; i++) { ht10.put("Key " + i, "Val " + i); keyVector.addElement("Key " + i); elmVector.addElement("Val " + i); } for (int i = 0; i < 7; i++) htfull.put("FKey " + i, "FVal " + i); }
27. HashtableTest#test_keys_subtest0()
Project: j2objc
File: HashtableTest.java
File: HashtableTest.java
/** * java.util.Hashtable#keys() */ public void test_keys_subtest0() { // this is the reference implementation behavior final Hashtable ht = new Hashtable(3); ht.put("initial", ""); Enumeration en = ht.keys(); en.hasMoreElements(); ht.remove("initial"); boolean exception = false; try { Object result = en.nextElement(); assertTrue("unexpected: " + result, "initial".equals(result)); } catch (NoSuchElementException e) { exception = true; } assertTrue("unexpected NoSuchElementException", !exception); }
28. HashtableTest#test_ConstructorIF()
Project: j2objc
File: HashtableTest.java
File: HashtableTest.java
/** * java.util.Hashtable#Hashtable(int, float) */ public void test_ConstructorIF() { // Test for method java.util.Hashtable(int, float) Hashtable h = new java.util.Hashtable(10, 0.5f); assertEquals("Created incorrect hashtable", 0, h.size()); Hashtable empty = new Hashtable(0, 0.75f); assertNull("Empty hashtable access", empty.get("nothing")); empty.put("something", "here"); assertTrue("cannot get element", empty.get("something") == "here"); try { new Hashtable(-1, 0.75f); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { } try { new Hashtable(0, -0.75f); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { } }
29. UIBuilder#getContainerState()
Project: CodenameOne
File: UIBuilder.java
File: UIBuilder.java
/** * This method is the container navigation equivalent of getFormState() see * that method for details. * @param cnt the container * @return the state */ protected Hashtable getContainerState(Container cnt) { Component c = null; Form parentForm = cnt.getComponentForm(); if (parentForm != null) { c = parentForm.getFocused(); } Hashtable h = new Hashtable(); h.put(FORM_STATE_KEY_NAME, cnt.getName()); h.put(FORM_STATE_KEY_CONTAINER, ""); if (c != null && isParentOf(cnt, c)) { if (c instanceof List) { h.put(FORM_STATE_KEY_SELECTION, new Integer(((List) c).getSelectedIndex())); } if (c.getName() != null) { h.put(FORM_STATE_KEY_FOCUS, c.getName()); } return h; } storeComponentState(cnt, h); return h; }
30. TestDeser#testHashtable()
Project: axis1-java
File: TestDeser.java
File: TestDeser.java
public void testHashtable() throws Exception { Hashtable ht = new Hashtable(); ht.put("abcKey", "abcVal"); ht.put("defKey", "defVal"); deserialize("<result xsi:type=\"xmlsoap:Map\" " + "xmlns:xmlsoap=\"http://xml.apache.org/xml-soap\"> " + "<item>" + "<key xsi:type=\"xsd:string\">abcKey</key>" + "<value xsi:type=\"xsd:string\">abcVal</value>" + "</item><item>" + "<key xsi:type=\"xsd:string\">defKey</key>" + "<value xsi:type=\"xsd:string\">defVal</value>" + "</item>" + "</result>", ht, true); }
31. SystemNotificationsImpl#registerAsEventHandler()
Project: acs-aem-commons
File: SystemNotificationsImpl.java
File: SystemNotificationsImpl.java
private void registerAsEventHandler() { final Hashtable filterProps = new Hashtable<String, String>(); // Listen on Add and Remove under /etc/acs-commons/notifications filterProps.put(EventConstants.EVENT_TOPIC, new String[] { SlingConstants.TOPIC_RESOURCE_ADDED, SlingConstants.TOPIC_RESOURCE_REMOVED }); filterProps.put(EventConstants.EVENT_FILTER, "(&" + "(" + SlingConstants.PROPERTY_PATH + "=" + SystemNotificationsImpl.PATH_NOTIFICATIONS + "/*)" + ")"); this.eventHandlerRegistration = this.osgiComponentContext.getBundleContext().registerService(EventHandler.class.getName(), this, filterProps); log.debug("Registered System Notifications as Event Handler"); }
32. LocalCorrectionsQuickFixTest#testUnusedVariableBug120579()
Project: che
File: LocalCorrectionsQuickFixTest.java
File: LocalCorrectionsQuickFixTest.java
@Test public void testUnusedVariableBug120579() throws Exception { Hashtable hashtable = JavaCore.getOptions(); hashtable.put(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.ERROR); hashtable.put(JavaCore.COMPILER_PB_UNUSED_PARAMETER, JavaCore.ERROR); JavaCore.setOptions(hashtable); IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf = new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" char[] array= new char[0];\n"); buf.append(" for (char element: array) {}\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot = getASTRoot(cu); ArrayList proposals = collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 0); assertCorrectLabels(proposals); }
33. ConvertIterableLoopQuickFixTest#setUp()
Project: che
File: ConvertIterableLoopQuickFixTest.java
File: ConvertIterableLoopQuickFixTest.java
@Before public void setUp() throws Exception { super.setUp(); Hashtable options = TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); JavaCore.setOptions(options); IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); fProject = ProjectTestSetup.getProject(); fSourceFolder = JavaProjectHelper.addSourceContainer(fProject, "src"); fConvertLoopProposal = null; }
34. ConvertForLoopQuickFixTest#setUp()
Project: che
File: ConvertForLoopQuickFixTest.java
File: ConvertForLoopQuickFixTest.java
// public static Test suite() { // return setUpTest(new TestSuite(THIS)); // } // public static Test setUpTest(Test test) { // return new ProjectTestSetup(test); // } @Before public void setUp() throws Exception { super.setUp(); Hashtable options = TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); JavaCore.setOptions(options); IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); fJProject1 = ProjectTestSetup.getProject(); fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src"); fConvertLoopProposal = null; }
35. AssistQuickFixTest18#setUp()
Project: che
File: AssistQuickFixTest18.java
File: AssistQuickFixTest18.java
// public static Test suite() { // return setUpTest(new TestSuite(THIS)); // } // // public static Test setUpTest(Test test) { // return new Java18ProjectTestSetup(test); // } @Before public void setUp() throws Exception { super.setUp(); Hashtable options = TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); JavaCore.setOptions(options); IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null); fJProject1 = Java18ProjectTestSetup.getProject(); fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src"); }
36. AssistQuickFixTest17#setUp()
Project: che
File: AssistQuickFixTest17.java
File: AssistQuickFixTest17.java
@Before public void setUp() throws Exception { super.setUp(); Hashtable options = TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); JavaCore.setOptions(options); IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, false); StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null); // Preferences corePrefs = JavaPlugin.getJavaCorePluginPreferences(); // corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); // corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); // corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); // corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); fJProject1 = Java17ProjectTestSetup.getProject(); fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src"); }
37. AdvancedQuickAssistTest18#setUp()
Project: che
File: AdvancedQuickAssistTest18.java
File: AdvancedQuickAssistTest18.java
@Before public void setUp() throws Exception { super.setUp(); Hashtable options = TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); JavaCore.setOptions(options); IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, false); StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null); fJProject1 = Java18ProjectTestSetup.getProject(); fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src"); }
38. AdvancedQuickAssistTest17#setUp()
Project: che
File: AdvancedQuickAssistTest17.java
File: AdvancedQuickAssistTest17.java
@Before public void setUp() throws Exception { super.setUp(); Hashtable options = TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); JavaCore.setOptions(options); IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, false); StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null); // Preferences corePrefs = JavaPlugin.getJavaCorePluginPreferences(); // corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); // corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); // corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); // corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); fJProject1 = Java17ProjectTestSetup.getProject(); fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src"); }
39. AdvancedQuickAssistTest#setUp()
Project: che
File: AdvancedQuickAssistTest.java
File: AdvancedQuickAssistTest.java
@Before public void setUp() throws Exception { super.setUp(); Hashtable options = TestOptions.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); JavaCore.setOptions(options); IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, false); StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null); // Preferences corePrefs = JavaPlugin.getJavaCorePluginPreferences(); // corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); // corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); // corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); // corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); fJProject1 = ProjectTestSetup.getProject(); fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src"); }
40. JavaModelManager#getDefaultOptions()
Project: che
File: JavaModelManager.java
File: JavaModelManager.java
// If modified, also modify the method getDefaultOptionsNoInitialization() public Hashtable getDefaultOptions() { Hashtable defaultOptions = new Hashtable(10); // see JavaCorePreferenceInitializer#initializeDefaultPluginPreferences() for changing default settings // If modified, also modify the method getDefaultOptionsNoInitialization() // IEclipsePreferences defaultPreferences = getDefaultPreferences(); // initialize preferences to their default // Iterator iterator = this.optionNames.iterator(); // while (iterator.hasNext()) { // String propertyName = (String) iterator.next(); // String value = defaultPreferences.get(propertyName, null); // if (value != null) defaultOptions.put(propertyName, value); // } // get encoding through resource plugin defaultOptions.put(org.eclipse.jdt.core.JavaCore.CORE_ENCODING, "UTF-8"); defaultOptions.putAll(getDefaultOptionsNoInitialization()); return defaultOptions; }
41. Activator#doStart()
Project: karaf-cellar
File: Activator.java
File: Activator.java
@Override public void doStart() throws Exception { ClusterManager clusterManager = getTrackedService(ClusterManager.class); if (clusterManager == null) return; GroupManager groupManager = getTrackedService(GroupManager.class); if (groupManager == null) return; LOGGER.debug("CELLAR WEBCONSOLE: init plugin"); plugin = new CellarPlugin(); plugin.setClusterManager(clusterManager); plugin.setGroupManager(groupManager); plugin.setBundleContext(bundleContext); plugin.start(); Hashtable props = new Hashtable(); props.put("felix.webconsole.label", "cellar"); register(Servlet.class, plugin, props); }
42. Activator#doStart()
Project: karaf-cellar
File: Activator.java
File: Activator.java
@Override public void doStart() throws Exception { ClusterManager clusterManager = getTrackedService(ClusterManager.class); if (clusterManager == null) return; String nodeId = clusterManager.getNode().getId(); GreeterImpl greeter = new GreeterImpl(nodeId); Hashtable props = new Hashtable(); props.put("service.exported.interfaces", "*"); register(Greeter.class, greeter, props); }
43. GenericValidatingPackagerTest#testGenericValidatorContentHandlerMakeMsgValidatorArray()
Project: jPOS
File: GenericValidatingPackagerTest.java
File: GenericValidatingPackagerTest.java
@SuppressWarnings("unchecked") @Test public void testGenericValidatorContentHandlerMakeMsgValidatorArray() throws Throwable { GenericValidatingPackager.GenericValidatorContentHandler genericValidatorContentHandler = new GenericValidatingPackager().new GenericValidatorContentHandler(); Vector vector = new Vector(); vector.add(null); Hashtable tab = new Hashtable(100); tab.put(Integer.valueOf(-3), vector); ISOBaseValidator[] result = genericValidatorContentHandler.makeMsgValidatorArray(tab); assertEquals("result.length", 1, result.length); assertNull("result[0]", result[0]); }
44. GenericValidatingPackagerTest#testGenericValidatorContentHandlerMakeFieldValidatorArrayThrowsClassCastException2()
Project: jPOS
File: GenericValidatingPackagerTest.java
File: GenericValidatingPackagerTest.java
@SuppressWarnings("unchecked") @Test public void testGenericValidatorContentHandlerMakeFieldValidatorArrayThrowsClassCastException2() throws Throwable { GenericValidatingPackager.GenericValidatorContentHandler genericValidatorContentHandler = new GenericValidatingPackager().new GenericValidatorContentHandler(); Hashtable tab = new Hashtable(100); tab.put("testString", new Object()); try { genericValidatorContentHandler.makeFieldValidatorArray(tab); fail("Expected ClassCastException to be thrown"); } catch (ClassCastException ex) { assertEquals("ex.getClass()", ClassCastException.class, ex.getClass()); assertEquals("tab.size()", 1, tab.size()); } }
45. GenericValidatingPackagerTest#testGenericValidatorContentHandlerMakeFieldValidatorArrayThrowsClassCastException1()
Project: jPOS
File: GenericValidatingPackagerTest.java
File: GenericValidatingPackagerTest.java
@SuppressWarnings("unchecked") @Test public void testGenericValidatorContentHandlerMakeFieldValidatorArrayThrowsClassCastException1() throws Throwable { GenericValidatingPackager.GenericValidatorContentHandler genericValidatorContentHandler = new GenericValidatingPackager().new GenericValidatorContentHandler(); Map hashMap = new HashMap(); hashMap.put("", "testString"); Hashtable tab = new Hashtable(hashMap); tab.put(Integer.valueOf(100), new IVA_ALPHANUMNOZERO_NOBLANK(true, "testGenericValidatorContentHandlerDescription")); try { genericValidatorContentHandler.makeFieldValidatorArray(tab); fail("Expected ClassCastException to be thrown"); } catch (ClassCastException ex) { assertEquals("ex.getClass()", ClassCastException.class, ex.getClass()); assertEquals("tab.size()", 2, tab.size()); } }
46. GetContDirCtx#main()
Project: jdk7u-jdk
File: GetContDirCtx.java
File: GetContDirCtx.java
public static void main(String[] args) throws Exception { CannotProceedException cpe = new CannotProceedException(); Hashtable env = new Hashtable(1); cpe.setEnvironment(env); Reference ref = new Reference("java.lang.Object", "DummyObjectFactory", null); cpe.setResolvedObj(ref); Context contCtx = null; try { contCtx = DirectoryManager.getContinuationDirContext(cpe); } catch (CannotProceedException e) { } Hashtable contEnv = contCtx.getEnvironment(); if (contEnv.get(NamingManager.CPE) != cpe) { throw new Exception("Test failed: CPE property not set" + " in the continuation context"); } }
47. BinaryConstantPool#createIndexHash()
Project: jdk7u-jdk
File: BinaryConstantPool.java
File: BinaryConstantPool.java
/** * Create a hash table of all the items in the constant pool that could * possibly be referenced from the outside. */ public void createIndexHash(Environment env) { indexHashObject = new Hashtable(); indexHashAscii = new Hashtable(); for (int i = 1; i < cpool.length; i++) { if (types[i] == CONSTANT_UTF8) { indexHashAscii.put(cpool[i], new Integer(i)); } else { try { indexHashObject.put(getConstant(i, env), new Integer(i)); } catch (ClassFormatError e) { } } } }
48. AttributeValues#toSerializableHashtable()
Project: jdk7u-jdk
File: AttributeValues.java
File: AttributeValues.java
public Hashtable<Object, Object> toSerializableHashtable() { Hashtable ht = new Hashtable(); int hashkey = defined; for (int m = defined, i = 0; m != 0; ++i) { EAttribute ea = EAttribute.atts[i]; if ((m & ea.mask) != 0) { m &= ~ea.mask; Object o = get(ea); if (o == null) { // hashkey will handle it } else if (o instanceof Serializable) { // check all... ht.put(ea.att, o); } else { hashkey &= ~ea.mask; } } } ht.put(DEFINED_KEY, Integer.valueOf(hashkey)); return ht; }
49. NamingManager#getContinuationContext()
Project: jdk7u-jdk
File: NamingManager.java
File: NamingManager.java
/** * Creates a context in which to continue a context operation. *<p> * In performing an operation on a name that spans multiple * namespaces, a context from one naming system may need to pass * the operation on to the next naming system. The context * implementation does this by first constructing a * <code>CannotProceedException</code> containing information * pinpointing how far it has proceeded. It then obtains a * continuation context from JNDI by calling * <code>getContinuationContext</code>. The context * implementation should then resume the context operation by * invoking the same operation on the continuation context, using * the remainder of the name that has not yet been resolved. *<p> * Before making use of the <tt>cpe</tt> parameter, this method * updates the environment associated with that object by setting * the value of the property <a href="#CPE"><tt>CPE</tt></a> * to <tt>cpe</tt>. This property will be inherited by the * continuation context, and may be used by that context's * service provider to inspect the fields of this exception. * * @param cpe * The non-null exception that triggered this continuation. * @return A non-null Context object for continuing the operation. * @exception NamingException If a naming exception occurred. */ public static Context getContinuationContext(CannotProceedException cpe) throws NamingException { Hashtable env = cpe.getEnvironment(); if (env == null) { env = new Hashtable(7); } else { // Make a (shallow) copy of the environment. env = (Hashtable) env.clone(); } env.put(CPE, cpe); ContinuationContext cctx = new ContinuationContext(cpe, env); return cctx.getTargetContext(); }
50. DirectoryManager#getContinuationDirContext()
Project: jdk7u-jdk
File: DirectoryManager.java
File: DirectoryManager.java
/** * Creates a context in which to continue a <tt>DirContext</tt> operation. * Operates just like <tt>NamingManager.getContinuationContext()</tt>, * only the continuation context returned is a <tt>DirContext</tt>. * * @param cpe * The non-null exception that triggered this continuation. * @return A non-null <tt>DirContext</tt> object for continuing the operation. * @exception NamingException If a naming exception occurred. * * @see NamingManager#getContinuationContext(CannotProceedException) */ public static DirContext getContinuationDirContext(CannotProceedException cpe) throws NamingException { Hashtable env = cpe.getEnvironment(); if (env == null) { env = new Hashtable(7); } else { // Make a (shallow) copy of the environment. env = (Hashtable) env.clone(); } env.put(CPE, cpe); return (new ContinuationDirContext(cpe, env)); }
51. HashtableTest#test_putAllLjava_util_Map()
Project: j2objc
File: HashtableTest.java
File: HashtableTest.java
/** * java.util.Hashtable#putAll(java.util.Map) */ public void test_putAllLjava_util_Map() { // Test for method void java.util.Hashtable.putAll(java.util.Map) Hashtable h = new Hashtable(); h.putAll(ht10); Enumeration e = keyVector.elements(); while (e.hasMoreElements()) { Object x = e.nextElement(); assertTrue("Failed to put all elements", h.get(x).equals(ht10.get(x))); } try { h.putAll(null); fail("NullPointerException expected"); } catch (NullPointerException ee) { } }
52. MemberResolver#lookupClass()
Project: HotswapAgent
File: MemberResolver.java
File: MemberResolver.java
/** * @param name a qualified class name. e.g. java.lang.String */ public org.hotswap.agent.javassist.CtClass lookupClass(String name, boolean notCheckInner) throws CompileError { Hashtable cache = getInvalidNames(); Object found = cache.get(name); if (found == INVALID) throw new CompileError("no such class: " + name); else if (found != null) try { return classPool.get((String) found); } catch (org.hotswap.agent.javassist.NotFoundException e) { } org.hotswap.agent.javassist.CtClass cc = null; try { cc = lookupClass0(name, notCheckInner); } catch (org.hotswap.agent.javassist.NotFoundException e) { cc = searchImports(name); } cache.put(name, cc.getName()); return cc; }
53. JndiTest#testConfigureJndiInsideSpringXml()
Project: geronimo-xbean
File: JndiTest.java
File: JndiTest.java
public void testConfigureJndiInsideSpringXml() throws Exception { // lets load a spring context BeanFactory factory = new ClassPathXmlApplicationContext("org/apache/xbean/spring/jndi/spring.xml"); Object test = factory.getBean("restaurant"); assertNotNull("Should have found the test object", test); Object jndi = factory.getBean("jndi"); assertNotNull("Should have found the jndi object", jndi); Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, SpringInitialContextFactory.class.getName()); InitialContext context = new InitialContext(env); assertEntryExists(context, "test"); assertEntryExists(context, "test/restaurant"); assertSame(test, context.lookup("test/restaurant")); }
54. JndiTest#testConfigureJndiInsideSpringXml()
Project: geronimo-xbean
File: JndiTest.java
File: JndiTest.java
public void testConfigureJndiInsideSpringXml() throws Exception { // lets load a spring context BeanFactory factory = new ClassPathXmlApplicationContext("org/apache/xbean/spring/jndi/spring.xml"); Object test = factory.getBean("restaurant"); assertNotNull("Should have found the test object", test); Object jndi = factory.getBean("jndi"); assertNotNull("Should have found the jndi object", jndi); Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, SpringInitialContextFactory.class.getName()); InitialContext context = new InitialContext(env); assertEntryExists(context, "test"); assertEntryExists(context, "test/restaurant"); assertSame(test, context.lookup("test/restaurant")); }
55. JndiTest#testConfigureJndiInsideSpringXml()
Project: geronimo-xbean
File: JndiTest.java
File: JndiTest.java
public void testConfigureJndiInsideSpringXml() throws Exception { // lets load a spring context BeanFactory factory = new ClassPathXmlApplicationContext("org/apache/xbean/spring/jndi/spring.xml"); Object test = factory.getBean("restaurant"); assertNotNull("Should have found the test object", test); Object jndi = factory.getBean("jndi"); assertNotNull("Should have found the jndi object", jndi); Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, SpringInitialContextFactory.class.getName()); InitialContext context = new InitialContext(env); assertEntryExists(context, "test"); assertEntryExists(context, "test/restaurant"); assertSame(test, context.lookup("test/restaurant")); }
56. CollectionHelper#parameterMapToHashtable()
Project: geronimo
File: CollectionHelper.java
File: CollectionHelper.java
public static Hashtable parameterMapToHashtable(Map m) { Hashtable ret = new Hashtable(); ret.putAll(m); for (Iterator i = ret.keySet().iterator(); i.hasNext(); ) { Object key = i.next(); String[] value = (String[]) ret.get(key); try { ret.put(key, value[0]); } catch (ArrayIndexOutOfBoundsException e) { } } return ret; }
57. MemberResolver#lookupClass()
Project: scouter
File: MemberResolver.java
File: MemberResolver.java
/** * @param name a qualified class name. e.g. java.lang.String */ public CtClass lookupClass(String name, boolean notCheckInner) throws CompileError { Hashtable cache = getInvalidNames(); Object found = cache.get(name); if (found == INVALID) throw new CompileError("no such class: " + name); else if (found != null) try { return classPool.get((String) found); } catch (NotFoundException e) { } CtClass cc = null; try { cc = lookupClass0(name, notCheckInner); } catch (NotFoundException e) { cc = searchImports(name); } cache.put(name, cc.getName()); return cc; }
58. AbstractRunner#getContext()
Project: qpid-java
File: AbstractRunner.java
File: AbstractRunner.java
protected Context getContext() { String jndiConfig = getJndiConfig(); Hashtable env = new Hashtable(); env.put(Context.PROVIDER_URL, jndiConfig); // Java allows this to be overridden with a system property of the same name if (!System.getProperties().containsKey(InitialContext.INITIAL_CONTEXT_FACTORY)) { env.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jndi.PropertiesFileInitialContextFactory"); } try { return new InitialContext(env); } catch (NamingException e) { throw new DistributedTestException("Exception whilst creating InitialContext from URL '" + jndiConfig + "'", e); } }
59. GetContDirCtx#main()
Project: openjdk
File: GetContDirCtx.java
File: GetContDirCtx.java
public static void main(String[] args) throws Exception { CannotProceedException cpe = new CannotProceedException(); Hashtable env = new Hashtable(1); cpe.setEnvironment(env); Reference ref = new Reference("java.lang.Object", "DummyObjectFactory", null); cpe.setResolvedObj(ref); Context contCtx = null; try { contCtx = DirectoryManager.getContinuationDirContext(cpe); } catch (CannotProceedException e) { } Hashtable contEnv = contCtx.getEnvironment(); if (contEnv.get(NamingManager.CPE) != cpe) { throw new Exception("Test failed: CPE property not set" + " in the continuation context"); } }
60. TestAttributedStringCtor#main()
Project: openjdk
File: TestAttributedStringCtor.java
File: TestAttributedStringCtor.java
public static void main(String[] args) { // Create a new AttributedString with one attribute. Hashtable attributes = new Hashtable(); attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD); AttributedString origString = new AttributedString("Hello world.", attributes); // Create an iterator over part of the AttributedString. AttributedCharacterIterator iter = origString.getIterator(null, 4, 6); // Attempt to create a new AttributedString from the iterator. // This will throw IllegalArgumentException. AttributedString newString = new AttributedString(iter); // Without the exception this would get executed. System.out.println("DONE"); }
61. BinaryConstantPool#createIndexHash()
Project: openjdk
File: BinaryConstantPool.java
File: BinaryConstantPool.java
/** * Create a hash table of all the items in the constant pool that could * possibly be referenced from the outside. */ public void createIndexHash(Environment env) { indexHashObject = new Hashtable<>(); indexHashAscii = new Hashtable<>(); for (int i = 1; i < cpool.length; i++) { if (types[i] == CONSTANT_UTF8) { indexHashAscii.put(cpool[i], i); } else { try { indexHashObject.put(getConstant(i, env), i); } catch (ClassFormatError e) { } } } }
62. BuildConfig#putFieldImpl()
Project: openjdk
File: BuildConfig.java
File: BuildConfig.java
private static void putFieldImpl(String cfg, String field, Object value) { if (cfg == null) { globalData.put(field, value); return; } Hashtable ht = (Hashtable) cfgData.get(cfg); if (ht == null) { ht = new Hashtable(); cfgData.put(cfg, ht); } ht.put(field, value); }
63. IDLGenerator#writeImplementation()
Project: openjdk
File: IDLGenerator.java
File: IDLGenerator.java
/** * Write an IDL interface definition for a Java implementation class * @param t The current ImplementationType * @param p The output stream. */ protected void writeImplementation(ImplementationType t, IndentingWriter p) throws IOException { Hashtable inhHash = new Hashtable(); Hashtable refHash = new Hashtable(); //collect interfaces getInterfaces(t, inhHash); writeBanner(t, 0, !isException, p); writeInheritedIncludes(inhHash, p); writeIfndef(t, 0, !isException, !isForward, p); writeIncOrb(p); writeModule1(t, p); p.pln(); p.pI(); p.p("interface " + t.getIDLName()); writeInherits(inhHash, !forValuetype, p); p.pln(" {"); p.pln("};"); p.pO(); p.pln(); writeModule2(t, p); writeEpilog(t, refHash, p); }
64. PatternLearner#extract()
Project: lucida
File: PatternLearner.java
File: PatternLearner.java
/** * Loads target-context-answer-regex tuples from resource files, forms * queries, fetches text passages, extracts answer patterns and writes them * to resource files. * * @return <code>true</code>, iff the answer patterns could be extracted */ public static boolean extract() { // load tuples and form queries MsgPrinter.printFormingQueries(); ass = new Hashtable<String, String>(); regexs = new Hashtable<String, String>(); Query[] queries; ArrayList<Query> queryList = new ArrayList<Query>(); queries = formQueries("res/patternlearning/interpretations"); for (Query query : queries) queryList.add(query); queries = formQueries("res/patternlearning/interpretations_extract"); for (Query query : queries) queryList.add(query); queries = queryList.toArray(new Query[queryList.size()]); // fetch text passages MsgPrinter.printFetchingPassages(); Result[] results = fetchPassages(queries); // extract answer patterns MsgPrinter.printExtractingPatterns(); extractPatterns(results); // save answer patterns MsgPrinter.printSavingPatterns(); return savePatterns("res/patternlearning/answerpatterns_extract"); }
65. MapTest#testSupportsOldHashtables()
Project: xstream
File: MapTest.java
File: MapTest.java
public void testSupportsOldHashtables() { Hashtable hashtable = new Hashtable(); hashtable.put("hello", "world"); String expected = "" + "<hashtable>\n" + " <entry>\n" + " <string>hello</string>\n" + " <string>world</string>\n" + " </entry>\n" + "</hashtable>"; assertBothWays(hashtable, expected); }
66. PKCS12KeyStoreSpi#engineSize()
Project: bc-java
File: PKCS12KeyStoreSpi.java
File: PKCS12KeyStoreSpi.java
public int engineSize() { Hashtable tab = new Hashtable(); Enumeration e = certs.keys(); while (e.hasMoreElements()) { tab.put(e.nextElement(), "cert"); } e = keys.keys(); while (e.hasMoreElements()) { String a = (String) e.nextElement(); if (tab.get(a) == null) { tab.put(a, "key"); } } return tab.size(); }
67. PKCS12KeyStoreSpi#engineAliases()
Project: bc-java
File: PKCS12KeyStoreSpi.java
File: PKCS12KeyStoreSpi.java
public Enumeration engineAliases() { Hashtable tab = new Hashtable(); Enumeration e = certs.keys(); while (e.hasMoreElements()) { tab.put(e.nextElement(), "cert"); } e = keys.keys(); while (e.hasMoreElements()) { String a = (String) e.nextElement(); if (tab.get(a) == null) { tab.put(a, "key"); } } return tab.keys(); }
68. PKCS12KeyStoreSpi#engineSize()
Project: bc-java
File: PKCS12KeyStoreSpi.java
File: PKCS12KeyStoreSpi.java
public int engineSize() { Hashtable tab = new Hashtable(); Enumeration e = certs.keys(); while (e.hasMoreElements()) { tab.put(e.nextElement(), "cert"); } e = keys.keys(); while (e.hasMoreElements()) { String a = (String) e.nextElement(); if (tab.get(a) == null) { tab.put(a, "key"); } } return tab.size(); }
69. PKCS12KeyStoreSpi#engineAliases()
Project: bc-java
File: PKCS12KeyStoreSpi.java
File: PKCS12KeyStoreSpi.java
public Enumeration engineAliases() { Hashtable tab = new Hashtable(); Enumeration e = certs.keys(); while (e.hasMoreElements()) { tab.put(e.nextElement(), "cert"); } e = keys.keys(); while (e.hasMoreElements()) { String a = (String) e.nextElement(); if (tab.get(a) == null) { tab.put(a, "key"); } } return tab.keys(); }
70. PKCS12KeyStoreSpi#engineSize()
Project: bc-java
File: PKCS12KeyStoreSpi.java
File: PKCS12KeyStoreSpi.java
public int engineSize() { Hashtable tab = new Hashtable(); Enumeration e = certs.keys(); while (e.hasMoreElements()) { tab.put(e.nextElement(), "cert"); } e = keys.keys(); while (e.hasMoreElements()) { String a = (String) e.nextElement(); if (tab.get(a) == null) { tab.put(a, "key"); } } return tab.size(); }
71. PKCS12KeyStoreSpi#engineAliases()
Project: bc-java
File: PKCS12KeyStoreSpi.java
File: PKCS12KeyStoreSpi.java
public Enumeration engineAliases() { Hashtable tab = new Hashtable(); Enumeration e = certs.keys(); while (e.hasMoreElements()) { tab.put(e.nextElement(), "cert"); } e = keys.keys(); while (e.hasMoreElements()) { String a = (String) e.nextElement(); if (tab.get(a) == null) { tab.put(a, "key"); } } return tab.keys(); }
72. X509NameTest#createEntryValueFromString()
Project: bc-java
File: X509NameTest.java
File: X509NameTest.java
private ASN1Encodable createEntryValueFromString(ASN1ObjectIdentifier oid, String value) { Hashtable attrs = new Hashtable(); attrs.put(oid, value); Vector order = new Vector(); order.addElement(oid); X509Name name = new X509Name(new X509Name(order, attrs).toString()); ASN1Sequence seq = (ASN1Sequence) name.toASN1Primitive(); ASN1Set set = (ASN1Set) seq.getObjectAt(0); seq = (ASN1Sequence) set.getObjectAt(0); return seq.getObjectAt(1); }
73. X509NameTest#createEntryValue()
Project: bc-java
File: X509NameTest.java
File: X509NameTest.java
private ASN1Encodable createEntryValue(ASN1ObjectIdentifier oid, String value) { Hashtable attrs = new Hashtable(); attrs.put(oid, value); Vector order = new Vector(); order.addElement(oid); X509Name name = new X509Name(order, attrs); ASN1Sequence seq = (ASN1Sequence) name.toASN1Primitive(); ASN1Set set = (ASN1Set) seq.getObjectAt(0); seq = (ASN1Sequence) set.getObjectAt(0); return seq.getObjectAt(1); }
74. StaticConfigurationAdminTest#testFilter()
Project: bnd
File: StaticConfigurationAdminTest.java
File: StaticConfigurationAdminTest.java
public void testFilter() throws Exception { List<StaticConfiguration> configs = new LinkedList<StaticConfiguration>(); Dictionary<String, Object> dict; dict = new Hashtable<String, Object>(); dict.put("foo", "bar"); configs.add(StaticConfiguration.createSingletonConfiguration("org.example.foo", dict)); dict = new Hashtable<String, Object>(); dict.put("foo", "baz"); configs.add(StaticConfiguration.createSingletonConfiguration("org.example.bar", dict)); StaticConfigurationAdmin cm = new StaticConfigurationAdmin(null, configs); Configuration[] result = cm.listConfigurations("(foo=baz)"); assertEquals(1, result.length); assertEquals(configs.get(1), result[0]); }
75. POIServiceImpl#initialize()
Project: bioformats
File: POIServiceImpl.java
File: POIServiceImpl.java
/* @see POIService#initialize(RandomAccessInputStream) */ @Override public void initialize(RandomAccessInputStream s) throws IOException { // determine the size of a 'big' block stream = s; stream.order(true); stream.seek(30); int size = (int) Math.pow(2, stream.readShort()); stream.seek(0); // initialize the file system fileSystem = new POIFSFileSystem(stream, size); root = fileSystem.getRoot(); // build the list of files in the file system filePath = new Vector<String>(); fileSizes = new Hashtable<String, Integer>(); files = new Hashtable<String, DocumentEntry>(); parseFile(root); }
76. HTMLForm#addCheckBox()
Project: CodenameOne
File: HTMLForm.java
File: HTMLForm.java
/** * Adds the specified CheckBox to the form. * Note that unlike adding to a Codename One form here the components are added logically only to query them for their value on submit. * * @param key The CheckBox's name/id * @param cb The CheckBox * @param value The value of the checkbox */ void addCheckBox(String key, CheckBox cb, String value) { if (cb.isSelected()) { defaultCheckedButtons.addElement(cb); } else { defaultUncheckedButtons.addElement(cb); } if (key == null) { //no id return; } Hashtable internal = (Hashtable) comps.get(key); if (internal == null) { internal = new Hashtable(); comps.put(key, internal); } internal.put(cb, value); }
77. HTMLEventsListener#deregisterAll()
Project: CodenameOne
File: HTMLEventsListener.java
File: HTMLEventsListener.java
/** * Deregisters all the listeners, happens before a new page is loaded */ void deregisterAll() { for (Enumeration e = comps.keys(); e.hasMoreElements(); ) { Component cmp = (Component) e.nextElement(); cmp.removeFocusListener(this); if (cmp instanceof Button) { // catches Button, CheckBox, RadioButton ((Button) cmp).removeActionListener(this); } else if (cmp instanceof List) { // catches ComboBox ((List) cmp).removeSelectionListener((SelectionListener) listeners.get(cmp)); } else if (cmp instanceof TextArea) { ((TextArea) cmp).removeActionListener(this); if (cmp instanceof TextField) { ((TextField) cmp).removeDataChangeListener((DataChangedListener) listeners.get(cmp)); } } } comps = new Hashtable(); listeners = new Hashtable(); }
78. CodenameOneImplementation#addCookie()
Project: CodenameOne
File: CodenameOneImplementation.java
File: CodenameOneImplementation.java
/** * Adds/replaces a cookie to be sent to the given domain * * @param c cookie to add */ public void addCookie(Cookie c) { if (cookies == null) { cookies = new Hashtable(); } Hashtable h = (Hashtable) cookies.get(c.getDomain()); if (h == null) { h = new Hashtable(); cookies.put(c.getDomain(), h); } h.put(c.getName(), c); if (Cookie.isAutoStored()) { if (Storage.getInstance().exists(Cookie.STORAGE_NAME)) { Storage.getInstance().deleteStorageFile(Cookie.STORAGE_NAME); } Storage.getInstance().writeObject(Cookie.STORAGE_NAME, cookies); } }
79. User#init()
Project: CodenameOne
File: User.java
File: User.java
private void init(Hashtable toCopy) { super.copy(toCopy); username = (String) toCopy.get("username"); first_name = (String) toCopy.get("first_name"); last_name = (String) toCopy.get("last_name"); link = (String) toCopy.get("link"); about = (String) toCopy.get("about"); birthday = (String) toCopy.get("birthday"); email = (String) toCopy.get("email"); website = (String) toCopy.get("website"); bio = (String) toCopy.get("bio"); gender = (String) toCopy.get("gender"); relationship_status = (String) toCopy.get("relationship_status"); //timezone = Long.parseLong((String) toCopy.get("timezone")); last_updated = (String) toCopy.get("last_updated"); locale = (String) toCopy.get("locale"); Hashtable l = (Hashtable) toCopy.get("location"); if (l != null) { location = new FBObject(l); } Hashtable h = (Hashtable) toCopy.get("hometown"); if (h != null) { hometown = new FBObject(h); } }
80. JarHolder#getEntries()
Project: velocity-engine
File: JarHolder.java
File: JarHolder.java
/** * @return The entries of the jar as a hashtable. */ public Hashtable getEntries() { Hashtable allEntries = new Hashtable(559); Enumeration all = theJar.entries(); while (all.hasMoreElements()) { JarEntry je = (JarEntry) all.nextElement(); // We don't map plain directory entries if (!je.isDirectory()) { allEntries.put(je.getName(), this.urlpath); } } return allEntries; }
81. XSD2JavaGenerator#generateFromXMLSchema()
Project: tuscany-sdo
File: XSD2JavaGenerator.java
File: XSD2JavaGenerator.java
/** * This method was invoked by the SDO Mojo plugin * * @param xsdFileName * @param namespace * @param targetDirectory * @param javaPackage * @param prefix * @param genOptions */ public static void generateFromXMLSchema(String xsdFileName, String namespace, String targetDirectory, String javaPackage, String prefix, int genOptions) { boolean allNamespaces = false; // Need to process the passed-in schemaNamespace value from Mojo plugin the same as the command line if ("all".equalsIgnoreCase(namespace)) { namespace = null; allNamespaces = true; } EPackage.Registry packageRegistry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE); ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(packageRegistry); String packageURI = getSchemaNamespace(xsdFileName); Hashtable packageInfoTable = createPackageInfoTable(packageURI, namespace, javaPackage, prefix, null); generateFromXMLSchema(xsdFileName, packageRegistry, extendedMetaData, targetDirectory, packageInfoTable, genOptions, null, allNamespaces); }
82. LdapContextSourceTest#testGetAnonymousEnvWhenCacheIsOff()
Project: spring-ldap
File: LdapContextSourceTest.java
File: LdapContextSourceTest.java
@Test public void testGetAnonymousEnvWhenCacheIsOff() throws Exception { tested.setBase("dc=example,dc=se"); tested.setUrl("ldap://ldap.example.com:389"); tested.setPooled(true); tested.setUserDn("cn=Some User"); tested.setPassword("secret"); tested.setCacheEnvironmentProperties(false); tested.afterPropertiesSet(); Hashtable env = tested.getAnonymousEnv(); assertThat(env.get(Context.PROVIDER_URL)).isEqualTo("ldap://ldap.example.com:389/dc=example,dc=se"); assertThat(env.get(LdapContextSource.SUN_LDAP_POOLING_FLAG)).isEqualTo("true"); assertThat(env.get(Context.SECURITY_PRINCIPAL)).isNull(); assertThat(env.get(Context.SECURITY_CREDENTIALS)).isNull(); tested.setUrl("ldap://ldap2.example.com:389"); env = tested.getAnonymousEnv(); assertThat(env.get(Context.PROVIDER_URL)).isEqualTo("ldap://ldap2.example.com:389/dc=example,dc=se"); }
83. LdapContextSourceTest#testGetAuthenticatedEnv()
Project: spring-ldap
File: LdapContextSourceTest.java
File: LdapContextSourceTest.java
@Test public void testGetAuthenticatedEnv() throws Exception { tested.setBase("dc=example,dc=se"); tested.setUrl("ldap://ldap.example.com:389"); tested.setPooled(true); tested.setUserDn("cn=Some User"); tested.setPassword("secret"); tested.afterPropertiesSet(); Hashtable env = tested.getAuthenticatedEnv("cn=Some User", "secret"); assertThat(env.get(Context.PROVIDER_URL)).isEqualTo("ldap://ldap.example.com:389/dc=example,dc=se"); assertThat(env.get(LdapContextSource.SUN_LDAP_POOLING_FLAG)).isEqualTo("true"); assertThat(env.get(Context.SECURITY_PRINCIPAL)).isEqualTo("cn=Some User"); assertThat(env.get(Context.SECURITY_CREDENTIALS)).isEqualTo("secret"); // check that base was added to environment assertThat(env.get(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY)).isEqualTo(LdapUtils.newLdapName("dc=example,dc=se")); }
84. LdapContextSourceTest#testOldJdkWithBaseSetToEmptyPathShouldWork()
Project: spring-ldap
File: LdapContextSourceTest.java
File: LdapContextSourceTest.java
@Test public void testOldJdkWithBaseSetToEmptyPathShouldWork() throws Exception { tested = new LdapContextSource() { String getJdkVersion() { return "1.3"; } }; tested.setUrl("ldap://ldap.example.com:389"); tested.setBase(null); tested.afterPropertiesSet(); // check that base was not added to environment Hashtable env = tested.getAnonymousEnv(); assertThat(env.get(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY)).isNull(); }
85. LdapContextSourceTest#testOldJdkWithNoBaseSetShouldWork()
Project: spring-ldap
File: LdapContextSourceTest.java
File: LdapContextSourceTest.java
@Test public void testOldJdkWithNoBaseSetShouldWork() throws Exception { tested = new LdapContextSource() { String getJdkVersion() { return "1.3"; } }; tested.setUrl("ldap://ldap.example.com:389"); tested.afterPropertiesSet(); // check that base was not added to environment Hashtable env = tested.getAnonymousEnv(); assertThat(env.get(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY)).isNull(); }
86. LdapContextSourceTest#testGetAnonymousEnvWithPoolingInBaseEnvironmentAndPoolingOff()
Project: spring-ldap
File: LdapContextSourceTest.java
File: LdapContextSourceTest.java
@Test public void testGetAnonymousEnvWithPoolingInBaseEnvironmentAndPoolingOff() throws Exception { tested.setUrl("ldap://ldap.example.com:389"); HashMap map = new HashMap(); map.put(LdapContextSource.SUN_LDAP_POOLING_FLAG, "true"); tested.setBaseEnvironmentProperties(map); tested.setPooled(false); tested.afterPropertiesSet(); Hashtable env = tested.getAnonymousEnv(); assertThat(env.get(Context.PROVIDER_URL)).isEqualTo("ldap://ldap.example.com:389"); assertThat(env.get(LdapContextSource.SUN_LDAP_POOLING_FLAG)).isNull(); }
87. Activator#start()
Project: sling
File: Activator.java
File: Activator.java
/** * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) */ public void start(final BundleContext context) throws Exception { // get start level service, it's always there (required by the spec) startLevelRef = context.getServiceReference(StartLevel.class.getName()); logSupport = new LogSupport((StartLevel) context.getService(startLevelRef)); context.addBundleListener(logSupport); context.addFrameworkListener(logSupport); context.addServiceListener(logSupport); LogServiceFactory lsf = new LogServiceFactory(logSupport); Dictionary<String, String> props = new Hashtable<String, String>(); props.put(Constants.SERVICE_PID, lsf.getClass().getName()); props.put(Constants.SERVICE_DESCRIPTION, "Apache Sling LogService implementation"); props.put(Constants.SERVICE_VENDOR, VENDOR); context.registerService(LogService.class.getName(), lsf, props); LogReaderServiceFactory lrsf = new LogReaderServiceFactory(logSupport); props = new Hashtable<String, String>(); props.put(Constants.SERVICE_PID, lrsf.getClass().getName()); props.put(Constants.SERVICE_DESCRIPTION, "Apache Sling LogReaderService implementation"); props.put(Constants.SERVICE_VENDOR, VENDOR); context.registerService(LogReaderService.class.getName(), lrsf, props); }
88. ITConfigAdminSupport#testChangeGlobalConfig()
Project: sling
File: ITConfigAdminSupport.java
File: ITConfigAdminSupport.java
@Test public void testChangeGlobalConfig() throws Exception { // Set log level to debug for Root logger Configuration config = ca.getConfiguration(PID, null); Dictionary<String, Object> p = new Hashtable<String, Object>(); p.put(LOG_LEVEL, "DEBUG"); config.update(p); delay(); assertTrue(LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME).isDebugEnabled()); // Reset back to Info config = ca.getConfiguration(PID, null); p = new Hashtable<String, Object>(); p.put(LOG_LEVEL, "INFO"); config.update(p); delay(); assertTrue(LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME).isInfoEnabled()); assertFalse(LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME).isDebugEnabled()); }
89. JndiTemplate#createInitialContext()
Project: shiro
File: JndiTemplate.java
File: JndiTemplate.java
/** * Create a new JNDI initial context. Invoked by {@link #execute}. * <p>The default implementation use this template's environment settings. * Can be subclassed for custom contexts, e.g. for testing. * * @return the initial Context instance * @throws NamingException in case of initialization errors */ @SuppressWarnings({ "unchecked" }) protected Context createInitialContext() throws NamingException { Properties env = getEnvironment(); Hashtable icEnv = null; if (env != null) { icEnv = new Hashtable(env.size()); for (Enumeration en = env.propertyNames(); en.hasMoreElements(); ) { String key = (String) en.nextElement(); icEnv.put(key, env.getProperty(key)); } } return new InitialContext(icEnv); }
90. MemberResolver#getInvalidNames()
Project: scouter
File: MemberResolver.java
File: MemberResolver.java
private Hashtable getInvalidNames() { Hashtable ht = invalidNames; if (ht == null) { synchronized (MemberResolver.class) { WeakReference ref = (WeakReference) invalidNamesMap.get(classPool); if (ref != null) ht = (Hashtable) ref.get(); if (ht == null) { ht = new Hashtable(); invalidNamesMap.put(classPool, new WeakReference(ht)); } } invalidNames = ht; } return ht; }
91. ExifRewriteTest#makeFieldMap()
Project: sanselan
File: ExifRewriteTest.java
File: ExifRewriteTest.java
private Hashtable makeFieldMap(List items) { Hashtable fieldMap = new Hashtable(); for (int i = 0; i < items.size(); i++) { TiffImageMetadata.Item item = (TiffImageMetadata.Item) items.get(i); TiffField field = item.getTiffField(); Object key = new Integer(field.tag); if (!fieldMap.containsKey(key)) fieldMap.put(key, field); } return fieldMap; }
92. JITBenchmark#hashtable()
Project: pluotsorbet
File: JITBenchmark.java
File: JITBenchmark.java
public static void hashtable() { int count = size * 2; Hashtable hash = new Hashtable(); Object o = new Object(); String[] names = { "hello", "world", "hello1", "world2", "hello3", "world4", "hello5", "world6" }; for (int i = 0; i < count; i++) { String name = names[i % names.length]; hash.put(name, o); hash.get(name); hash.put(name, o); hash.get(name); hash.put(name, o); hash.get(name); hash.put(name, o); hash.get(name); } }
93. ScriptValuesHelp#buildFunctionList()
Project: pentaho-kettle
File: ScriptValuesHelp.java
File: ScriptValuesHelp.java
private static void buildFunctionList() { hatFunctionsList = new Hashtable<String, String>(); NodeList nlFunctions = dom.getElementsByTagName("jsFunction"); for (int i = 0; i < nlFunctions.getLength(); i++) { String strFunctionName = nlFunctions.item(i).getAttributes().getNamedItem("name").getNodeValue(); Node elType = ((Element) nlFunctions.item(i)).getElementsByTagName("type").item(0); String strType = ""; if (elType.hasChildNodes()) { strType = elType.getFirstChild().getNodeValue(); } NodeList nlFunctionArgs = ((Element) nlFunctions.item(i)).getElementsByTagName("argument"); for (int j = 0; j < nlFunctionArgs.getLength(); j++) { String strFunctionArgs = nlFunctionArgs.item(j).getFirstChild().getNodeValue(); hatFunctionsList.put(strFunctionName + "(" + strFunctionArgs + ")", strType); } if (nlFunctionArgs.getLength() == 0) { hatFunctionsList.put(strFunctionName + "()", strType); } } }
94. ScriptHelp#buildFunctionList()
Project: pentaho-kettle
File: ScriptHelp.java
File: ScriptHelp.java
private static void buildFunctionList() { hatFunctionsList = new Hashtable<String, String>(); NodeList nlFunctions = dom.getElementsByTagName("jsFunction"); for (int i = 0; i < nlFunctions.getLength(); i++) { String strFunctionName = nlFunctions.item(i).getAttributes().getNamedItem("name").getNodeValue(); Node elType = ((Element) nlFunctions.item(i)).getElementsByTagName("type").item(0); String strType = ""; if (elType.hasChildNodes()) { strType = elType.getFirstChild().getNodeValue(); } NodeList nlFunctionArgs = ((Element) nlFunctions.item(i)).getElementsByTagName("argument"); for (int j = 0; j < nlFunctionArgs.getLength(); j++) { String strFunctionArgs = nlFunctionArgs.item(j).getFirstChild().getNodeValue(); hatFunctionsList.put(strFunctionName + "(" + strFunctionArgs + ")", strType); } if (nlFunctionArgs.getLength() == 0) { hatFunctionsList.put(strFunctionName + "()", strType); } } }
95. PropsUI#loadScreens()
Project: pentaho-kettle
File: PropsUI.java
File: PropsUI.java
public void loadScreens() { screens = new Hashtable<String, WindowProperty>(); int nr = 1; String name = properties.getProperty("ScreenName" + nr); while (name != null) { boolean max = YES.equalsIgnoreCase(properties.getProperty(STRING_SIZE_MAX + nr)); int x = Const.toInt(properties.getProperty(STRING_SIZE_X + nr), 0); int y = Const.toInt(properties.getProperty(STRING_SIZE_Y + nr), 0); int w = Const.toInt(properties.getProperty(STRING_SIZE_W + nr), 320); int h = Const.toInt(properties.getProperty(STRING_SIZE_H + nr), 200); WindowProperty winprop = new WindowProperty(name, max, x, y, w, h); screens.put(name, winprop); nr++; name = properties.getProperty("ScreenName" + nr); } }
96. ScriptableObject#associateValue()
Project: pad
File: ScriptableObject.java
File: ScriptableObject.java
/** * Associate arbitrary application-specific value with this object. * Value can only be associated with the given object and key only once. * The method ignores any subsequent attempts to change the already * associated value. * <p> The associated values are not serialized. * @param key key object to select particular value. * @param value the value to associate * @return the passed value if the method is called first time for the * given key or old value for any subsequent calls. * @see #getAssociatedValue(Object key) */ public final Object associateValue(Object key, Object value) { if (value == null) throw new IllegalArgumentException(); Hashtable h = associatedValues; if (h == null) { synchronized (this) { h = associatedValues; if (h == null) { h = new Hashtable(); associatedValues = h; } } } return Kit.initHash(h, key, value); }
97. EnvClone#main()
Project: openjdk
File: EnvClone.java
File: EnvClone.java
public static void main(String[] args) throws Exception { Hashtable env = new Hashtable(5); EnvClone ctx = new EnvClone(env); if (env == ctx.myProps) { throw new Exception("Test failed: constructor didn't clone environment"); } ctx = new EnvClone(true); ctx.init(env); if (env != ctx.myProps) { throw new Exception("Test failed: init() cloned environment"); } }
98. BasicTreeUI#prepareForUIInstall()
Project: openjdk
File: BasicTreeUI.java
File: BasicTreeUI.java
/** * Invoked after the {@code tree} instance variable has been * set, but before any defaults/listeners have been installed. */ protected void prepareForUIInstall() { drawingCache = new Hashtable<TreePath, Boolean>(7); // Data member initializations leftToRight = BasicGraphicsUtils.isLeftToRight(tree); stopEditingInCompleteEditing = true; lastSelectedRow = -1; leadRow = -1; preferredSize = new Dimension(); largeModel = tree.isLargeModel(); if (getRowHeight() <= 0) largeModel = false; setModel(tree.getModel()); }
99. SchemaParser#initPatternTable()
Project: openjdk
File: SchemaParser.java
File: SchemaParser.java
private void initPatternTable() { patternTable = new Hashtable(); patternTable.put("zeroOrMore", new ZeroOrMoreState()); patternTable.put("oneOrMore", new OneOrMoreState()); patternTable.put("optional", new OptionalState()); patternTable.put("list", new ListState()); patternTable.put("choice", new ChoiceState()); patternTable.put("interleave", new InterleaveState()); patternTable.put("group", new GroupState()); patternTable.put("mixed", new MixedState()); patternTable.put("element", new ElementState()); patternTable.put("attribute", new AttributeState()); patternTable.put("empty", new EmptyState()); patternTable.put("text", new TextState()); patternTable.put("value", new ValueState()); patternTable.put("data", new DataState()); patternTable.put("notAllowed", new NotAllowedState()); patternTable.put("grammar", new GrammarState()); patternTable.put("ref", new RefState()); patternTable.put("parentRef", new ParentRefState()); patternTable.put("externalRef", new ExternalRefState()); }
100. ValueType#getPersistentFields()
Project: openjdk
File: ValueType.java
File: ValueType.java
/** * Get the names and types of all the persistent fields of a Class. */ private Hashtable getPersistentFields(Class clz) { Hashtable result = new Hashtable(); ObjectStreamClass osc = ObjectStreamClass.lookup(clz); if (osc != null) { ObjectStreamField[] fields = osc.getFields(); for (int i = 0; i < fields.length; i++) { String typeSig; String typePrefix = String.valueOf(fields[i].getTypeCode()); if (fields[i].isPrimitive()) { typeSig = typePrefix; } else { if (fields[i].getTypeCode() == '[') { typePrefix = ""; } typeSig = typePrefix + fields[i].getType().getName().replace('.', '/'); if (typeSig.endsWith(";")) { typeSig = typeSig.substring(0, typeSig.length() - 1); } } result.put(fields[i].getName(), typeSig); } } return result; }