List of usage examples for org.apache.commons.collections4.iterators IteratorEnumeration IteratorEnumeration
public IteratorEnumeration(final Iterator<? extends E> iterator)
IteratorEnumeration
that will use the given iterator. From source file:de.micromata.genome.test.web.SimServletConfig.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public Enumeration getInitParameterNames() { return new IteratorEnumeration(initParameter.keySet().iterator()); }
From source file:de.micromata.genome.tpsb.httpmockup.MockServletConfig.java
@Override @SuppressWarnings("unchecked") public Enumeration getInitParameterNames() { return new IteratorEnumeration(initParameters.keySet().iterator()); }
From source file:de.micromata.genome.util.i18n.I18NTranslationProviderImpl.java
@Override public Enumeration<String> getKeys() { return new IteratorEnumeration<String>(keySet().iterator()); }
From source file:de.micromata.genome.gwiki.web.StandaloneHttpSession.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public Enumeration getAttributeNames() { return new IteratorEnumeration(sessionAttributes.keySet().iterator()); }
From source file:com.ethercis.vehr.parser.EhrScapeURIParserTest.java
@Test public void testEhrQueryParser() throws ServiceManagerException { // Request request = client.newRequest("http://" + hostname + ":8080/rest/v1/ehr?subjectId=1234&subjectNamespace=ABCDEF"); // request.method(HttpMethod.POST); HttpServletRequest request = mock(HttpServletRequest.class); when(request.getRequestURI()).thenReturn("/rest/v1/ehr"); Map<String, String[]> parameters = new HashMap<String, String[]>(); parameters.put("subjectId", new String[] { "1234" }); parameters.put("subjectNamespace", new String[] { "ABCDEF" }); when(request.getParameterMap()).thenReturn(parameters); Map<String, String[]> headers = new HashMap<String, String[]>(); headers.put("Content-Type", new String[] { "application/json" }); when(request.getHeaderNames()).thenReturn(new IteratorEnumeration<String>(headers.keySet().iterator())); when(request.getHeader("Content-Type")).thenReturn("application/json"); when(request.getMethod()).thenReturn("POST"); uriParser.parse(request);/*from w w w . j a va 2 s. c o m*/ assertEquals("POST", uriParser.identifyMethod().toUpperCase()); assertEquals("1234", uriParser.identifyParametersAsProperties().getClientProperty("subjectId").toString()); assertEquals("ABCDEF", uriParser.identifyParametersAsProperties().getClientProperty("subjectNamespace").toString()); ///ehr/{ehrId} retrieve an ehr Status from its id request = mock(HttpServletRequest.class); when(request.getRequestURI()).thenReturn("/rest/v1/ehr/8fd2bea0-9e0e-11e5-8994-feff819cdc9f"); parameters = new HashMap<>(); when(request.getParameterMap()).thenReturn(parameters); headers = new HashMap<>(); headers.put("Content-Type", new String[] { "application/json" }); when(request.getHeaderNames()).thenReturn(new IteratorEnumeration<String>(headers.keySet().iterator())); when(request.getHeader("Content-Type")).thenReturn("application/json"); when(request.getMethod()).thenReturn("GET"); uriParser.parse(request); assertEquals("GET", uriParser.identifyMethod().toUpperCase()); assertEquals("rest/v1/ehr/status", uriParser.identifyPath()); assertEquals("8fd2bea0-9e0e-11e5-8994-feff819cdc9f", uriParser.identifyParametersAsProperties().getClientProperty("ehrId").toString()); //Returns a JSON representation of the state of the EHR for a subject Id and namespace (STATUS) request = mock(HttpServletRequest.class); when(request.getRequestURI()).thenReturn("/rest/v1/ehr"); parameters = new HashMap<>(); parameters.put("subjectId", new String[] { "1234" }); parameters.put("subjectNamespace", new String[] { "ABCDEF" }); when(request.getParameterMap()).thenReturn(parameters); headers = new HashMap<>(); headers.put("Content-Type", new String[] { "application/json" }); when(request.getHeaderNames()).thenReturn(new IteratorEnumeration<String>(headers.keySet().iterator())); when(request.getHeader("Content-Type")).thenReturn("application/json"); when(request.getMethod()).thenReturn("GET"); uriParser.parse(request); assertEquals("GET", uriParser.identifyMethod().toUpperCase()); assertEquals("rest/v1/ehr/status", uriParser.identifyPath()); assertEquals("1234", uriParser.identifyParametersAsProperties().getClientProperty("subjectId").toString()); assertEquals("ABCDEF", uriParser.identifyParametersAsProperties().getClientProperty("subjectNamespace").toString()); //update the status of an EHR request = mock(HttpServletRequest.class); when(request.getRequestURI()).thenReturn("/rest/v1/ehr/status/8fd2bea0-9e0e-11e5-8994-feff819cdc9f"); parameters = new HashMap<>(); when(request.getParameterMap()).thenReturn(parameters); headers = new HashMap<>(); headers.put("Content-Type", new String[] { "application/json" }); when(request.getHeaderNames()).thenReturn(new IteratorEnumeration<String>(headers.keySet().iterator())); when(request.getHeader("Content-Type")).thenReturn("application/json"); when(request.getMethod()).thenReturn("PUT"); uriParser.parse(request); assertEquals("PUT", uriParser.identifyMethod().toUpperCase()); assertEquals("rest/v1/ehr/status", uriParser.identifyPath()); assertEquals("8fd2bea0-9e0e-11e5-8994-feff819cdc9f", uriParser.identifyParametersAsProperties().getClientProperty("ehrId").toString()); }
From source file:de.micromata.genome.gwiki.plugin.CombinedClassLoader.java
@Override public Enumeration<URL> findResources(String name) throws IOException { List<URL> res = new ArrayList<URL>(); for (ClassLoader cl : parents) { Enumeration<URL> resource = cl.getResources(name); CollectionUtils.addAll(res, resource); }//from w w w. j a va 2 s .co m return new IteratorEnumeration<URL>(res.iterator()); }
From source file:de.micromata.genome.test.web.SimServletContext.java
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public Enumeration getAttributeNames() { return new IteratorEnumeration(attributes.keySet().iterator()); }
From source file:de.micromata.genome.test.web.SimServletContext.java
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public Enumeration getInitParameterNames() { return new IteratorEnumeration(initParameters.keySet().iterator()); }
From source file:de.micromata.genome.gwiki.page.gspt.StandAlonePageContext.java
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override//from ww w . jav a 2 s . c o m public Enumeration getAttributeNamesInScope(int scope) { assertValidScope(scope, true, true); return new IteratorEnumeration(scopes.get(scope - 1).keySet().iterator()); }
From source file:com.ethercis.vehr.parser.EhrScapeURIParserTest.java
@Test public void testCompositionQueryParser() throws ServiceManagerException { // Request request = client.newRequest("http://" + hostname + ":8080/rest/v1/ehr?subjectId=1234&subjectNamespace=ABCDEF"); // request.method(HttpMethod.POST); HttpServletRequest request = mock(HttpServletRequest.class); when(request.getRequestURI()).thenReturn("/rest/v1/composition"); Map<String, String[]> parameters = new HashMap<String, String[]>(); parameters.put("format", new String[] { "RAW" }); when(request.getParameterMap()).thenReturn(parameters); Map<String, String[]> headers = new HashMap<String, String[]>(); headers.put("Content-Type", new String[] { "application/xml" }); when(request.getHeaderNames()).thenReturn(new IteratorEnumeration<String>(headers.keySet().iterator())); when(request.getHeader("Content-Type")).thenReturn("application/xml"); when(request.getMethod()).thenReturn("POST"); uriParser.parse(request);//ww w . ja v a2 s. c om assertEquals("POST", uriParser.identifyMethod().toUpperCase()); assertEquals("XML", uriParser.identifyParametersAsProperties().getClientProperty("format").toString()); request = mock(HttpServletRequest.class); when(request.getRequestURI()).thenReturn("/rest/v1/composition/123456?format=FLAT"); parameters = new HashMap<>(); parameters.put("format", new String[] { "FLAT" }); // parameters.put("templateId", new String[]{"test%20test"}); when(request.getParameterMap()).thenReturn(parameters); headers = new HashMap<>(); headers.put("Accept", new String[] { "application/json" }); when(request.getHeaderNames()).thenReturn(new IteratorEnumeration<String>(headers.keySet().iterator())); when(request.getHeader("Accept")).thenReturn("application/json"); when(request.getMethod()).thenReturn("GET"); uriParser.parse(request); assertEquals("GET", uriParser.identifyMethod().toUpperCase()); assertEquals("FLAT", uriParser.identifyParametersAsProperties().getClientProperty("format").toString()); // assertEquals("test%20test", uriParser.identifyParametersAsProperties().getClientProperty("templateId").toString()); assertEquals("123456", uriParser.identifyParametersAsProperties().getClientProperty("uid").toString()); request = mock(HttpServletRequest.class); when(request.getRequestURI()).thenReturn("/rest/v1/composition/123456?format=FLAT"); parameters = new HashMap<>(); parameters.put("format", new String[] { "FLAT" }); when(request.getParameterMap()).thenReturn(parameters); headers = new HashMap<>(); headers.put("Content-Type", new String[] { "application/json" }); when(request.getHeaderNames()).thenReturn(new IteratorEnumeration<String>(headers.keySet().iterator())); when(request.getHeader("Content-Type")).thenReturn("application/json"); when(request.getMethod()).thenReturn("PUT"); uriParser.parse(request); assertEquals("PUT", uriParser.identifyMethod().toUpperCase()); assertEquals("FLAT", uriParser.identifyParametersAsProperties().getClientProperty("format").toString()); assertEquals("123456", uriParser.identifyParametersAsProperties().getClientProperty("uid").toString()); request = mock(HttpServletRequest.class); when(request.getRequestURI()).thenReturn("/rest/v1/composition/8fd2bea0-9e0e-11e5-8994-feff819cdc9f"); parameters = new HashMap<>(); parameters.put("format", new String[] { "RAW" }); when(request.getParameterMap()).thenReturn(parameters); headers = new HashMap<>(); headers.put("Accept", new String[] { "application/xml" }); when(request.getHeaderNames()).thenReturn(new IteratorEnumeration<String>(headers.keySet().iterator())); when(request.getHeader("Accept")).thenReturn("application/xml"); when(request.getMethod()).thenReturn("GET"); uriParser.parse(request); assertEquals("GET", uriParser.identifyMethod().toUpperCase()); assertEquals("8fd2bea0-9e0e-11e5-8994-feff819cdc9f", uriParser.identifyParametersAsProperties().getClientProperty("uid").toString()); assertEquals("XML", uriParser.identifyParametersAsProperties().getClientProperty("format").toString()); request = mock(HttpServletRequest.class); when(request.getRequestURI()).thenReturn("/rest/v1/composition/8fd2bea0-9e0e-11e5-8994-feff819cdc9f"); parameters = new HashMap<>(); when(request.getParameterMap()).thenReturn(parameters); headers = new HashMap<>(); headers.put("Content-Type", new String[] { "application/json" }); when(request.getHeaderNames()).thenReturn(new IteratorEnumeration<String>(headers.keySet().iterator())); when(request.getHeader("Content-Type")).thenReturn("application/xml"); when(request.getMethod()).thenReturn("DELETE"); uriParser.parse(request); assertEquals("DELETE", uriParser.identifyMethod().toUpperCase()); assertEquals("rest/v1/composition", uriParser.identifyPath()); assertEquals("8fd2bea0-9e0e-11e5-8994-feff819cdc9f", uriParser.identifyParametersAsProperties().getClientProperty("uid").toString()); }