private static void assertArrayContainingElements(final String[] result) { assertThat(result, arrayContainingInAnyOrder("1", "1001")); }
private static void assertArrayContainingElements(final Integer[] result) { assertThat(result, arrayContainingInAnyOrder(1, 1001)); }
private static void assertArrayContainingElements(final Integer[] result) { assertThat(result, arrayContainingInAnyOrder(1, 1001)); }
@Test public void cleanDirWithAllows() throws IOException { runBuild(mkdirs("bar/foo/baz"), Passed); runBuild(mkdirs("bar/foo2"), Passed); assertTrue(new File(sandbox, "bar/foo/file1").createNewFile()); assertTrue(new File(sandbox, "bar/file2").createNewFile()); assertTrue(new File(sandbox, "file3").createNewFile()); runBuild(cleandir("bar", "file2", "foo2"), Passed); assertThat(new File(sandbox, "bar").isDirectory(), is(true)); assertThat(new File(sandbox, "file3").exists(), is(true)); assertThat(new File(sandbox, "bar").listFiles(), arrayContainingInAnyOrder(new File(sandbox, "bar/file2"), new File(sandbox, "bar/foo2"))); }
@Test public void cleanDirWithAllowsAndWorkingDir() throws IOException { runBuild(mkdirs("bar/foo/baz"), Passed); runBuild(mkdirs("bar/foo2"), Passed); assertTrue(new File(sandbox, "bar/foo/file1").createNewFile()); assertTrue(new File(sandbox, "bar/file2").createNewFile()); assertTrue(new File(sandbox, "file3").createNewFile()); runBuild(cleandir("", "file2", "foo2").setWorkingDirectory("bar"), Passed); assertThat(new File(sandbox, "bar").isDirectory(), is(true)); assertThat(new File(sandbox, "file3").exists(), is(true)); assertThat(new File(sandbox, "bar").listFiles(), arrayContainingInAnyOrder(new File(sandbox, "bar/file2"), new File(sandbox, "bar/foo2"))); }
@Test public void testLdapScopes() throws Exception { assumeTrue(ldapGroup.equals("ldap-groups-as-scopes.xml")); AuthenticationManager manager = (AuthenticationManager)getBean("ldapAuthenticationManager"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("marissa3","ldap3"); Authentication auth = manager.authenticate(token); assertNotNull(auth); String[] list = new String[]{ "uaa.admin", "cloud_controller.read", "thirdmarissa" }; assertThat(list, arrayContainingInAnyOrder(getAuthorities(auth.getAuthorities()))); }
@Test public void getAttributeNames() { this.simpAttributes.setAttribute("name1", "value1"); this.simpAttributes.setAttribute("name2", "value1"); this.simpAttributes.setAttribute("name3", "value1"); assertThat(this.simpAttributes.getAttributeNames(), arrayContainingInAnyOrder("name1", "name2", "name3")); }
@Test public void shouldLeaveTheDefaultCipherSuiteInclusionAndExclusionListUnTouchedIfNotOverridden() { when(goSSLConfig.getCipherSuitesToBeIncluded()).thenReturn(null); when(goSSLConfig.getCipherSuitesToBeExcluded()).thenReturn(null); sslSocketConnector = new GoSslSocketConnector(jettyServer, "password", systemEnvironment, goSSLConfig); ServerConnector connector = (ServerConnector) sslSocketConnector.getConnector(); Collection<ConnectionFactory> connectionFactories = connector.getConnectionFactories(); SslContextFactory sslContextFactory = findSslContextFactory(connectionFactories); assertThat(sslContextFactory.getExcludeCipherSuites(), is(arrayWithSize(5))); assertThat(sslContextFactory.getExcludeCipherSuites(), is(arrayContainingInAnyOrder("^.*_(MD5|SHA|SHA1)$", "^TLS_RSA_.*$", "^SSL_.*$", "^.*_NULL_.*$", "^.*_anon_.*$"))); assertThat(sslContextFactory.getIncludeCipherSuites(), is(emptyArray())); }
@Theory public void theoryDirectoriesHaveFileWithSameNamedChildren(String path) throws Exception { Resource res = getResource(path); assumeThat(res, is(directory())); File dir = res.dir(); Collection<Resource> resChildren = res.list(); String[] fileChildrenNames = dir.list(); String[] resChildrenNames = new String[resChildren.size()]; int i = 0; for (Resource child : resChildren) { resChildrenNames[i] = child.name(); i++; } assertThat(fileChildrenNames, arrayContainingInAnyOrder(resChildrenNames)); }
@Test public void toObjectArrayCopiesElementsIntoNewArrayIncludingMissingValue() { addTwoElements(testSet); testSet.add(MISSING_VALUE); final Object[] result = testSet.toArray(); assertThat(result, arrayContainingInAnyOrder(1, 1001, MISSING_VALUE)); }
@Test @SuppressWarnings("ToArrayCallWithZeroLengthArrayArgument") public void toArrayCopiesElementsIntoNewArrayIncludingMissingValue() { addTwoElements(testSet); testSet.add(MISSING_VALUE); final Integer[] result = testSet.toArray(new Integer[testSet.size()]); assertThat(result, arrayContainingInAnyOrder(1, 1001, MISSING_VALUE)); }
@SuppressWarnings("unchecked") @Test public void testFindTwoInContext() { CacheProvider testCacheProvider1 = addMockProvider("testCacheProvider1"); CacheProvider testCacheProvider2 = addMockProvider("testCacheProvider2"); replay(testCacheProvider1, testCacheProvider2); CacheProvider provider = DefaultCacheProvider.findProvider(); assertThat( provider, anyOf(sameInstance(testCacheProvider1), sameInstance(testCacheProvider2))); String providerName = "testCacheProvider2"; if (provider == testCacheProvider1) { providerName = "testCacheProvider1"; } logging.assertLogged( allOf( hasProperty("level", is(Level.WARNING)), hasProperty( "parameters", arrayContainingInAnyOrder( // Name of the provider being used equalTo(providerName), // Available providers anyOf( equalTo("testCacheProvider1, testCacheProvider2"), equalTo("testCacheProvider2, testCacheProvider1")), // The system property to override equalTo("GEOSERVER_DEFAULT_CACHE_PROVIDER"))))); verify(testCacheProvider1, testCacheProvider2); }
@Test public void testApplyArrayValues() throws Exception { Settings settings = new TestSettings(); settings.asProperties().put("es.net.http.header.Accept-Encoding", new Object[]{"gzip","deflate"}); Header[] headers = applyHeaders(settings); assertThat(headers, arrayWithSize(3)); assertThat(headers, arrayContainingInAnyOrder( new Header("Accept", "application/json"), new Header("Content-Type", "application/json"), new Header("Accept-Encoding", "gzip,deflate") )); }
@Test public void doNotIterateTwiceOverSameElementsWhenItsPartOfSourceAndAdded() { LongIterator source = iterator( 4L, 5L ); LongSet added = LongHashSet.newSetWith( 1L, 4L ); LongSet removed = LongHashSet.newSetWith( 3L ); LongIterator iterator = DiffApplyingPrimitiveLongIterator.augment( source, added, removed ); Long[] values = ArrayUtils.toObject( asArray( iterator ) ); assertThat( values, arrayContainingInAnyOrder( 1L, 4L, 5L ) ); assertThat( values, arrayWithSize( 3 ) ); }
@Test public void testApplyValidHeader() throws Exception { Settings settings = new TestSettings(); settings.setProperty("es.net.http.header.Max-Forwards", "10"); Header[] headers = applyHeaders(settings); assertThat(headers, arrayWithSize(3)); assertThat(headers, arrayContainingInAnyOrder( new Header("Accept", "application/json"), new Header("Content-Type", "application/json"), new Header("Max-Forwards", "10") )); }
@Test public void testApplyMultiValues() throws Exception { Settings settings = new TestSettings(); settings.setProperty("es.net.http.header.Accept-Encoding", "gzip,deflate"); Header[] headers = applyHeaders(settings); assertThat(headers, arrayWithSize(3)); assertThat(headers, arrayContainingInAnyOrder( new Header("Accept", "application/json"), new Header("Content-Type", "application/json"), new Header("Accept-Encoding", "gzip,deflate") )); } }
@Test public void defaultProtocol() throws Exception { TlsConfiguration tlsConfiguration = new TlsConfiguration(DEFAULT_KEYSTORE); tlsConfiguration.initialise(true, JSSE_NAMESPACE); SSLSocketFactory socketFactory = tlsConfiguration.getSocketFactory(); SSLServerSocketFactory serverSocketFactory = tlsConfiguration.getServerSocketFactory(); SSLContext sslContext = SSLContext.getInstance(DEFAULT_SSL_TYPE); sslContext.init(null, null, null); assertThat(socketFactory.getDefaultCipherSuites(), arrayContainingInAnyOrder(sslContext.getSocketFactory().getDefaultCipherSuites())); }
@Test public void defaultProtocolFromConfigFile() throws Exception { File configFile = createDefaultProtocolConfigFile(); try { TlsConfiguration tlsConfiguration = new TlsConfiguration(DEFAULT_KEYSTORE); tlsConfiguration.initialise(true, JSSE_NAMESPACE); SSLSocketFactory socketFactory = tlsConfiguration.getSocketFactory(); SSLServerSocketFactory serverSocketFactory = tlsConfiguration.getServerSocketFactory(); SSLContext sslContext = SSLContext.getInstance(SUPPORTED_PROTOCOL); sslContext.init(null, null, null); SSLSocketFactory protocolSocketFactory = sslContext.getSocketFactory(); SSLServerSocketFactory protocolServerSocketFactory = sslContext.getServerSocketFactory(); assertThat(socketFactory.getDefaultCipherSuites(), arrayWithSize(protocolSocketFactory.getDefaultCipherSuites().length)); assertThat(socketFactory.getDefaultCipherSuites(), is(arrayContainingInAnyOrder(protocolSocketFactory.getDefaultCipherSuites()))); assertThat(serverSocketFactory.getDefaultCipherSuites(), arrayWithSize(protocolServerSocketFactory.getDefaultCipherSuites().length)); assertThat(serverSocketFactory.getDefaultCipherSuites(), is(arrayContainingInAnyOrder(protocolServerSocketFactory.getDefaultCipherSuites()))); } finally { configFile.delete(); } }
private void assertErrorType(ParameterModel errorTypeParam, String paramName) { assertThat(errorTypeParam.getName(), is(paramName)); assertThat(errorTypeParam.getType(), is(instanceOf(DefaultStringType.class))); assertThat(errorTypeParam.getType().getAnnotation(EnumAnnotation.class).get().getValues(), arrayContainingInAnyOrder( "ANY", "REDELIVERY_EXHAUSTED", "TRANSFORMATION", "EXPRESSION", "SECURITY", "CLIENT_SECURITY", "SERVER_SECURITY", "ROUTING", "CONNECTIVITY", "RETRY_EXHAUSTED", "TIMEOUT")); assertThat(errorTypeParam.getExpressionSupport(), is(NOT_SUPPORTED)); assertThat(errorTypeParam.isRequired(), is(false)); }
@Test public void testDumpLevel2() throws Exception { // GIVEN // WHEN String s = DumperUtil.dump(node, 2); // Creation date is added automatically at the time of import so has to be excluded before comparison s = substituteJcrCreatedTimestamp(s); // THEN assertThat(s.split(separator), arrayContainingInAnyOrder(LEVEL_TWO_FRAGMENTS)); }