Example usage for java.util Collections EMPTY_MAP

List of usage examples for java.util Collections EMPTY_MAP

Introduction

In this page you can find the example usage for java.util Collections EMPTY_MAP.

Prototype

Map EMPTY_MAP

To view the source code for java.util Collections EMPTY_MAP.

Click Source Link

Document

The empty map (immutable).

Usage

From source file:fr.inria.atlanmod.neoemf.graph.blueprints.resources.BlueprintsResourceSaveTest.java

@Test
public void testSaveGraphResourceNoOption() throws IOException, ConfigurationException {
    resource.save(Collections.EMPTY_MAP);
    File configFile = new File(testFilePath + configFileName);
    assert configFile.exists() : "Config file does not exist";
    PropertiesConfiguration configuration = new PropertiesConfiguration(configFile);
    assert configuration.containsKey(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE);
    assert configuration.getString(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE)
            .equals(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE_DEFAULT);
    assert getKeyCount(configuration) == 3 : "Too much content in the .properties file";
}

From source file:org.apache.cocoon.xml.XMLBaseSupport.java

/**
 * Warning: do not forget to release the source returned by this method.
 *///from   w  w w  . j av  a 2 s  .  c  om
private Source resolve(String baseURI, String location) throws SAXException {
    try {
        Source source;
        if (baseURI != null) {
            source = resolver.resolveURI(location, baseURI, Collections.EMPTY_MAP);
        } else {
            source = resolver.resolveURI(location);
        }
        if (logger.isDebugEnabled()) {
            logger.debug("XMLBaseSupport: resolved location " + location + " against base URI " + baseURI
                    + " to " + source.getURI());
        }
        return source;
    } catch (IOException e) {
        throw new SAXException("XMLBaseSupport: problem resolving uri.", e);
    }
}

From source file:org.forgerock.openam.examples.SampleSubjectType.java

@Override
public SubjectDecision evaluate(String realm, SubjectAttributesManager mgr, Subject subject,
        String resourceName, Map<String, Set<String>> environment) throws EntitlementException {

    boolean authorized = false;

    for (Principal principal : subject.getPrincipals()) {

        String userDn = principal.getName();

        int start = userDn.indexOf('=');
        int end = userDn.indexOf(',');
        if (end <= start) {
            throw new EntitlementException(EntitlementException.CONDITION_EVALUTATION_FAILED,
                    "Name is not a valid DN: " + userDn);
        }/*from w w  w.j av  a 2 s.  c  om*/

        String userName = userDn.substring(start + 1, end);

        if (userName.equals(getName())) {
            authorized = true;
        }

    }

    return new SubjectDecision(authorized, Collections.EMPTY_MAP);
}

From source file:de.hybris.platform.commercefacades.customer.DefaultCustomerFacadeIntegrationTest.java

@Before
public void setUp() throws Exception {
    // Create data for tests
    LOG.info("Creating data for user facade..");
    userService.setCurrentUser(userService.getAdminUser());
    final long startTime = System.currentTimeMillis();
    new CoreBasicDataCreator().createEssentialData(Collections.EMPTY_MAP, null);
    // importing test csv
    importCsv("/commercefacades/test/testUserFacade.csv", "utf-8");
    commonI18NService.setCurrentLanguage(commonI18NService.getLanguage(LANG_EN));
    setCurrentUser(TEST_USER_UID);
    LOG.info("Finished data for product facade " + (System.currentTimeMillis() - startTime) + "ms");
    customerAccountService.setEventService(Mockito.mock(EventService.class));
}

From source file:com.bstek.dorado.config.definition.Definition.java

/**
 * ??<br>//  w ww .j a  v  a 2  s. c o m
 * Map?Map??<br>
 * ??????:
 * <ul>
 * <li></li>
 * <li>EL?{@link com.bstek.dorado.core.el.Expression}</li>
 * <li>?{@link com.bstek.dorado.config.definition.Definition}
 * ????</li>
 * <li>?
 * {@link com.bstek.dorado.config.definition.DefinitionReference}
 * ????</li>
 * </ul>
 */
@SuppressWarnings("unchecked")
public Map<String, Object> getProperties() {
    return (unmodifiableProperties != null) ? unmodifiableProperties : Collections.EMPTY_MAP;
}

From source file:com.adobe.ags.curly.test.ErrorBehaviorTest.java

@Test
public void testGlobalIgnore() throws IOException, ParseException {
    ApplicationState.getInstance().errorBehaviorProperty().set(ErrorBehavior.IGNORE);
    List<Action> actions = Arrays.asList(failureAction(), failureAction(), failureAction());
    ActionGroupRunner runner = new ActionGroupRunner("Global Ignore Test", ignore -> client, actions,
            Collections.EMPTY_MAP, Collections.EMPTY_SET);
    runner.run();/*from ww  w .j  a v a 2 s. c  o m*/
    assertResults(runner.getResult(), false, true);
}

From source file:com.adobe.cq.wcm.core.components.internal.resource.ImageResourceWrapperTest.java

@Test
public void isResourceTypeDelegated() {
    Resource toBeWrapped = mock(Resource.class);
    ResourceResolver resourceResolver = mock(ResourceResolver.class);
    when(toBeWrapped.getValueMap()).thenReturn(new ValueMapDecorator(Collections.EMPTY_MAP));
    when(toBeWrapped.getResourceResolver()).thenReturn(resourceResolver);
    when(resourceResolver.isResourceType(any(ImageResourceWrapper.class), any(String.class))).thenReturn(true);
    Resource wrappedResource = new ImageResourceWrapper(toBeWrapped, "a/b/c");
    assertTrue(wrappedResource.isResourceType("a/b/c"));
    verify(resourceResolver).isResourceType(wrappedResource, "a/b/c");
}

From source file:org.apache.tapestry5.upload.internal.services.MultipartDecoderImplTest.java

@Test
public void non_file_items_with_null_request_encoding() throws Exception {
    HttpServletRequest request = mockHttpServletRequest();
    expect(request.getParameterMap()).andReturn(Collections.EMPTY_MAP);

    MultipartDecoderImpl decoder = new MultipartDecoderImpl(fileItemFactory, -1, -1, CHARSET);

    List<FileItem> fileItems = Arrays.asList(createValueItem("one", "first"), createValueItem("two", "second"));

    replay();/*from   w w  w.j  ava2s.c om*/

    HttpServletRequest decodedRequest = decoder.processFileItems(request, fileItems);

    assertNotSame(decodedRequest, request);

    assertEquals(decodedRequest.getParameter("one"), "first");
    assertEquals(decodedRequest.getParameter("two"), "second");

    verify();
}

From source file:com.redhat.rhn.frontend.taglibs.list.helper.ListSessionSetHelper.java

/**
 * Creates a new <code>ListSessionSetHelper</code> that will attempt to generate
 * its own unique name for the set. This call is suitable when there are no request
 * parameters of interest for the page./*from  ww w.  ja va 2 s.c om*/
 *
 * @param inp listable
 * @param req the servlet request
 */
public ListSessionSetHelper(Listable inp, HttpServletRequest req) {
    this(inp, req, Collections.EMPTY_MAP);
}

From source file:org.apache.sling.servlets.post.impl.operations.StreamingUploadOperationTest.java

@Test
public void test() throws RepositoryException, UnsupportedEncodingException {
    List<Modification> changes = new ArrayList<Modification>();
    PostResponse response = new AbstractPostResponse() {
        @Override//ww  w .ja va 2 s. c o m
        protected void doSend(HttpServletResponse response) throws IOException {

        }

        @Override
        public void onChange(String type, String... arguments) {

        }

        @Override
        public String getPath() {
            return "/test/upload/location";
        }
    };

    List<Part> partsList = new ArrayList<Part>();
    partsList.add(new MockPart("formfield1", null, null, 0,
            new ByteArrayInputStream("testformfield1".getBytes("UTF-8")), Collections.EMPTY_MAP));
    partsList.add(new MockPart("formfield2", null, null, 0,
            new ByteArrayInputStream("testformfield2".getBytes("UTF-8")), Collections.EMPTY_MAP));
    partsList.add(new MockPart("test1.txt", "text/plain", "test1bad.txt", 4,
            new ByteArrayInputStream("test".getBytes("UTF-8")), Collections.EMPTY_MAP));
    partsList.add(new MockPart("*", "text/plain2", "test2.txt", 8,
            new ByteArrayInputStream("test1234".getBytes("UTF-8")), Collections.EMPTY_MAP));
    partsList.add(new MockPart("badformfield2", null, null, 0,
            new ByteArrayInputStream("testbadformfield2".getBytes("UTF-8")), Collections.EMPTY_MAP));
    final Iterator<Part> partsIterator = partsList.iterator();
    final Map<String, Resource> repository = new HashMap<String, Resource>();
    final ResourceResolver resourceResolver = new MockResourceResolver() {
        @Override
        public Resource getResource(String path) {

            Resource resource = repository.get(path);

            if (resource == null) {
                if ("/test/upload/location".equals(path)) {
                    resource = new MockRealResource(this, path, "sling:Folder");
                    repository.put(path, resource);
                    LOG.debug("Created {} ", path);

                }
            }
            LOG.debug("Resource {} is {} {}", path, resource, ResourceUtil.isSyntheticResource(resource));
            return resource;
        }

        @Override
        public Iterable<Resource> getChildren(Resource resource) {
            return null;
        }

        @Override
        public void delete(Resource resource) throws PersistenceException {

        }

        @Override
        public Resource create(Resource resource, String s, Map<String, Object> map)
                throws PersistenceException {
            Resource childResource = resource.getChild(s);
            if (childResource != null) {
                throw new IllegalArgumentException("Child " + s + " already exists ");
            }
            Resource newResource = new MockRealResource(this, resource.getPath() + "/" + s,
                    (String) map.get("sling:resourceType"), map);
            repository.put(newResource.getPath(), newResource);
            return newResource;
        }

        @Override
        public void revert() {

        }

        @Override
        public void commit() throws PersistenceException {
            LOG.debug("Committing");
            for (Map.Entry<String, Resource> e : repository.entrySet()) {
                LOG.debug("Committing {} ", e.getKey());
                Resource r = e.getValue();
                ModifiableValueMap vm = r.adaptTo(ModifiableValueMap.class);
                for (Map.Entry<String, Object> me : vm.entrySet()) {
                    if (me.getValue() instanceof InputStream) {
                        try {
                            String value = IOUtils.toString((InputStream) me.getValue());
                            LOG.debug("Converted {} {}  ", me.getKey(), value);
                            vm.put(me.getKey(), value);

                        } catch (IOException e1) {
                            throw new PersistenceException("Failed to commit input stream", e1);
                        }
                    }
                }
                LOG.debug("Converted {} ", vm);
            }
            LOG.debug("Committted {} ", repository);

        }

        @Override
        public boolean hasChanges() {
            return false;
        }
    };

    SlingHttpServletRequest request = new MockSlingHttpServlet3Request(null, null, null, null, null) {
        @Override
        public Object getAttribute(String name) {
            if ("request-parts-iterator".equals(name)) {
                return partsIterator;
            }
            return super.getAttribute(name);
        }

        @Override
        public ResourceResolver getResourceResolver() {
            return resourceResolver;
        }
    };
    streamedUplodOperation.doRun(request, response, changes);

    {
        Resource r = repository.get("/test/upload/location/test1.txt");
        Assert.assertNotNull(r);
        ValueMap m = r.adaptTo(ValueMap.class);
        Assert.assertNotNull(m);

        Assert.assertEquals("nt:file", m.get("jcr:primaryType"));

    }
    {
        Resource r = repository.get("/test/upload/location/test1.txt/jcr:content");
        Assert.assertNotNull(r);
        ValueMap m = r.adaptTo(ValueMap.class);
        Assert.assertNotNull(m);

        Assert.assertEquals("nt:resource", m.get("jcr:primaryType"));
        Assert.assertTrue(m.get("jcr:lastModified") instanceof Calendar);
        Assert.assertEquals("text/plain", m.get("jcr:mimeType"));
        Assert.assertEquals("test", m.get("jcr:data"));

    }
    {
        Resource r = repository.get("/test/upload/location/test2.txt");
        Assert.assertNotNull(r);
        ValueMap m = r.adaptTo(ValueMap.class);
        Assert.assertNotNull(m);

        Assert.assertEquals("nt:file", m.get("jcr:primaryType"));

    }
    {
        Resource r = repository.get("/test/upload/location/test2.txt/jcr:content");
        Assert.assertNotNull(r);
        ValueMap m = r.adaptTo(ValueMap.class);
        Assert.assertNotNull(m);

        Assert.assertEquals("nt:resource", m.get("jcr:primaryType"));
        Assert.assertTrue(m.get("jcr:lastModified") instanceof Calendar);
        Assert.assertEquals("text/plain2", m.get("jcr:mimeType"));
        Assert.assertEquals("test1234", m.get("jcr:data"));
    }

}