List of usage examples for java.util Collections enumeration
public static <T> Enumeration<T> enumeration(final Collection<T> c)
From source file:org.apache.beehive.netui.pageflow.AutoRegisterActionServlet.java
public Enumeration getInitParameterNames() { if (getServletConfig() == null) { assert _configParams != null; // see comments on writeObject return Collections.enumeration(_configParams.keySet()); }//w w w . jav a 2s . c om return super.getInitParameterNames(); }
From source file:com.netxforge.oss2.xml.event.Event.java
/** * Method enumerateAutoaction.// w w w.jav a 2 s .c o m * * @return an Enumeration over all possible elements of this collection */ public Enumeration<Autoaction> enumerateAutoaction() { return Collections.enumeration(_autoactionList); }
From source file:com.adobe.acs.commons.http.headers.impl.AbstractDispatcherCacheHeaderFilterTest.java
@Test public void testMultipleFilters() throws Exception { agents.add(AbstractDispatcherCacheHeaderFilter.DISPATCHER_AGENT_HEADER_VALUE); when(request.getHeaders(AbstractDispatcherCacheHeaderFilter.SERVER_AGENT_NAME)) .thenAnswer(i -> Collections.enumeration(agents)); filter.doFilter(request, response, chain); filter.doFilter(request, response, chain); verify(response, times(1)).addHeader(headerName, headerValue); }
From source file:org.exist.util.io.FastByteArrayOutputStream.java
/** * Gets the current contents of this byte stream as a Input Stream. The * returned stream is backed by buffers of <code>this</code> stream, * avoiding memory allocation and copy, thus saving space and time.<br> * * @return the current contents of this output stream. * @see java.io.ByteArrayOutputStream#toByteArray() * @see #reset()/*from w ww. j ava2 s . co m*/ * @since 2.5 */ public /*synchronized*/ InputStream toInputStream() { int remaining = count; if (remaining == 0) { return new ClosedInputStream(); } final List<ByteArrayInputStream> list = new ArrayList<>(buffers.size()); for (final byte[] buf : buffers) { final int c = Math.min(buf.length, remaining); list.add(new ByteArrayInputStream(buf, 0, c)); remaining -= c; if (remaining == 0) { break; } } reuseBuffers = false; return new SequenceInputStream(Collections.enumeration(list)); }
From source file:com.seeburger.vfs2.util.VFSClassLoader.java
/** * Returns an Enumeration of all the resources in the search path * with the specified name./*from w w w.ja v a 2 s . c o m*/ * @param name The resources to find. * @return An Enumeration of the resources associated with the name. */ @Override protected Enumeration<URL> findResources(final String name) throws IOException { ArrayList<URL> result = new ArrayList<URL>(2); final Iterator<FileObject> it = resources.iterator(); while (it.hasNext()) { final FileObject baseFile = it.next(); final FileObject file = baseFile.resolveFile(name, NameScope.DESCENDENT_OR_SELF); if (file.exists()) { result.add(new Resource(name, baseFile, file).getURL()); } } return Collections.enumeration(result); }
From source file:org.dspace.handle.MultiRemoteDSpaceRepositoryHandlePlugin.java
/** * Return all handles in local storage which start with the naming authority * handle.//w w w . j a v a 2s . com * * @param theNAHandle * byte array representation of naming authority handle * @return All handles in local storage which start with the naming * authority handle. * @exception HandleException * If an error occurs while calling the Handle API. */ public Enumeration getHandlesForNA(byte[] theNAHandle) throws HandleException { String naHandle = Util.decodeString(theNAHandle); if (log.isInfoEnabled()) { log.info("Called getHandlesForNA for NA " + naHandle); } List<String> handles = getRemoteDSpaceHandles(naHandle); List<byte[]> results = new LinkedList<byte[]>(); for (String handle : handles) { // Transforms to byte array results.add(Util.encodeString(handle)); } return Collections.enumeration(results); }
From source file:org.apache.axis2.classloader.MultiParentClassLoader.java
public Enumeration findResources(String name) throws IOException { if (isDestroyed()) { return Collections.enumeration(Collections.EMPTY_SET); }/* ww w.ja v a2 s .c om*/ List resources = new ArrayList(); // // if we are using inverse class loading, add the resources from local urls first // if (inverseClassLoading && !isDestroyed()) { List myResources = Collections.list(super.findResources(name)); resources.addAll(myResources); } // // Add parent resources // for (int i = 0; i < parents.length; i++) { ClassLoader parent = parents[i]; List parentResources = Collections.list(parent.getResources(name)); resources.addAll(parentResources); } // // if we are not using inverse class loading, add the resources from local urls now // if (!inverseClassLoading && !isDestroyed()) { List myResources = Collections.list(super.findResources(name)); resources.addAll(myResources); } return Collections.enumeration(resources); }
From source file:com.netxforge.oss2.xml.event.Event.java
/** * Method enumerateForward./*from w w w .j ava 2 s. c om*/ * * @return an Enumeration over all possible elements of this collection */ public Enumeration<Forward> enumerateForward() { return Collections.enumeration(_forwardList); }
From source file:org.wso2.carbon.identity.oauth.endpoint.token.OAuth2TokenEndpointTest.java
@Test(dataProvider = "testIssueAccessTokenDataProvider", groups = "testWithConnection") public void testIssueAccessToken(String clientId, String authzHeader, Object paramMapObj, String grantType, String idToken, Object headerObj, Object customResponseParamObj, Exception e, int expectedStatus, String expectedErrorCode) throws Exception { MultivaluedMap<String, String> paramMap = (MultivaluedMap<String, String>) paramMapObj; ResponseHeader[] responseHeaders = (ResponseHeader[]) headerObj; Map<String, String> customResponseParameters = (Map<String, String>) customResponseParamObj; Map<String, String[]> requestParams = new HashMap<>(); if (clientId != null) { requestParams.put(OAuth.OAUTH_CLIENT_ID, clientId.split(",")); }/*w ww . j av a 2s . c om*/ requestParams.put(OAuth.OAUTH_GRANT_TYPE, new String[] { grantType }); requestParams.put(OAuth.OAUTH_SCOPE, new String[] { "scope1" }); requestParams.put(OAuth.OAUTH_REDIRECT_URI, new String[] { APP_REDIRECT_URL }); requestParams.put(OAuth.OAUTH_USERNAME, new String[] { USERNAME }); requestParams.put(OAuth.OAUTH_PASSWORD, new String[] { "password" }); HttpServletRequest request = mockHttpRequest(requestParams, new HashMap<String, Object>()); when(request.getHeader(OAuthConstants.HTTP_REQ_HEADER_AUTHZ)).thenReturn(authzHeader); when(request.getHeaderNames()).thenReturn(Collections.enumeration(new ArrayList<String>() { { add(OAuthConstants.HTTP_REQ_HEADER_AUTHZ); } })); spy(EndpointUtil.class); doReturn(REALM).when(EndpointUtil.class, "getRealmInfo"); doReturn(oAuth2Service).when(EndpointUtil.class, "getOAuth2Service"); when(oAuth2Service.issueAccessToken(any(OAuth2AccessTokenReqDTO.class))) .thenReturn(oAuth2AccessTokenRespDTO); when(oAuth2AccessTokenRespDTO.getAccessToken()).thenReturn(ACCESS_TOKEN); when(oAuth2AccessTokenRespDTO.getRefreshToken()).thenReturn(REFRESH_TOKEN); when(oAuth2AccessTokenRespDTO.getExpiresIn()).thenReturn(3600L); when(oAuth2AccessTokenRespDTO.getAuthorizedScopes()).thenReturn("scope1"); when(oAuth2AccessTokenRespDTO.getIDToken()).thenReturn(idToken); when(oAuth2AccessTokenRespDTO.getResponseHeaders()).thenReturn(responseHeaders); when(oAuth2AccessTokenRespDTO.getParameters()).thenReturn(customResponseParameters); mockOAuthServerConfiguration(); mockStatic(IdentityDatabaseUtil.class); when(IdentityDatabaseUtil.getDBConnection()).thenReturn(connection); Map<String, Class<? extends OAuthValidator<HttpServletRequest>>> grantTypeValidators = new Hashtable<>(); grantTypeValidators.put(GrantType.PASSWORD.toString(), PasswordValidator.class); when(oAuthServerConfiguration.getSupportedGrantTypeValidators()).thenReturn(grantTypeValidators); when(oAuth2Service.getOauthApplicationState(CLIENT_ID_VALUE)).thenReturn("ACTIVE"); Response response; try { response = oAuth2TokenEndpoint.issueAccessToken(request, paramMap); } catch (InvalidRequestParentException ire) { InvalidRequestExceptionMapper invalidRequestExceptionMapper = new InvalidRequestExceptionMapper(); response = invalidRequestExceptionMapper.toResponse(ire); } assertNotNull(response, "Token response is null"); assertEquals(response.getStatus(), expectedStatus, "Unexpected HTTP response status"); assertNotNull(response.getEntity(), "Response entity is null"); final String responseBody = response.getEntity().toString(); if (customResponseParameters != null) { customResponseParameters .forEach((key, value) -> assertTrue(responseBody.contains(key) && responseBody.contains(value), "Expected custom response parameter: " + key + " not found in token response.")); } if (expectedErrorCode != null) { assertTrue(responseBody.contains(expectedErrorCode), "Expected error code not found"); } else if (HttpServletResponse.SC_OK == expectedStatus) { assertTrue(responseBody.contains(ACCESS_TOKEN), "Successful response should contain access token"); } }
From source file:com.netxforge.oss2.xml.event.Event.java
/** * Method enumerateLoggroup.//w w w .j a v a 2 s.c o m * * @return an Enumeration over all possible elements of this collection */ public Enumeration<String> enumerateLoggroup() { return Collections.enumeration(_loggroupList); }