⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 schemaopstest.java

📁 JAVA开源LDAP浏览器jxplorer的源码!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        assertNotNull(atts.get("SUP"));
        assertNotNull(atts.get("STRUCTURAL"));
        assertNotNull(atts.get("MAY"));


        Attributes bloop = virtualOps.getAttributesFromSchemaValue(syntaxValue3);
        debugPrintAttribute("WIERD BRACKET THING", bloop);

        Enumeration mayValues = bloop.get("MAY").getAll();

        for (int i=0; mayValues.hasMoreElements(); i++)
            assertEquals(syntaxValue3Mays[i], mayValues.nextElement().toString());
    }

    public void testNameParser()
        throws NamingException
    {
        assertEquals("newPilotPerson", virtualOps.getNames(syntaxValue1)[0]);

        String[] names = virtualOps.getNames(syntaxValue2);
        assertEquals(names.length, syntaxNames2.length);
        for (int i = 0; i < syntaxNames2.length; i++)
        {
            assertEquals(names[i], syntaxNames2[i]);
        }

        //syntaxValue3Mays
        assertEquals("newPilotPerson", virtualOps.getFirstName(syntaxValue1));

        assertEquals("newPilotPerson", virtualOps.getFirstName(syntaxValue2));

    }

    public void testObjectClasses()
        throws NamingException
    {
        ArrayList list = virtualOps.objectClasses();
        assertNotNull(list);
        assertTrue(list.size() == sortedObjectClassesNames.length);
        for (int i=0; i<list.size(); i++)
            assertTrue(" testing equality between ("+i+")" + list.get(i) + " and " + objectClassesNames[i],list.get(i).equals(sortedObjectClassesNames[i]));
    }

    public void testAttributeNames()
        throws NamingException
    {
        ArrayList list = virtualOps.attributeNames();
        assertNotNull("read attribute list", list);
        assertTrue("read list size: " + list.size() + " should equal stored list: " + sortedAttributeNames.length , list.size() == sortedAttributeNames.length);
        for (int i=0; i<list.size(); i++)
            assertTrue(" testing equality between ("+i+")" + list.get(i) + " and " + sortedAttributeNames[i],list.get(i).equals(sortedAttributeNames[i]));
    }


    public void testGetNewBinaryAttributes()
    {
        String bloop = virtualOps.getNewBinaryAttributes();
        assertEquals(bloop, binaryStrings);
    }

    public void testGetAttributeSyntax()
    {
        assertEquals("1.3.6.1.4.1.1466.115.121.1.38", virtualOps.getAttributeSyntax("objectClass"));
        assertEquals("1.3.6.1.4.1.1466.115.121.1.38", virtualOps.getAttributeSyntax("oc"));
        assertEquals("1.3.6.1.4.1.1466.115.121.1.12", virtualOps.getAttributeSyntax("aliasedObjectName"));
        assertEquals("1.3.6.1.4.1.1466.115.121.1.15", virtualOps.getAttributeSyntax("knowledgeInformation"));
    }

    public void testDirGetAttributeSyntax()
    {
        if (initDirectory())
        {
            assertEquals("1.3.6.1.4.1.1466.115.121.1.38", directorySchemaOps.getAttributeSyntax("objectClass"));
            assertEquals("1.3.6.1.4.1.1466.115.121.1.38", directorySchemaOps.getAttributeSyntax("oc"));
            assertEquals("1.3.6.1.4.1.1466.115.121.1.12", directorySchemaOps.getAttributeSyntax("aliasedObjectName"));
            assertEquals("1.3.6.1.4.1.1466.115.121.1.15", directorySchemaOps.getAttributeSyntax("knowledgeInformation"));
        }
    }

    public void testDirSchemaLookup()
    {
        if (initDirectory())
        {
            assertEquals("c",directorySchemaOps.schemaLookup("schema=countryName,schema=attributeTypes", "NAME"));
            assertEquals("Certificate",directorySchemaOps.schemaLookup("schema=Certificate,schema=ldapSyntaxes", "DESC"));
        }
    }


    public void testSchemaLookup()
    {
        assertEquals("c",virtualOps.schemaLookup("schema=countryName,schema=attributeTypes", "NAME"));
        assertEquals("Certificate",virtualOps.schemaLookup("schema=Certificate,schema=ldapSyntaxes", "DESC"));
        assertEquals("objectClass", virtualOps.schemaLookup("AttributeDefinition/objectClass", "NAME"));
        assertEquals("objectClass", virtualOps.schemaLookup("attributeTypes/objectClass", "NAME"));
    }

//.schemaLookup("AttributeDefinition/objectClass", "NAME");

    public void testSchemaList()
        throws NamingException
    {
        ArrayList nextLevel = virtualOps.listEntryNames("schema=objectClasses");
        for (int i=0; i<nextLevel.size(); i++)
            assertEquals(objectClassesNames[i], nextLevel.get(i) );

        nextLevel = virtualOps.listEntryNames("");
        for (int i=0; i<topLevelNames.length; i++)
            nextLevel.contains(topLevelNames[i]);

        nextLevel = virtualOps.listEntryNames("cn=schema");
        for (int i=0; i<topLevelNames.length; i++)
            nextLevel.contains(topLevelNames[i]);
    }

    public void testGetNameOfObjectClassAttribute()
    {
        assertEquals("objectClass", virtualOps.getNameOfObjectClassAttribute());
    }

    public void testTranslateOID()
    {
        assertEquals("knowledgeInformation", virtualOps.translateOID("2.5.4.2"));
        assertEquals("mhsBadAddressSearchPoint", virtualOps.translateOID("1.3.6.1.4.1.453.7.3.2.4"));
        assertEquals("o-top-NF", virtualOps.translateOID("1.3.6.1.4.1.3327.7.2"));
    }

    public void testMultipleNamedAttributes()
        throws NamingException
    {
        Attributes cn1 = virtualOps.getAttributesFromSchemaName("schema=commonName,schema=attributeTypes");
        Attributes cn2 = virtualOps.getAttributesFromSchemaName("schema=cn,schema=attributeTypes");

        assertNotNull(cn1);
        assertNotNull(cn2);
        assertEquals(cn1.get("OID"), cn2.get("OID"));

    }

    // test parsing of:
    //"( 1.1.1.1.1.1 NAME 'xxxPerson' DESC 'Person im EEA GDS-System' AUXILIARY MAY ( eeaBadgeNumber $ eeaPersonalHash ) X-NDS_NOT_CONTAINER '1' )"};
    //and
    //"( 2.5.6.2 NAME 'country' SUP ( top ) STRUCTURAL MUST ( c ) MAY ( description $ searchGuide ) )",

    public void testObjectClassAttributeParsing()
        throws NamingException
    {
        Attributes oc = virtualOps.getAttributes("schema=xxxPerson,schema=objectClasses");

        //debugPrintAttribute("XXX Person", oc);

        assertEquals(oc.get("NAME").get(), "xxxPerson");
        assertEquals(oc.get("DESC").get(), "Person im EEA GDS-System");

        oc = virtualOps.getAttributes("schema=country,schema=objectClasses");
        assertEquals(oc.get("NAME").get(), "country");
        assertEquals(oc.get("OID").get(), "2.5.6.2");


    }

    public void testObjectClassAttributeParsingWithMixedCases()
        throws NamingException
    {
        Attributes oc = virtualOps.getAttributes("schema=xxxperson,schema=objectClasses");

        //debugPrintAttribute("XXX Person", oc);
        assertNotNull("unable to read mixed case schema object", oc);
        assertNotNull("unable to read name of mixed case schema object", oc.get("NAME"));

        assertEquals(oc.get("NAME").get(), "xxxPerson");
        assertEquals(oc.get("DESC").get(), "Person im EEA GDS-System");

        oc = virtualOps.getAttributes("schema=country,schema=objectClasses");
        assertEquals(oc.get("NAME").get(), "country");
        assertEquals(oc.get("OID").get(), "2.5.6.2");


    }

    public void debugPrintAttribute(String msg, Attributes atts)
        throws NamingException
    {
        System.out.println(msg);
        Enumeration bloop = atts.getIDs();
        while (bloop.hasMoreElements())
        {
            String id = bloop.nextElement().toString();
            Enumeration vals = atts.get(id).getAll();
            while (vals.hasMoreElements())
                System.out.println("  " + id + " : " + vals.nextElement().toString());
        }

    }

    public void testGetTypeName()
        throws NamingException
    {
        assertEquals("objectClasses", virtualOps.getTypeName("schema=objectClasses,cn=schema"));
        assertEquals("attributeTypes", virtualOps.getTypeName("schema=cn,schema=attributeTypes,cn=schema"));
        assertEquals("attributeTypes", virtualOps.getTypeName("schema=cn,schema=attributeTypes"));
    }

    public void testGetSpecificName()
        throws NamingException
    {
        assertEquals("cn", virtualOps.getSpecificName("schema=cn,schema=attributeTypes,cn=schema"));
        assertEquals("cn", virtualOps.getSpecificName("schema=cn,schema=attributeTypes"));
        assertEquals("xxxPerson", virtualOps.getSpecificName("schema=xxxPerson,schema=objectClass"));
    }
    public void testMangleEntryName()
    {
        assertEquals("schema=objectClasses", virtualOps.mangleEntryName("schema=ClassDefinition,cn=schema"));
        assertEquals("schema=ldapSyntaxes", virtualOps.mangleEntryName("schema=SyntaxDefinition"));
        assertEquals("schema=cn,schema=attributeTypes", virtualOps.mangleEntryName("AttributeDefinition/cn;binary"));
    }                       //   ;binary,schema=AttributeDefinition>

    public void testIsAttributeSingleValued()
    {/* TE */
        assertTrue("Testing if uNSPSCTitle is a SINGLE-VALUE attribute.", virtualOps.isAttributeSingleValued("uNSPSCTitle"));
        assertTrue("Testing if countryName is a SINGLE-VALUE attribute.", (!virtualOps.isAttributeSingleValued("countryName")));
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -