Example usage for junit.framework Assert assertNull

List of usage examples for junit.framework Assert assertNull

Introduction

In this page you can find the example usage for junit.framework Assert assertNull.

Prototype

static public void assertNull(String message, Object object) 

Source Link

Document

Asserts that an object is null.

Usage

From source file:org.mifos.framework.components.batchjobs.helpers.BranchReportClientSummaryHelperIntegrationTest.java

private void assertClientSummary(BranchReportBO branchReport) throws PersistenceException {
    Assert.assertNotNull(branchReport.getBranchReportId());
    Set<BranchReportClientSummaryBO> branchReportClientSummaries = branchReport.getClientSummaries();
    Assert.assertNotNull(branchReportClientSummaries);
    Assert.assertEquals(12, branchReportClientSummaries.size());

    Predicate predicate = new BranchReportClientSummaryBatchBOExtractor()
            .matchAllPredicates(branchReportClientSummaries);
    Assert.assertNull(predicate + " not found in summaries", predicate);
}

From source file:org.mifos.reports.branchreport.persistence.BranchReportPersistenceIntegrationTest.java

@Test
public void testExtractStaffingSummaryLevels() throws Exception {
    List<BranchReportStaffingLevelSummaryBO> staffingLevels = branchReportPersistence
            .extractBranchReportStaffingLevelSummary(LOAN_OFFICER_ID_SHORT);
    Assert.assertEquals(2, staffingLevels.size());
    Assert.assertNull("Should not extract roles with zero personnel count",
            org.apache.commons.collections.CollectionUtils.find(staffingLevels, new Predicate() {
                @Override/* w ww.j a v a  2s.co  m*/
                public boolean evaluate(Object arg0) {
                    BranchReportStaffingLevelSummaryBO summary = (BranchReportStaffingLevelSummaryBO) arg0;
                    return !TOTAL_STAFF_ROLENAME_STR.equals(summary.getTitleName())
                            && Integer.valueOf(0).equals((summary).getPersonnelCount());
                }
            }));
    for (BranchReportStaffingLevelSummaryBO summaryBO : staffingLevels) {
        if (TOTAL_STAFF_ROLENAME_STR.equals(summaryBO.getTitleName())) {
            Assert.assertEquals(Integer.valueOf(2), summaryBO.getPersonnelCount());
        }
    }
}

From source file:org.opennaas.extensions.router.junos.actionssets.actions.test.GetConfigActionTest.java

@Test
public void paramsTest() {
    // this action always have null params
    Assert.assertNull("Not accepted param", action.getParams());
}

From source file:org.opennaas.extensions.router.junos.actionssets.actions.test.queue.PrepareRestoreActionTest.java

@Test
public void paramsTest() {
    // this action always have null params
    Assert.assertNull("Not accepted param", restoreAction.getParams());
    Assert.assertNull("Not accepted param", prepareAction.getParams());

}

From source file:org.opennaas.extensions.router.junos.actionssets.digester.test.IPInterfaceParserTest.java

@Test
public void multipleIPsPerInterfaceTest() throws Exception {
    System model = new ComputerSystem();
    IPInterfaceParser parser = new IPInterfaceParser(model);

    String message = readStringFromFile("/parsers/ethernetPortWIthMultipleIPs.xml");

    parser.init();/*w  w w . j  a v  a 2s  .c om*/
    parser.configurableParse(new ByteArrayInputStream(message.getBytes()));
    String str = "\n";

    model = parser.getModel();
    Assert.assertEquals("Model shouldn't have any service.", 0, model.getHostedService().size());

    List<LogicalDevice> logicalDevices = model.getLogicalDevices();
    Assert.assertEquals("Model should have 4 differents logical devices.", 5, logicalDevices.size());

    for (LogicalDevice device : logicalDevices) {
        Assert.assertTrue("Model should only have Ethernet ports.", device instanceof EthernetPort);
        EthernetPort ethPort = (EthernetPort) device;

        if (ethPort.getName().equals("ge-2/0/0") && ethPort.getPortNumber() == 12) {
            Assert.assertNotNull("Ethernet Port ge-2/0/0.12 should have a description.",
                    ethPort.getDescription());
            List<ProtocolEndpoint> protocolEndpoints = ethPort.getProtocolEndpoint();
            Assert.assertEquals("Ethernet Port ge-2/0/0.12 should have 3 ProtocolEndpoints", 3,
                    protocolEndpoints.size());

            List<IPProtocolEndpoint> ipEndpoints = ethPort.getProtocolEndpointsByType(IPProtocolEndpoint.class);
            Assert.assertEquals("Ethernet Port ge-2/0/0.12 should have 2 IPProtocolEndpoints", 2,
                    ipEndpoints.size());

            List<VLANEndpoint> vlanEndpoints = ethPort.getProtocolEndpointsByType(VLANEndpoint.class);
            Assert.assertEquals("Ethernet Port ge-2/0/0.12 should have 1 VlanProtocolEndpoint", 1,
                    vlanEndpoints.size());

            IPProtocolEndpoint ipEndpoint = ipEndpoints.get(0);
            Assert.assertEquals("Ethernet Port ge-2/0/0.12 should only have IPv4 IPProtocolEndpoints",
                    ProtocolIFType.IPV4, ipEndpoint.getProtocolIFType());
            Assert.assertNull("Ethernet Port ge-2/0/0.12 should not have configured IPv6 addresses",
                    ipEndpoint.getIPv6Address());
            Assert.assertEquals("Ethernet Port ge-2/0/0.12 should not have configured IPv6 prefix length", 0,
                    ipEndpoint.getPrefixLength());
            Assert.assertTrue(
                    ipEndpoint.getIPv4Address() + " is not a valid address for Ethernet Port ge-2/0/0.12",
                    ipEndpoint.getIPv4Address().equals("193.1.190.133")
                            || ipEndpoint.getIPv4Address().equals("193.1.190.134"));
            Assert.assertEquals("Ethernet Port ge-2/0/0.12 should have configured IPv4 with /30 mask",
                    "255.255.255.252", ipEndpoint.getSubnetMask());

            ipEndpoint = ipEndpoints.get(1);
            Assert.assertEquals("Ethernet Port ge-2/0/0.12 should only have IPv4 IPProtocolEndpoints",
                    ipEndpoint.getProtocolIFType(), ProtocolIFType.IPV4);
            Assert.assertNull("Ethernet Port ge-2/0/0.12 should not have configured IPv6 addresses",
                    ipEndpoint.getIPv6Address());
            Assert.assertEquals("Ethernet Port ge-2/0/0.12 should not have configured IPv6 prefix length", 0,
                    ipEndpoint.getPrefixLength());
            Assert.assertTrue(
                    ipEndpoint.getIPv4Address() + " is not a valid address for Ethernet Port ge-2/0/0.12",
                    ipEndpoint.getIPv4Address().equals("193.1.190.133")
                            || ipEndpoint.getIPv4Address().equals("193.1.190.134"));
            Assert.assertEquals("Ethernet Port ge-2/0/0.12 should have configured IPv4 with /30 mask",
                    "255.255.255.252", ipEndpoint.getSubnetMask());

            Assert.assertEquals("Ethernet Port ge-2/0/0.12 should only have VlanEndpoint with VlanID 12", 12,
                    vlanEndpoints.get(0).getVlanID());

        }
        if (ethPort.getName().equals("ge-2/0/0") && ethPort.getPortNumber() == 201) {
            Assert.assertNotNull("Ethernet Port ge-2/0/0.201 should have a description.",
                    ethPort.getDescription());
            List<ProtocolEndpoint> protocolEndpoints = ethPort.getProtocolEndpoint();
            Assert.assertEquals("Ethernet Port ge-2/0/0.201 should have 2 ProtocolEndpoints", 2,
                    protocolEndpoints.size());

            List<IPProtocolEndpoint> ipEndpoints = ethPort.getProtocolEndpointsByType(IPProtocolEndpoint.class);
            Assert.assertEquals("Ethernet Port ge-2/0/0.201 should have 1 IPProtocolEndpoints", 1,
                    ipEndpoints.size());

            List<VLANEndpoint> vlanEndpoints = ethPort.getProtocolEndpointsByType(VLANEndpoint.class);
            Assert.assertEquals("Ethernet Port ge-2/0/0.201 should have 1 VlanProtocolEndpoint", 1,
                    vlanEndpoints.size());

            IPProtocolEndpoint ipEndpoint = ipEndpoints.get(0);
            Assert.assertEquals("Ethernet Port ge-2/0/0.201 should only have IPv4 IPProtocolEndpoints",
                    ProtocolIFType.IPV4, ipEndpoint.getProtocolIFType());
            Assert.assertNull("Ethernet Port ge-2/0/0.201 should not have configured IPv6 addresses",
                    ipEndpoint.getIPv6Address());
            Assert.assertEquals("Ethernet Port ge-2/0/0.201 should not have configured IPv6 prefix length", 0,
                    ipEndpoint.getPrefixLength());
            Assert.assertTrue(
                    ipEndpoint.getIPv4Address() + " is not a valid address for Ethernet Port ge-2/0/0.201",
                    ipEndpoint.getIPv4Address().equals("192.168.1.1"));
            Assert.assertEquals("Ethernet Port ge-2/0/0.201 should have configured IPv4 with /24 mask",
                    "255.255.255.0", ipEndpoint.getSubnetMask());

            Assert.assertEquals("Ethernet Port ge-2/0/0.201 should only have VlanEndpoint with VlanID 201", 201,
                    vlanEndpoints.get(0).getVlanID());
        }

        if (ethPort.getName().equals("ge-2/0/0") && ethPort.getPortNumber() == 202) {
            Assert.assertNotNull("Ethernet Port ge-2/0/0.202 should have a description.",
                    ethPort.getDescription());
            List<ProtocolEndpoint> protocolEndpoints = ethPort.getProtocolEndpoint();
            Assert.assertEquals("Ethernet Port ge-2/0/0.202 should have 2 ProtocolEndpoints", 2,
                    protocolEndpoints.size());

            List<IPProtocolEndpoint> ipEndpoints = ethPort.getProtocolEndpointsByType(IPProtocolEndpoint.class);
            Assert.assertEquals("Ethernet Port ge-2/0/0.202 should have 1 IPProtocolEndpoints", 1,
                    ipEndpoints.size());

            List<VLANEndpoint> vlanEndpoints = ethPort.getProtocolEndpointsByType(VLANEndpoint.class);
            Assert.assertEquals("Ethernet Port ge-2/0/0.202 should have 1 VlanProtocolEndpoint", 1,
                    vlanEndpoints.size());

            IPProtocolEndpoint ipEndpoint = ipEndpoints.get(0);
            Assert.assertEquals("Ethernet Port ge-2/0/0.202 should only have IPv6 IPProtocolEndpoints",
                    ProtocolIFType.IPV6, ipEndpoint.getProtocolIFType());
            Assert.assertNull("Ethernet Port ge-2/0/0.202 should not have configured IPv4 addresses",
                    ipEndpoint.getIPv4Address());
            Assert.assertNull("Ethernet Port ge-2/0/0.202 should not have configured IPv4 subnet mask",
                    ipEndpoint.getSubnetMask());
            Assert.assertTrue(
                    ipEndpoint.getIPv6Address() + " is not a valid address for Ethernet Port ge-2/0/0.201",
                    ipEndpoint.getIPv6Address().equals("FEDC:43::32:50"));
            Assert.assertEquals("Ethernet Port ge-2/0/0.202 should have configured IPv6 with /64 prefix", 64,
                    ipEndpoint.getPrefixLength());

            Assert.assertEquals("Ethernet Port ge-2/0/0.202 should only have VlanEndpoint with VlanID 202", 202,
                    vlanEndpoints.get(0).getVlanID());
        }

        if (ethPort.getName().equals("fe-0/3/2") && ethPort.getPortNumber() == 0) {
            Assert.assertNotNull("Ethernet Port fe-0/3/2.0 should have a description.",
                    ethPort.getDescription());
            List<ProtocolEndpoint> protocolEndpoints = ethPort.getProtocolEndpoint();
            Assert.assertEquals("Ethernet Port fe-0/3/2.0 should have 3 ProtocolEndpoints", 3,
                    protocolEndpoints.size());

            List<IPProtocolEndpoint> ipEndpoints = ethPort.getProtocolEndpointsByType(IPProtocolEndpoint.class);
            Assert.assertEquals("Ethernet Port fe-0/3/2.0 should have 2 IPProtocolEndpoints", 2,
                    ipEndpoints.size());

            List<VLANEndpoint> vlanEndpoints = ethPort.getProtocolEndpointsByType(VLANEndpoint.class);
            Assert.assertEquals("Ethernet Port fe-0/3/2.0 should have 1 VlanProtocolEndpoint", 1,
                    vlanEndpoints.size());

            IPProtocolEndpoint ipEndpoint = ipEndpoints.get(0);
            Assert.assertEquals("Ethernet Port fe-0/3/2.0 should only have IPv6 IPProtocolEndpoints",
                    ProtocolIFType.IPV6, ipEndpoint.getProtocolIFType());
            Assert.assertNull("Ethernet Port fe-0/3/2.0 should not have configured IPv4 addresses",
                    ipEndpoint.getIPv4Address());
            Assert.assertNull("Ethernet Port fe-0/3/2.0 should not have configured IPv4 subnet mask",
                    ipEndpoint.getSubnetMask());
            Assert.assertTrue(
                    ipEndpoint.getIPv6Address() + " is not a valid address for Ethernet Port fe-0/3/2.0",
                    ipEndpoint.getIPv6Address().equals("FEDC:43::32:1")
                            || ipEndpoint.getIPv6Address().equals("FEDC:43::32:2"));
            Assert.assertEquals("Ethernet Port fe-0/3/2.0 should have configured IPv6 with /64 prefix length",
                    64, ipEndpoint.getPrefixLength());

            ipEndpoint = ipEndpoints.get(1);
            Assert.assertEquals("Ethernet Port fe-0/3/2.0 should only have IPv6 IPProtocolEndpoints",
                    ProtocolIFType.IPV6, ipEndpoint.getProtocolIFType());
            Assert.assertNull("Ethernet Port fe-0/3/2.0 should not have configured IPv4 addresses",
                    ipEndpoint.getIPv4Address());
            Assert.assertNull("Ethernet Port fe-0/3/2.0 should not have configured IPv4 subnet mask",
                    ipEndpoint.getSubnetMask());
            Assert.assertTrue(
                    ipEndpoint.getIPv6Address() + " is not a valid address for Ethernet Port fe-0/3/2.0",
                    ipEndpoint.getIPv6Address().equals("FEDC:43::32:1")
                            || ipEndpoint.getIPv6Address().equals("FEDC:43::32:2"));
            Assert.assertEquals("Ethernet Port fe-0/3/2.0 should have configured IPv6 with /64 prefix length",
                    64, ipEndpoint.getPrefixLength());

            Assert.assertEquals("Ethernet Port fe-0/3/2.0 should only have VlanEndpoint with VlanID 32", 32,
                    vlanEndpoints.get(0).getVlanID());

        }

        if (ethPort.getName().equals("fe-0/3/2") && ethPort.getPortNumber() == 1) {
            Assert.assertNotNull("Ethernet Port fe-0/3/2.1 should have a description.",
                    ethPort.getDescription());
            List<ProtocolEndpoint> protocolEndpoints = ethPort.getProtocolEndpoint();
            Assert.assertEquals("Ethernet Port fe-0/3/2.1 should have 3 ProtocolEndpoints", 3,
                    protocolEndpoints.size());

            List<IPProtocolEndpoint> ipEndpoints = ethPort.getProtocolEndpointsByType(IPProtocolEndpoint.class);
            Assert.assertEquals("Ethernet Port fe-0/3/2.1 should have 2 IPProtocolEndpoints", 2,
                    ipEndpoints.size());

            List<VLANEndpoint> vlanEndpoints = ethPort.getProtocolEndpointsByType(VLANEndpoint.class);
            Assert.assertEquals("Ethernet Port fe-0/3/2.1 should have 1 VlanProtocolEndpoint", 1,
                    vlanEndpoints.size());

            IPProtocolEndpoint ipEndpoint1 = ipEndpoints.get(0);
            IPProtocolEndpoint ipEndpoint2 = ipEndpoints.get(1);
            Assert.assertNotNull(
                    "ProtocolIFType should be set in IPProtocolEndpoint of Ethernet Port fe-0/3/2.1.",
                    ipEndpoint1.getProtocolIFType());
            Assert.assertNotNull(
                    "ProtocolIFType should be set in IPProtocolEndpoint of Ethernet Port fe-0/3/2.1.",
                    ipEndpoint2.getProtocolIFType());
            Assert.assertFalse(
                    "IPProtocolEndpoints should have differents protocols in Ethernet Port fe-0/3/2.1",
                    ipEndpoint1.getProtocolIFType().equals(ipEndpoint2.getProtocolIFType()));

            for (IPProtocolEndpoint ipEndpoint : ipEndpoints) {
                if (ipEndpoint.getProtocolIFType().equals(ProtocolIFType.IPV4)) {

                    Assert.assertNull(
                            "IPv4 IPProtocolEndpoint in Ethernet Port fe-0/3/2.1 should not have configured IPv6 addresses",
                            ipEndpoint.getIPv6Address());
                    Assert.assertEquals(
                            "IPv4 IPProtocolEndpoint in Ethernet Port fe-0/3/2.1 should not have configured IPv6 prefix length",
                            0, ipEndpoint.getPrefixLength());
                    Assert.assertEquals(
                            "IPv4 IPProtocolEndpoint in Ethernet Port fe-0/3/2.1 should have the address 192.168.1.1.",
                            "192.168.1.1", ipEndpoint.getIPv4Address());
                    Assert.assertEquals(
                            "IPv4 IPProtocolEndpoint in Ethernet Port fe-0/3/2.1 should have the mask 255.255.255.0",
                            "255.255.255.0", ipEndpoint.getSubnetMask());
                }

                if (ipEndpoint.getProtocolIFType().equals(ProtocolIFType.IPV6)) {

                    Assert.assertNull(
                            "IPv6 IPProtocolEndpoint in Ethernet Port fe-0/3/2.1 should not have configured IPv4 addresses",
                            ipEndpoint.getIPv4Address());
                    Assert.assertNull(
                            "IPv6 IPProtocolEndpoint in Ethernet Port fe-0/3/2.1 should not have configured IPv4 subnet mask",
                            ipEndpoint.getSubnetMask());
                    Assert.assertEquals(
                            "IPv6 IPProtocolEndpoint in Ethernet Port fe-0/3/2.1 should have the address FEDC:43::32:3",
                            "FEDC:43::32:3", ipEndpoint.getIPv6Address());
                    Assert.assertEquals(
                            "IPv6 IPProtocolEndpoint in Ethernet Port fe-0/3/2.1 should have a prefix lenght of 64",
                            64, ipEndpoint.getPrefixLength());
                }

            }

            Assert.assertEquals("Ethernet Port fe-0/3/2.1 should only have VlanEndpoint with VlanID 35", 35,
                    vlanEndpoints.get(0).getVlanID());

        }

    }

}

From source file:org.outermedia.solrfusion.SolrFusionServletTest.java

protected void testBuildFusionRequestImpl(String fq) {
    SolrFusionServlet servlet = spy(this.servlet);
    Configuration cfg = mock(Configuration.class);
    doReturn(10).when(cfg).getDefaultPageSize();
    doReturn("score desc").when(cfg).getDefaultSortField();
    servlet.setCfg(cfg);/*from   w  w  w. ja  v  a  2  s .c om*/
    Map<String, String[]> requestParams = new HashMap<>();
    String q = "title:schiller";
    requestParams.put(QUERY.getRequestParamName(), new String[] { q });
    if (fq != null) {
        requestParams.put(FILTER_QUERY.getRequestParamName(), new String[] { fq });
    }
    String fieldsToReturn = "* score";
    requestParams.put(FIELDS_TO_RETURN.getRequestParamName(), new String[] { fieldsToReturn });
    requestParams.put(QUERY_TYPE.getRequestParamName(), new String[] { "morelikethis" });
    requestParams.put(HIGHLIGHT.getRequestParamName(), new String[] { "true" });
    requestParams.put(HIGHLIGHT_PRE.getRequestParamName(), new String[] { "pre" });
    requestParams.put(HIGHLIGHT_POST.getRequestParamName(), new String[] { "post" });
    requestParams.put(HIGHLIGHT_FIELDS_TO_RETURN.getRequestParamName(), new String[] { fieldsToReturn });
    requestParams.put(HIGHLIGHT_QUERY.getRequestParamName(), new String[] { q });
    requestParams.put(FACET.getRequestParamName(), new String[] { "true" });
    requestParams.put(FACET_FIELD.getRequestParamName(),
            new String[] { "{!ex=format_filter}format", "{!ex=format_de15_filter}format_de15" });
    requestParams.put(FACET_LIMIT.getRequestParamName(), new String[] { "20" });
    requestParams.put(FACET_MINCOUNT.getRequestParamName(), new String[] { "2" });
    requestParams.put(FACET_PREFIX.getRequestParamName(), new String[] { "p1" });
    requestParams.put(FACET_SORT.getRequestParamName(), new String[] { "author" });
    requestParams.put("f.finc_class_facet.facet.sort", new String[] { "s1" });
    requestParams.put("f.format.facet.sort", new String[] { "s2" });

    FusionRequest req = servlet.buildFusionRequest(requestParams, new HashMap<String, Object>());

    // check core params
    Assert.assertNotNull("Expected request object", req);
    Assert.assertEquals("Got different query", q, req.getQuery().getValue());
    if (fq == null) {
        Assert.assertNull("Expected no filter query list", req.getFilterQuery());
    } else {
        Assert.assertEquals("Got different filter query", fq, req.getFilterQuery().get(0).getValue());
    }
    Assert.assertEquals("Got different renderer type than expected", ResponseRendererType.JSON,
            req.getResponseType());
    Assert.assertEquals("Got different fields", fieldsToReturn, req.getFieldsToReturn().getValue());
    Assert.assertEquals("Got different query type", "morelikethis", req.getQueryType().getValue());
    Assert.assertFalse("Expected no exception, but got " + req.buildErrorMessage(), req.hasErrors());

    // check highlighting params
    Assert.assertEquals("Got different highlight query", q, req.getHighlightQuery().getValue());
    Assert.assertEquals("Got different highlight", "true", req.getHighlight().getValue());
    Assert.assertEquals("Got different highlight pre", "pre", req.getHighlightPre().getValue());
    Assert.assertEquals("Got different highlight post", "post", req.getHighlightPost().getValue());
    Assert.assertEquals("Got different highlight fields", fieldsToReturn,
            req.getHighlightingFieldsToReturn().getValue());

    // check facet params
    Assert.assertEquals("Got different facet", "true", req.getFacet().getValue());
    Assert.assertEquals("Got different facet", "20", req.getFacetLimit().getValue());
    Assert.assertEquals("Got different facet", "2", req.getFacetMincount().getValue());
    Assert.assertEquals("Got different facet", "p1", req.getFacetPrefix().getValue());
    Assert.assertEquals("Got different facet", "author", req.getFacetSort().getValue());
    List<SolrFusionRequestParam> facetFields = req.getFacetFields();
    Assert.assertNotNull("Expected facet fields", facetFields);
    Assert.assertEquals("Got different number of facet fields", 2, facetFields.size());
    Assert.assertEquals("Got different first facet field", "{!ex=format_filter}format",
            facetFields.get(0).getValue());
    Assert.assertEquals("Got different second facet field", "{!ex=format_de15_filter}format_de15",
            facetFields.get(1).getValue());
    List<SolrFusionRequestParam> facetSortFields = req.getFacetSortFields();
    Assert.assertNotNull("Expected facet sort fields", facetSortFields);
    Assert.assertEquals("Got different number of facet sort fields", 2, facetSortFields.size());
    Assert.assertEquals("Got different first facet sort field value", "s1", facetSortFields.get(0).getValue());
    Assert.assertEquals("Got different second facet sort field value", "s2", facetSortFields.get(1).getValue());
    Assert.assertEquals("Got different first facet sort field", "finc_class_facet",
            facetSortFields.get(0).getParamNameVariablePart());
    Assert.assertEquals("Got different second facet sort field", "format",
            facetSortFields.get(1).getParamNameVariablePart());
}

From source file:org.pentaho.test.platform.util.XmlHelperTest.java

public void testEncodeDecode() {
    String emptyString = null;//from   w w w  .  j ava  2 s  . c o m
    Assert.assertNull("decode(null) Should return null", XmlHelper.decode(emptyString)); //$NON-NLS-1$
    Assert.assertNull("encode(null) Should return null", XmlHelper.encode(emptyString)); //$NON-NLS-1$

    String[] emptyArray = null;
    try {
        XmlHelper.decode(emptyArray);
    } catch (Throwable t) {
        Assert.fail("decode with a null array should not throw exception: " + t.getMessage()); //$NON-NLS-1$
    }
    try {
        XmlHelper.encode(emptyArray);
    } catch (Throwable t) {
        Assert.fail("encode with a null array should not throw exception: " + t.getMessage()); //$NON-NLS-1$
    }

    String encodedXml = " ABC 123 abc &amp;amp;=&amp; &amp;lt;=&lt; &amp;gt;=&gt; &amp;apos;=&apos; &amp;quot;=&quot; ABC123abc &amp;quot = &quot; &amp;apos; = &apos; &amp;gt; = &gt; &amp;lt; = &lt; &amp;amp; = &amp; ABC123abc "; //$NON-NLS-1$
    String decodedXml = " ABC 123 abc &amp;=& &lt;=< &gt;=> &apos;=' &quot;=\" ABC123abc &quot = \" &apos; = ' &gt; = > &lt; = < &amp; = & ABC123abc "; //$NON-NLS-1$
    Assert.assertEquals("Error in decode", decodedXml, XmlHelper.decode(encodedXml)); //$NON-NLS-1$
    Assert.assertEquals("Error in encode", encodedXml, XmlHelper.encode(decodedXml)); //$NON-NLS-1$
    Assert.assertEquals("Error encoding after decoding", encodedXml, //$NON-NLS-1$
            XmlHelper.encode(XmlHelper.decode(encodedXml)));
    Assert.assertEquals("Error decoding after encoding", decodedXml, //$NON-NLS-1$
            XmlHelper.decode(XmlHelper.encode(decodedXml)));
}

From source file:org.projectforge.plugins.teamcal.event.TeamEventDaoTestFork.java

private void checkMinimalAccess(final Integer eventId, final PFUserDO... users) {
    for (final PFUserDO user : users) {
        logon(user);//from  w  w  w .  j  ava  2s .c  o m
        final TeamEventDO event = teamEventDao.getById(eventId);
        Assert.assertTrue("Field 'attendees' should be null for minimal users.",
                CollectionUtils.isEmpty(event.getAttendees()));
        Assert.assertTrue("Field 'attachments' should be null for minimal users.",
                CollectionUtils.isEmpty(event.getAttachments()));
        Assert.assertNull("Field 'subject' should be null for minimal users.", event.getSubject());
        Assert.assertNull("Field 'localtion' should be null for minimal users.", event.getLocation());
        Assert.assertNull("Field 'note' should be null for minimal users.", event.getNote());
    }
}

From source file:org.wso2.charon.core.decoder.JSONDecoderTest.java

@Test
public void testDecodeUser() {
    try {//  w w  w  .  j  a v  a2  s.co m
        String fullJSONUser = "{\n" + "  \"schemas\": [\"urn:scim:schemas:core:1.0\"],\n"
                + "  \"id\": \"2819c223-7f76-453a-919d-413861904646\",\n" + "  \"externalId\": \"701984\",\n"
                + "  \"userName\": \"bjensen@example.com\",\n" + "  \"name\": {\n"
                + "    \"formatted\": \"Ms. Barbara J Jensen III\",\n" + "    \"familyName\": \"Jensen\",\n"
                + "    \"givenName\": \"Barbara\",\n" + "    \"middleName\": \"Jane\",\n"
                + "    \"honorificPrefix\": \"Ms.\",\n" + "    \"honorificSuffix\": \"III\"\n" + "  },\n"
                + "  \"displayName\": \"Babs Jensen\",\n" + "  \"nickName\": \"Babs\",\n"
                + "  \"profileUrl\": \"https://login.example.com/bjensen\",\n" + "  \"emails\": [\n" + "    {\n"
                + "      \"value\": \"bjensen@example.com\",\n" + "      \"type\": \"work\",\n"
                + "      \"primary\": true\n" + "    },\n" + "    {\n"
                + "      \"value\": \"babs@jensen.org\",\n" + "      \"type\": \"home\"\n" + "    }\n"
                + "  ],\n" + "  \"addresses\": [\n" + "    {\n" + "      \"type\": \"work\",\n"
                + "      \"streetAddress\": \"100 Universal City Plaza\",\n"
                + "      \"locality\": \"Hollywood\",\n" + "      \"region\": \"CA\",\n"
                + "      \"postalCode\": \"91608\",\n" + "      \"country\": \"USA\",\n"
                + "      \"formatted\": \"100 Universal City Plaza\\nHollywood, CA 91608 USA\",\n"
                + "      \"primary\": true\n" + "    },\n" + "    {\n" + "      \"type\": \"home\",\n"
                + "      \"streetAddress\": \"456 Hollywood Blvd\",\n" + "      \"locality\": \"Hollywood\",\n"
                + "      \"region\": \"CA\",\n" + "      \"postalCode\": \"91608\",\n"
                + "      \"country\": \"USA\",\n"
                + "      \"formatted\": \"456 Hollywood Blvd\\nHollywood, CA 91608 USA\"\n" + "    }\n"
                + "  ],\n" + "  \"phoneNumbers\": [\n" + "    {\n" + "      \"value\": \"555-555-5555\",\n"
                + "      \"type\": \"work\"\n" + "    },\n" + "    {\n" + "      \"value\": \"555-555-4444\",\n"
                + "      \"type\": \"mobile\"\n" + "    }\n" + "  ],\n" + "  \"ims\": [\n" + "    {\n"
                + "      \"value\": \"someaimhandle\",\n" + "      \"type\": \"aim\"\n" + "    }\n" + "  ],\n"
                + "  \"photos\": [\n" + "    {\n"
                + "      \"value\": \"https://photos.example.com/profilephoto/72930000000Ccne/F\",\n"
                + "      \"type\": \"photo\"\n" + "    },\n" + "    {\n"
                + "      \"value\": \"https://photos.example.com/profilephoto/72930000000Ccne/T\",\n"
                + "      \"type\": \"thumbnail\"\n" + "    }\n" + "  ],\n" + "  \"userType\": \"\",\n"
                + "  \"title\": \"Tour Guide\",\n" + "  \"preferredLanguage\":\"en_US\",\n"
                + "  \"locale\": \"en_US\",\n" + "  \"timezone\": \"America/Los_Angeles\",\n"
                + "  \"active\":true,\n" + "  \"password\":\"t1meMa$heen\",\n" + "  \"groups\": [\n" + "    {\n"
                + "      \"display\": \"Tour Guides\",\n" + "      \"value\": \"00300000005N2Y6AA\"\n"
                + "    },\n" + "    {\n" + "      \"display\": \"Employees\",\n"
                + "      \"value\": \"00300000005N34H78\"\n" + "    },\n" + "    {\n"
                + "      \"display\": \"US Employees\",\n" + "      \"value\": \"00300000005N98YT1\"\n"
                + "    }\n" + "  ],\n" + "  \"x509Certificates\": [\n" + "    {\n"
                + "      \"value\": \"MIIDQzCCAqygAwIBAgICEAAwDQYJKoZIhvcNAQEFBQAwTjELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFDASBgNVBAoMC2V4YW1wbGUuY29tMRQwEgYDVQQDDAtleGFtcGxlLmNvbTAeFw0xMTEwMjIwNjI0MzFaFw0xMjEwMDQwNjI0MzFaH8xCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRQwEgYDVQQKDAtleGFtcGxlLmNvbTEhMB8GA1UEAwwYTXMuIEJhcmJhcmEgSiBKZW5zZW4gSUlJMSIwIAYJKoZIhvcNAQkBFhNiamVuc2VuQGV4YW1wbGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7Kr+Dcds/JQ5GwejJFcBIP682X3xpjis56AK02bcFLgzdLI8auoR+cC9/Vrh5t66HkQIOdA4unHh0AaZ4xL5PhVbXIPMB5vAPKpzz5ixO8SL7I7SDhcBVJhqVqr3HgllEG6UClDdHO7nkLuwXq8HcISKkbT5WFTVfFZzidPl8HZ7DhXkZIRtJwBweq4bvm3hM1Os7UQH05ZS6cVDgweKNwdLLrT51ikSQG3DYrl+ft781UQRIqxgwqCfXEuDiinPh0kkvIi5jivVu1Z9QiwlYEdRbLJ4zJQBmDrSGTMYn4lRc2HgHO4DqB/bnMVorHB0CC6AV1QoFK4GPe1LwIDAQABo3sweTAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQU8pD0U0vsZIsaA16lL8En8bx0F/gwHwYDVR0jBBgwFoAUdGeKitcaF7gnzsNwDx708kqaVt0wDQYJKoZIhvcNAQEFBQADgYEAA81SsFnOdYJtNg5Tcq+/ByEDrBgnusx0jloUhByPMEVkoMZ3J7j1ZgI8rAbOkNngX8+pKfTiDz1RC4+dx8oU6Za+4NJXUjlL5CvV6BEYb1+QAEJwitTVvxB/A67g42/vzgAtoRUeDov1GFiBZ+GNF/cAYKcMtGcrs2i97ZkJMo=\"\n"
                + "    }\n" + "  ],\n" + "  \"meta\": {\n" + "    \"created\": \"2010-01-23T04:56:22Z\",\n"
                + "    \"lastModified\": \"2011-05-13T04:42:34Z\",\n"
                + "    \"version\": \"W\\/\\\"a330bc54f0671c9\\\"\",\n"
                + "    \"location\": \"https://example.com/v1/Users/2819c223-7f76-453a-919d-413861904646\"\n"
                + "  }\n" + "}";
        JSONDecoder jsonDecoder = new JSONDecoder();
        User decodedUser = (User) jsonDecoder.decodeResource(fullJSONUser,
                SCIMSchemaDefinitions.SCIM_USER_SCHEMA, new User());
        Assert.assertEquals("Jensen", decodedUser.getFamilyName());
        Assert.assertEquals("urn:scim:schemas:core:1.0", decodedUser.getSchemaList().get(0));
        Assert.assertEquals("2819c223-7f76-453a-919d-413861904646", decodedUser.getId());
        Assert.assertEquals("701984", decodedUser.getExternalId());
        Assert.assertEquals("bjensen@example.com", decodedUser.getUserName());
        Assert.assertEquals("Ms. Barbara J Jensen III", decodedUser.getFormattedName());
        Assert.assertEquals("Jensen", decodedUser.getFamilyName());
        Assert.assertEquals("Barbara", decodedUser.getGivenName());
        Assert.assertEquals("Jane", decodedUser.getMiddleName());
        Assert.assertEquals("Ms.", decodedUser.getHonorificPrefix());
        Assert.assertEquals("III", decodedUser.getHonorificSuffix());
        Assert.assertEquals("Babs Jensen", decodedUser.getDisplayName());
        Assert.assertEquals("Babs", decodedUser.getNickName());
        Assert.assertEquals("https://login.example.com/bjensen", decodedUser.getProfileURL());
        Assert.assertEquals("bjensen@example.com", decodedUser.getEmails()[0]);
        Assert.assertEquals("babs@jensen.org", decodedUser.getEmails()[1]);
        Assert.assertEquals("bjensen@example.com", decodedUser.getEmailByType("work"));
        Assert.assertEquals("babs@jensen.org", decodedUser.getEmailByType("home"));
        Assert.assertTrue(decodedUser.getActive());

        //            try {
        //                Assert.assertEquals("bjensen@example.com", decodedUser.getPrimaryEmail());
        //                decodedUser.getPrimaryEmail();
        //            } catch (NotFoundException e) {
        //                e.printStackTrace();
        //
        //            }

        Assert.assertEquals("555-555-5555", decodedUser.getPhoneNumbers("work").get(0));
        Assert.assertEquals("555-555-4444", decodedUser.getPhoneNumbers("mobile").get(0));
        Assert.assertEquals("someaimhandle", decodedUser.getIMs("aim").get(0));
        Assert.assertNull("Since the value of user type was empty, this should not be returned from storage",
                decodedUser.getUserType());
        Assert.assertEquals("Tour Guide", decodedUser.getTitle());
        Assert.assertEquals("en_US", decodedUser.getPreferredLanguage());
        Assert.assertEquals("en_US", decodedUser.getLocale());
        Assert.assertEquals("America/Los_Angeles", decodedUser.getTimeZone());
        //  Assert.assertEquals("true", decodedUser.getActive());
        Assert.assertEquals("t1meMa$heen", decodedUser.getPassword());
        Assert.assertEquals("00300000005N2Y6AA", decodedUser.getGroups().get(0));
        Assert.assertEquals("00300000005N34H78", decodedUser.getGroups().get(1));
        Assert.assertEquals("00300000005N98YT1", decodedUser.getGroups().get(2));

    } catch (BadRequestException e) {
        Assert.fail(e.getDescription());
    } catch (CharonException e) {
        Assert.fail(e.getDescription());
    }
}