/** * Asserts the availability of this virtual machine implementation. * * @return This virtual machine type. */ private static Class<?> doAssertAvailability() { if (!AFUNIXSocket.isSupported()) { throw new IllegalStateException("POSIX sockets are not supported on the current system"); } else if (!System.getProperty("java.vm.name").toLowerCase(Locale.US).contains("hotspot")) { throw new IllegalStateException("Cannot apply attachment on non-Hotspot compatible VM"); } else { return OnUnix.class; } }
/** * Asserts the availability of this virtual machine implementation. If the Unix socket library is missing or * if this VM does not support Unix socket communication, a {@link Throwable} is thrown. * * @return This virtual machine type. * @throws Throwable If this VM does not support POSIX sockets or is not running on a HotSpot VM. */ public static Class<?> assertAvailability() throws Throwable { if (!AFUNIXSocket.isSupported()) { throw new IllegalStateException("POSIX sockets are not supported on the current system"); } else if (!System.getProperty("java.vm.name").toLowerCase(Locale.US).contains("hotspot")) { throw new IllegalStateException("Cannot apply attachment on non-Hotspot compatible VM"); } else { return OnUnix.class; } }
/** * Test connection factories. * * @return test data * * @throws Exception on test failure */ @DataProvider(name = "factories") @SuppressWarnings("unchecked") public Object[][] connectionFactories() throws Exception { //Make sure native libraries are loaded and supported for the current unix based operating system. AssertJUnit.assertTrue(AFUNIXSocket.isSupported()); final Map<String, Object> props = new HashMap<>(); props.put(JndiProvider.SOCKET_FACTORY, "org.ldaptive.ldapi.AFUnixSocketFactory"); final DefaultConnectionFactory nativeFactory = new DefaultConnectionFactory( new ConnectionConfig("ldap://domainsocket")); nativeFactory.getProvider().getProviderConfig().setProperties(props); final DefaultConnectionFactory localFactory = new DefaultConnectionFactory(new ConnectionConfig(ldapHost)); final SearchRequest request = new SearchRequest(ldapBaseDn, ldapSearchFilter); return new Object[][] { new Object[] {nativeFactory, request, }, new Object[] {localFactory, request, }, }; }