Example usage for java.util Map toString

List of usage examples for java.util Map toString

Introduction

In this page you can find the example usage for java.util Map toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.garethahealy.camel.file.loadbalancer.example1.routes.ReadThreeFilesWithThreeReadersTest.java

@Test
public void readThreeFilesWithThreeReaders() throws InterruptedException, MalformedURLException {
    Map<String, String> answer = getRouteToEndpointPriority();

    //Used for debugging purposes, in-case we need to know which endpoint has what priority
    LOG.info("EndpointSetup: " + answer.toString());

    MockEndpoint first = getMockEndpoint("mock:endFirst");
    first.setExpectedMessageCount(1);/*from  ww  w  .ja  v  a2 s  .  com*/
    first.setResultWaitTime(TimeUnit.SECONDS.toMillis(15));
    first.setAssertPeriod(TimeUnit.SECONDS.toMillis(1));

    MockEndpoint second = getMockEndpoint("mock:endSecond");
    second.setExpectedMessageCount(1);
    second.setResultWaitTime(TimeUnit.SECONDS.toMillis(15));
    second.setAssertPeriod(TimeUnit.SECONDS.toMillis(1));

    MockEndpoint third = getMockEndpoint("mock:endThird");
    third.setExpectedMessageCount(1);
    third.setResultWaitTime(TimeUnit.SECONDS.toMillis(15));
    third.setAssertPeriod(TimeUnit.SECONDS.toMillis(1));

    //Wait for the files to be processed
    sleep(10);

    File firstDirectory = FileUtils.toFile(new URL("file:" + rootDirectory + "/.camel0"));
    File secondDirectory = FileUtils.toFile(new URL("file:" + rootDirectory + "/.camel1"));
    File thirdDirectory = FileUtils.toFile(new URL("file:" + rootDirectory + "/.camel2"));

    Assert.assertTrue(".camel0 doesnt exist", firstDirectory.exists());
    Assert.assertTrue(".camel1 doesnt exist", secondDirectory.exists());
    Assert.assertTrue(".camel2 doesnt exist", thirdDirectory.exists());

    Collection<File> firstFiles = FileUtils.listFiles(firstDirectory, FileFilterUtils.fileFileFilter(), null);
    Collection<File> secondFiles = FileUtils.listFiles(secondDirectory, FileFilterUtils.fileFileFilter(), null);
    Collection<File> thirdFiles = FileUtils.listFiles(thirdDirectory, FileFilterUtils.fileFileFilter(), null);

    Assert.assertNotNull(firstFiles);
    Assert.assertNotNull(secondFiles);
    Assert.assertNotNull(thirdFiles);

    //Check the files are unique, and we haven't copied the same file twice
    firstFiles.removeAll(secondFiles);
    firstFiles.removeAll(thirdFiles);

    secondFiles.removeAll(firstFiles);
    secondFiles.removeAll(thirdFiles);

    thirdFiles.removeAll(firstFiles);
    thirdFiles.removeAll(secondFiles);

    //Each directory should of only copied one file
    Assert.assertEquals(new Integer(1), new Integer(firstFiles.size()));
    Assert.assertEquals(new Integer(1), new Integer(secondFiles.size()));
    Assert.assertEquals(new Integer(1), new Integer(thirdFiles.size()));

    //Assert the endpoints last, as there seems to be a strange bug where they fail but the files have been processed,
    //so that would suggest the MockEndpoints are reporting a false-positive
    first.assertIsSatisfied();
    second.assertIsSatisfied();
    third.assertIsSatisfied();
}

From source file:us.polygon4.izzymongo.service.ServiceConfig.java

public @Bean MongoTemplateContainer initialize() throws Exception {
    Map<String, MongoOperations> templateMap = new HashMap<String, MongoOperations>();
    Mongo m = mongoFactoryBean.getObject();
    for (String dbname : m.getDatabaseNames()) {
        MongoOperations mongoOps = new MongoTemplate(m, dbname);
        templateMap.put(dbname, mongoOps);
    }/* w ww  .  j  a v a  2s  .  c  o  m*/
    log.info(templateMap.toString());
    MongoTemplateContainer mtc = new MongoTemplateContainer();
    mtc.setTemplateMap(templateMap);
    return mtc;
}

From source file:org.hyperic.hq.ui.action.resource.application.inventory.AddServiceDependenciesFormPrepareAction.java

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    AddApplicationServicesForm addForm = (AddApplicationServicesForm) form;
    AppdefResourceValue resource = RequestUtils.getResource(request);
    AppdefEntityID entityId = resource.getEntityId();
    Integer sessionId = RequestUtils.getSessionId(request);
    Integer appSvcId = addForm.getAppSvcId();
    PageControl pca = RequestUtils.getPageControl(request, "psa", "pna", "soa", "sca");
    PageControl pcp = RequestUtils.getPageControl(request, "psp", "pnp", "sop", "scp");

    // pending services are those on the right side of the "add
    // to list" widget- awaiting association with the resource
    // when the form's "ok" button is clicked.
    boolean servicesArePending = false;
    if (request.getSession().getAttribute(Constants.PENDING_SVCDEPS_SES_ATTR) != null
            && ((List) request.getSession().getAttribute(Constants.PENDING_SVCDEPS_SES_ATTR)).size() > 0)
        servicesArePending = true;//from  w w  w  .j  a va2s .  c  o  m

    if (log.isTraceEnabled())
        log.trace("getting AppServices for application [" + entityId + "]");
    // get the dependency tree
    DependencyTree tree = appdefBoss.getAppDependencyTree(sessionId.intValue(), resource.getId());
    DependencyNode appSvcNode = DependencyTree.findAppServiceById(tree, appSvcId);
    List<AppdefResourceValue> services = appdefBoss.findServiceInventoryByApplication(sessionId.intValue(),
            resource.getId(), PageControl.PAGE_ALL);
    Map<AppdefEntityID, AppdefResourceValue> serviceMap = DependencyTree.mapServices(services);
    log.debug("Map contains " + serviceMap.toString());
    List<DependencyNode> availableServices = new ArrayList<DependencyNode>();
    List<DependencyNode> potentialDeps = DependencyTree.findPotentialDependees(tree, appSvcNode, services);
    log.debug("The list contains " + potentialDeps);
    for (DependencyNode candidateNode : potentialDeps) {
        availableServices.add(candidateNode);
    }

    // filter out the pending ones, if there are any
    if (servicesArePending) {

        List<String> uiPendings = SessionUtils.getListAsListStr(request.getSession(),
                Constants.PENDING_SVCDEPS_SES_ATTR);

        AppdefEntityID[] pendingServiceIds = new AppdefEntityID[uiPendings.size()];

        for (int i = 0; i < uiPendings.size(); i++) {
            StringTokenizer tok = new StringTokenizer((String) uiPendings.get(i), " ");
            if (tok.countTokens() > 1) {
                pendingServiceIds[i] = new AppdefEntityID(AppdefEntityConstants.stringToType(tok.nextToken()),
                        Integer.parseInt(tok.nextToken()));
            } else {
                pendingServiceIds[i] = new AppdefEntityID(tok.nextToken());
            }
        }

        if (log.isTraceEnabled())
            log.trace("getting pending services for application [" + entityId + "] that service [" + appSvcId
                    + "] depends on");

        List<AppdefEntityID> pendingServiceIdList = Arrays.asList(pendingServiceIds);
        PageList<AppdefResourceValue> pendingServices = new PageList<AppdefResourceValue>();
        for (int i = 0; i < pendingServiceIds.length; i++) {
            pendingServices.add(serviceMap.get(pendingServiceIds[i]));
        }

        PageList<AppdefResourceValue> pagedPendingList = new PageList<AppdefResourceValue>();
        Pager pendingPager = Pager.getDefaultPager();
        pagedPendingList = pendingPager.seek(pendingServices, pcp.getPagenum(), pcp.getPagesize());
        request.setAttribute(Constants.PENDING_SVCDEPS_REQ_ATTR, /* pendingServices */pagedPendingList);
        request.setAttribute(Constants.NUM_PENDING_SVCDEPS_REQ_ATTR, new Integer(pendingServices.size()));

        // begin filtering

        for (Iterator<DependencyNode> iter = availableServices.iterator(); iter.hasNext();) {
            DependencyNode element = iter.next();
            if (pendingServiceIdList.contains(element.getEntityId())) {
                iter.remove();
            }
        }
        // end filtering
    } else {
        // nothing is pending, so we'll initialize the attributes
        request.setAttribute(Constants.PENDING_SVCDEPS_REQ_ATTR, new ArrayList<AppdefResourceValue>());
        request.setAttribute(Constants.NUM_PENDING_SVCDEPS_REQ_ATTR, new Integer(0));
    }

    // Sort list
    Collections.sort(availableServices);

    PageList<DependencyNode> pagedAvailabileList = new PageList<DependencyNode>();
    Pager pendingPager = Pager.getDefaultPager();
    pagedAvailabileList = pendingPager.seek(availableServices, pca.getPagenum(), pca.getPagesize());
    request.setAttribute(Constants.AVAIL_SVCDEPS_REQ_ATTR, /* availableServices */pagedAvailabileList);
    request.setAttribute(Constants.NUM_AVAIL_SVCDEPS_REQ_ATTR, new Integer(availableServices.size()));

    return null;
}

From source file:edu.arizona.kra.proposaldevelopment.service.impl.PropDevRoutingStateLookupableHelperServiceImpl.java

/**
 * Method that generates the search results for the lookup framework.
 * Called by performLookup()//  ww w .ja  v  a 2 s  . c  o  m
 * 
 * @see org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl#getSearchResults(java.util.Map)
 */
@Override
public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
    LOG.debug("getSearchResults():" + fieldValues.toString());
    checkUserPermissions();

    List<ProposalDevelopmentRoutingState> results = new ArrayList<ProposalDevelopmentRoutingState>();
    try {
        results = getPropDevRoutingStateService().findPropDevRoutingState(fieldValues);
        // sort list DESC by ORDExpedited so 'Yes' rows will be shown first
        List defaultSortColumns = getDefaultSortColumns();
        if (defaultSortColumns.size() > 0) {
            Collections.sort(results,
                    Collections.reverseOrder(new BeanPropertyComparator(defaultSortColumns, true)));
        }
    } catch (Exception e) {
        e.printStackTrace();
        LOG.error(e);
    }
    return results;
}

From source file:hu.vpmedia.media.red5.dev.Application.java

@Override
public boolean roomConnect(IConnection conn, Object[] params) {
    log.info("Main.roomConnect " + conn.getClient().getId());
    //boolean accept = (Boolean)params[0];
    // if ( !accept ) rejectClient( "you passed false..." );
    // getting client parameters        
    Map properties = conn.getConnectParams();
    log.info("Connection properties " + properties.toString());
    //connection time
    Long stamp = System.currentTimeMillis();
    // client ip        
    String ip = (String) conn.getRemoteAddress();
    // agent        
    String agent = (String) properties.get("flashVer");
    // referrer        
    String referrer = (String) properties.get("swfUrl");
    // this will be our stream list        
    Object[] streamList = {};/*  w  ww .ja v a 2 s  .c om*/

    // Trigger calling of "onBWDone", required for some FLV players
    ServiceUtils.invokeOnConnection(conn, "onBWDone", new Object[] { 0, 0, 0, 0 });
    //BandwidthDetection detect = new BandwidthDetection();
    //detect.checkBandwidth(conn);
    /*
    if (conn instanceof IStreamCapableConnection) {
       IStreamCapableConnection streamConn = (IStreamCapableConnection) conn;
       SimpleConnectionBWConfig bwConfig = new SimpleConnectionBWConfig();
       bwConfig.getChannelBandwidth()[IBandwidthConfigure.OVERALL_CHANNEL] = 1024 * 1024;
       bwConfig.getChannelInitialBurst()[IBandwidthConfigure.OVERALL_CHANNEL] = 128 * 1024;
       streamConn.setBandwidthConfigure(bwConfig);
    } */
    ServiceUtils.invokeOnConnection(conn, "onRoomLogin", new Object[] { "guest" + conn.getClient().getId() });
    onUserListChange(conn);
    return super.roomConnect(conn, params);
}

From source file:com.garethahealy.camel.file.loadbalancer.example1.routes.Read99FilesWithThreeReadersTest.java

@Test
public void readThreeFilesWithThreeReaders() throws InterruptedException, MalformedURLException {
    Map<String, String> answer = getRouteToEndpointPriority();

    //Used for debugging purposes, in-case we need to know which endpoint has what priority
    LOG.info("EndpointSetup: " + answer.toString());

    MockEndpoint first = getMockEndpoint("mock:endFirst");
    first.setExpectedMessageCount(33);/*from   w w w.j  av  a  2 s . c o  m*/
    first.setResultWaitTime(TimeUnit.SECONDS.toMillis(15));
    first.setAssertPeriod(TimeUnit.SECONDS.toMillis(1));

    MockEndpoint second = getMockEndpoint("mock:endSecond");
    second.setExpectedMessageCount(33);
    second.setResultWaitTime(TimeUnit.SECONDS.toMillis(15));
    second.setAssertPeriod(TimeUnit.SECONDS.toMillis(1));

    MockEndpoint third = getMockEndpoint("mock:endThird");
    third.setExpectedMessageCount(33);
    third.setResultWaitTime(TimeUnit.SECONDS.toMillis(15));
    third.setAssertPeriod(TimeUnit.SECONDS.toMillis(1));

    //Wait for the files to be processed
    sleep(30);

    File firstDirectory = FileUtils.toFile(new URL("file:" + rootDirectory + "/.camel0"));
    File secondDirectory = FileUtils.toFile(new URL("file:" + rootDirectory + "/.camel1"));
    File thirdDirectory = FileUtils.toFile(new URL("file:" + rootDirectory + "/.camel2"));

    Assert.assertTrue(".camel0 doesnt exist", firstDirectory.exists());
    Assert.assertTrue(".camel1 doesnt exist", secondDirectory.exists());
    Assert.assertTrue(".camel2 doesnt exist", thirdDirectory.exists());

    Collection<File> firstFiles = FileUtils.listFiles(firstDirectory, FileFilterUtils.fileFileFilter(), null);
    Collection<File> secondFiles = FileUtils.listFiles(secondDirectory, FileFilterUtils.fileFileFilter(), null);
    Collection<File> thirdFiles = FileUtils.listFiles(thirdDirectory, FileFilterUtils.fileFileFilter(), null);

    Assert.assertNotNull(firstFiles);
    Assert.assertNotNull(secondFiles);
    Assert.assertNotNull(thirdFiles);

    //Check the files are unique, and we haven't copied the same file twice
    int firstSize = firstFiles.size();
    int secondSize = secondFiles.size();
    int thirdSize = thirdFiles.size();

    firstFiles.removeAll(secondFiles);
    firstFiles.removeAll(thirdFiles);

    secondFiles.removeAll(firstFiles);
    secondFiles.removeAll(thirdFiles);

    thirdFiles.removeAll(firstFiles);
    thirdFiles.removeAll(secondFiles);

    //If these numbers don't match, we duplicated a file
    Assert.assertEquals("duplicate copy in .camel0", new Integer(firstSize), new Integer(firstFiles.size()));
    Assert.assertEquals("duplicate copy in .camel1", new Integer(secondSize), new Integer(secondFiles.size()));
    Assert.assertEquals("duplicate copy in .camel2", new Integer(thirdSize), new Integer(thirdFiles.size()));

    //Check the expected copied amount is correct
    Assert.assertEquals(new Integer(33), new Integer(firstFiles.size()));
    Assert.assertEquals(new Integer(33), new Integer(secondFiles.size()));
    Assert.assertEquals(new Integer(33), new Integer(thirdFiles.size()));
    Assert.assertEquals(new Integer(99),
            new Integer(firstFiles.size() + secondFiles.size() + thirdFiles.size()));

    //Assert the endpoints last, as there seems to be a strange bug where they fail but the files have been processed,
    //so that would suggest the MockEndpoints are reporting a false-positive
    first.assertIsSatisfied();
    second.assertIsSatisfied();
    third.assertIsSatisfied();
}

From source file:gr.upatras.ece.nam.baker.impl.BakerClientAPIImpl.java

@GET
@Path("/ibuns/example")
@Produces("application/json")
public Response getJsonInstalledBunExample(@Context HttpHeaders headers, @Context HttpServletRequest request) {

    String userAgent = headers.getRequestHeader("user-agent").get(0);
    logger.info("Received GET for Example. user-agent= " + userAgent);

    if (headers.getRequestHeaders().get("X-Baker-API-Version") != null) {
        String XBakerAPIVersion = headers.getRequestHeader("X-Baker-API-Version").get(0);
        logger.info("Received GET for Example. X-Baker-API-Version= " + XBakerAPIVersion);
    }/*from   w w  w .  j ava2  s.  co  m*/

    Map<String, Cookie> cookies = headers.getCookies();
    logger.info("cookies for Example = " + cookies.toString());
    HttpSession session = request.getSession(true);
    logger.info("session = " + session.getId());

    URI endpointUrl = uri.getBaseUri();

    InstalledBun installedBun = new InstalledBun(("12cab8b8-668b-4c75-99a9-39b24ed3d8be"),
            endpointUrl + "repo/ibuns/12cab8b8-668b-4c75-99a9-39b24ed3d8be");
    installedBun.setName("ServiceName");

    ResponseBuilder response = Response.ok(installedBun);

    CacheControl cacheControl = new CacheControl();
    cacheControl.setNoCache(true);
    response.cacheControl(cacheControl);

    return response.build();
}

From source file:com.trenako.results.SearchRangeTests.java

@Test
public void shouldReturnSearchRangeParametersAsMap() {
    SearchRange range = new SearchRange(25, new Sort(Direction.DESC, "name"), SINCE, MAX);

    Map<String, Object> params = range.asMap();

    String expected = "{dir=DESC, max=501171ab575ef9abd1a0c71f, "
            + "since=501171ab575ef9abd1a0c71e, size=25, sort=name}";

    assertNotNull(params);//  w  w w.  ja  va  2 s.  co  m
    assertEquals(5, params.size());
    assertEquals(expected, params.toString());
}

From source file:org.datacleaner.monitor.server.controllers.JobModificationControllerTest.java

public void testRenameJobAndResult() throws Exception {
    final JobModificationPayload input = new JobModificationPayload();
    input.setName("renamed_job");

    HttpServletResponse response = new MockHttpServletResponse();
    final Map<String, String> result = jobModificationController.modifyJob("tenant1", "product_profiling",
            input, response);/*from www . j ava2s  . c om*/
    assertEquals("{new_job_name=renamed_job, old_job_name=product_profiling, "
            + "repository_url=/tenant1/jobs/renamed_job.analysis.xml}", result.toString());

    final RepositoryFolder resultsFolder = repository.getFolder("tenant1").getFolder("results");

    // check that files have been renamed
    assertEquals(0, resultsFolder.getFiles("product_profiling", ".result.dat").size());
    assertEquals(6, resultsFolder.getFiles("renamed_job", ".result.dat").size());

    final TimelineDefinition timelineDefinition = timelineDao.getTimelineDefinition(new TimelineIdentifier(
            "Product types", "/tenant1/timelines/Product data/Product types.analysis.timeline.xml", null));

    assertEquals("renamed_job", timelineDefinition.getJobIdentifier().getName());
}

From source file:org.datacleaner.monitor.server.controllers.JobCopyAndDeleteControllerTest.java

public void testRenameJobAndResult() throws Exception {
    assertNull(repository.getRepositoryNode("/tenant1/jobs/product_analysis.analysis.xml"));

    final AtomicBoolean copyEventReceived = new AtomicBoolean(false);

    final JobCopyController jobCopyController = new JobCopyController();
    jobCopyController._contextFactory = tenantContextFactory;
    jobCopyController._eventPublisher = new ApplicationEventPublisher() {
        @Override/*from   ww  w .  ja  va 2 s  .c  om*/
        public void publishEvent(ApplicationEvent event) {
            copyEventReceived.set(true);

            assertTrue(event instanceof JobCopyEvent);
            JobCopyEvent copyEvent = (JobCopyEvent) event;

            assertEquals("product_profiling", copyEvent.getSourceJob().getName());
            assertEquals("product_analysis", copyEvent.getTargetJob().getName());
        }
    };

    final JobCopyPayload input = new JobCopyPayload();
    input.setName("product_analysis");

    Map<String, String> result = jobCopyController.copyJob("tenant1", "product_profiling", input);
    assertEquals("{repository_url=/tenant1/jobs/product_analysis.analysis.xml, "
            + "source_job=product_profiling, target_job=product_analysis}", result.toString());

    assertNotNull(repository.getRepositoryNode("/tenant1/jobs/product_analysis.analysis.xml"));

    assertTrue(copyEventReceived.get());

    final AtomicBoolean deleteEventReceived = new AtomicBoolean(false);
    final JobDeletionController jobDeleteController = new JobDeletionController();
    jobDeleteController._contextFactory = tenantContextFactory;
    jobDeleteController._eventPublisher = new ApplicationEventPublisher() {
        @Override
        public void publishEvent(ApplicationEvent event) {
            deleteEventReceived.set(true);

            assertTrue(event instanceof JobDeletionEvent);
            JobDeletionEvent copyEvent = (JobDeletionEvent) event;

            assertEquals("product_analysis", copyEvent.getJobName());
        }
    };

    result = jobDeleteController.deleteJob("tenant1", "product_analysis");
    assertEquals("{action=delete, job=product_analysis}", result.toString());

    assertTrue(deleteEventReceived.get());

    assertNull(repository.getRepositoryNode("/tenant1/jobs/product_analysis.analysis.xml"));
}