Package org.openxri.resolve

Examples of org.openxri.resolve.Resolver


    * Attempts resolution using an unconfigured (@ and = authorities)
    * resolver.
    */
    public void testNoGlobalAuthority()
    {
        Resolver oResolver = new Resolver();

        //
        // try to resolve a xri without setting up global authority
        //
        try
        {
            String sXRI = "xri://@foo";
            oResolver.resolveAuthToXRDS(new XRI(sXRI), new TrustType(), true);
            assertTrue(
                "Did not get expected PartialResolutionException", false);
        }
        catch (PartialResolutionException E)
        {
View Full Code Here


    *
    * @param bTrusted
    */
    private void testResolution(boolean bTrusted, boolean bEncrypted)
    {
        Resolver oResolver = getConfiguredResolver();

        //
        // resolve valid but non-existing xri
        //
        try
        {
            String sXRI = "xri://@gates*com";
            XRD oDesc =
                oResolver.resolveAuthToXRD(new XRI(sXRI), new TrustType(), false);
            assertTrue("Thought " + sXRI + " did not exist.", oDesc == null);
        }
        catch (PartialResolutionException e) {
          // ok
        }
        catch (Exception E)
        {
            E.printStackTrace();
            assertTrue("Unexpected " + E, false);
        }

        //
        // resolve existing xri
        //
        try
        {
            String sXRI = "xri://@foo";
            XRD oDesc =
                oResolver.resolveAuthToXRD(new XRI(sXRI), new TrustType(), false);
            assertTrue("Thought " + sXRI + " exists.", oDesc != null);
            assertTrue("Invalid XRD Query", oDesc.getQuery().equals("*foo"));
        }
        catch (Exception E)
        {
            E.printStackTrace();
            assertTrue("Unexpected " + E, false);
        }

        //
        // resolve nonexistent segment
        //
        try
        {
            String sXRI = "xri://@foo*bar";
            XRD oDesc =
                oResolver.resolveAuthToXRD(new XRI(sXRI), new TrustType(), false);
            assertTrue("Expected PartialResolutionException but not thrown", false);
        }
        catch (PartialResolutionException e) {
          // ok
        }
View Full Code Here

    * @return a configured (@ and = authorities) resolver; null if
    * configuration fails
    */
    private Resolver getConfiguredResolver()
    {
        Resolver oResolver = new Resolver();

        //
        // Setup Global Authorities
        //
        // stuff the root URI for @, =, and +.  This makes them all the same!
        // e.g. =jmj ends up being the same as @jmj.  For testing only.
        //
        try
        {
          XRD eqXRD = new XRD();
          eqXRD.addService(getRootAuthority());
         
          XRD atXRD = new XRD();
          atXRD.addService(getRootAuthority());
          oResolver.setAuthority("=", eqXRD);
          oResolver.setAuthority("@", atXRD);
        }
        catch (Exception oEx)
        {
            oResolver = null;
        }
View Full Code Here

    {
        if (DEBUG) _log.debug("Initializing local XRI resolver...");

        try {

          _openXriResolver = new Resolver(null);
    } catch (Exception e) {
     
      throw new RuntimeException("Cannot initialize OpenXRI Resolver: " + e.getMessage(), e);
    }
    }
View Full Code Here

TOP

Related Classes of org.openxri.resolve.Resolver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.