Package java.lang

Examples of java.lang.Exception


        Cookies cs=new Cookies(null);
        cs.processCookieHeader( s.getBytes(), 0, s.length());

        int num = cs.getCookieCount();
        if (num != 2)
          throw new Exception("wrong number of cookies " + num);
        ServerCookie co = cs.getCookie(0);
        System.out.println("1 - Cookie: " + co);
        ServerCookie co2 = cs.getCookie(1);
        System.out.println("2 - Cookie: " + co2);

        String coname = co.getName().toString();
        String coval  = co.getValue().toString();
        if ( ! name.equals(coname))
          throw new Exception("1 - wrong name " + coname + " != " + name);
        if ( ! val.equals(coval))
          throw new Exception("1 - wrong value " + coval + " != " + val);

        String coname2 = co2.getName().toString();
        String coval2  = co2.getValue().toString();
        if ( ! name2.equals(coname2))
          throw new Exception("2 - wrong name " + coname2 + " != " + name2);
        if ( ! val2.equals(coval2))
          throw new Exception("2 - wrong value " + coval2 + " != " + val2);
    }
View Full Code Here


        Cookies cs=new Cookies(null);
        cs.processCookieHeader( s.getBytes(), 0, s.length());

        int num = cs.getCookieCount();
        if (num != 3)
          throw new Exception("wrong number of cookies " + num);
        ServerCookie co = cs.getCookie(0);
        System.out.println("1 - Cookie: " + co);
        ServerCookie co2 = cs.getCookie(1);
        System.out.println("2 - Cookie: " + co2);
        ServerCookie co3 = cs.getCookie(2);
        System.out.println("3 - Cookie: " + co3);

        String coname = co.getName().toString();
        String coval  = co.getValue().toString();
        if ( ! name.equals(coname))
          throw new Exception("1 - wrong name " + coname + " != " + name);
        if ( ! val.equals(coval))
          throw new Exception("1 - wrong value " + coval + " != " + val);

        String coname2 = co2.getName().toString();
        String coval2  = co2.getValue().toString();
        if ( ! name2.equals(coname2))
          throw new Exception("2 - wrong name " + coname2 + " != " + name2);
        if ( ! val2.equals(coval2))
          throw new Exception("2 - wrong value " + coval2 + " != " + val2);

        String coname3 = co3.getName().toString();
        String coval3  = co3.getValue().toString();
        if ( ! name3.equals(coname3))
          throw new Exception("3 - wrong name " + coname3 + " != " + name3);
        if ( ! val2.equals(coval2))
          throw new Exception("3 - wrong value " + coval3 + " != " + val3);
    }
View Full Code Here

        Cookies cs=new Cookies(null);
        cs.processCookieHeader( s.getBytes(), 0, s.length());

        int num = cs.getCookieCount();
        if (num != 4)
          throw new Exception("wrong number of cookies " + num);
        ServerCookie co = cs.getCookie(0);
        System.out.println("1 - Cookie: " + co);
        ServerCookie co2 = cs.getCookie(1);
        System.out.println("2 - Cookie: " + co2);
        ServerCookie co3 = cs.getCookie(2);
        System.out.println("3 - Cookie: " + co3);
        ServerCookie co4 = cs.getCookie(3);
        System.out.println("4 - Cookie: " + co4);

        String coname = co.getName().toString();
        String coval  = co.getValue().toString();
        if ( ! name.equals(coname))
          throw new Exception("1 - wrong name " + coname + " != " + name);
        if ( ! val.equals(coval))
          throw new Exception("1 - wrong value " + coval + " != " + val);

        String coname2 = co2.getName().toString();
        String coval2  = co2.getValue().toString();
        if ( ! name2.equals(coname2))
          throw new Exception("2 - wrong name " + coname2 + " != " + name2);
        if ( ! val2.equals(coval2))
          throw new Exception("2 - wrong value " + coval2 + " != " + val2);

        String coname3 = co3.getName().toString();
        String coval3  = co3.getValue().toString();
        if ( ! name3.equals(coname3))
          throw new Exception("3 - wrong name " + coname3 + " != " + name3);
        if ( ! val3.equals(coval3))
          throw new Exception("3 - wrong value " + coval3 + " != " + val3);

        String coname4 = co4.getName().toString();
        String coval4  = co4.getValue().toString();
        if ( ! name4.equals(coname4))
          throw new Exception("4 - wrong name " + coname4 + " != " + name4);
        if ( ! val4.equals(coval4))
          throw new Exception("4 - wrong value " + coval4 + " != " + val4);
    }
View Full Code Here

            ums = (UserManager) ctx.getBean("org.apache.jetspeed.security.UserManager");
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            throw new Exception("Exception while setup SSO TEST");
        }
    }
View Full Code Here

      }
      catch(SSOException ssoex)
      {
          System.out.println("SSO Credential add FAILED for user:" + TEST_USER+ " site: " + TEST_URL);
          ssoex.printStackTrace();
          throw new Exception(ssoex.getMessage());
      }
      }
      else
      {
        System.out.println("SSO Credential found for user:" + TEST_USER+ " site: " + TEST_URL);
      }
     
      // Add another remote principal for the same user
      if ( ssoBroker.hasSSOCredentials(subject, TEST_URL2) == false)
      {
        System.out.println("No SSO Credential for user:" + TEST_USER+ " site: " + TEST_URL2);
       
        // Add credential
        try
      {
          ssoBroker.addCredentialsForSite(subject, REMOTE_USER2, TEST_URL2,REMOTE_PWD_1);
          System.out.println("SSO Credential added for user:" + TEST_USER+ " site: " + TEST_URL2);
      }
      catch(SSOException ssoex)
      {
          System.out.println("SSO Credential add FAILED for user:" + TEST_USER+ " site: " + TEST_URL2);
          ssoex.printStackTrace();
          throw new Exception(ssoex.getMessage());
      }
      }
      else
      {
        System.out.println("SSO Credential found for user:" + TEST_USER+ " site: " + TEST_URL2);
      }
     
      // Test if the credential where persisted
     
      // Test credential update
      SSOContext ssocontext = ssoBroker.getCredentials(subject, TEST_URL);
      System.out.println("SSO Credential: User:" + ssocontext.getUserName() + " Password: " + ssocontext.getPassword()+ " for site: " + TEST_URL);
     
      SSOContext ssocontext2 = ssoBroker.getCredentials(subject, TEST_URL2);
      System.out.println("SSO Credential: User:" + ssocontext.getUserName() + " Password: " + ssocontext.getPassword() + " for site: " + TEST_URL2);
     
      try
    {
        // Update Remote credential
        System.out.println("SSO Credential Update" );
        ssoBroker.updateCredentialsForSite(subject, REMOTE_USER , TEST_URL, REMOTE_PWD_2);
       
        ssocontext = ssoBroker.getCredentials(subject, TEST_URL);
        System.out.println("SSO Credential updated: User:" + ssocontext.getUserName() + " Password: " + ssocontext.getPassword());
       
    }
      catch(SSOException ssoex)
    {
        System.out.println("SSO Credential update FAILED for user:" + TEST_USER+ " site: " + TEST_URL);
        throw new Exception(ssoex.getMessage());
    }
     
      /*
       * For hypersonic the cascading deletes are not generated by Torque and the remove credentials
       * fails with a constraint error.
View Full Code Here

            url = new URL( "http://" + facade_url + "/CFEclipseFacade.cfc?method=execute&test=" + name );
          } else {
            url = new URL( "http://" + facade_url + "?method=execute&test=" + name );
          }
        } else {
          addCriticalErrorResult( new Exception( "No CFUnit Facde URL Set\nTo set this preference click 'Window' > 'Preferences...', then select 'CFEclipse' > 'CFUnit'" ) );
          notifyObservers();
          return null;
        }
         
      }
View Full Code Here

            gms = (GroupManager) ctx.getBean("org.apache.jetspeed.security.GroupManager");
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            throw new Exception("Exception while setup SSO TEST");
        }
    }
View Full Code Here

      }
      catch(SSOException ssoex)
      {
          System.out.println("SSO Credential add FAILED for Group:" + TEST_GROUP+ " site: " + TEST_URL);
          ssoex.printStackTrace();
          throw new Exception(ssoex.getMessage());
      }
        }
        else
        {
            System.out.println("Group:" + TEST_GROUP+ " site: " + TEST_URL + " has already a remote credential");
        }

        // Create Principal for User
    principal = new UserPrincipalImpl(TEST_GROUP_USER);
        principals = new HashSet();
        principals.add(principal);
        subject = new Subject(true, principals, new HashSet(), new HashSet())
       
        // User should have credential for site   
        if ( ssoBroker.hasSSOCredentials(subject, TEST_URL) == false)
      {
            // Group expansion failed. User not recognized
        System.out.println("No SSO Credential for user:" + TEST_GROUP_USER+ " site: " + TEST_URL);
       
        // Test failure
        try
            {
                ums.removeUser(TEST_GROUP_USER);
                gms.removeGroup(TEST_GROUP);
            }
            catch (SecurityException sex)
            {
                assertTrue("could not remove user and group. exception caught: " + sex, false);
            }
           
            throw new Exception("SSO Unit test for Group support failed");
      }
        else
        {
            // Group lookup succesful
        System.out.println("SSO Test for Group support successful\nSSO Credential for user:" + TEST_GROUP_USER + " site: " + TEST_URL + " found. User is member of Group " + TEST_GROUP);
View Full Code Here

      }
      catch(SSOException ssoex)
      {
          System.out.println("SSO Credential add FAILED for user:" + TEST_USER+ " site: " + TEST_URL);
          ssoex.printStackTrace();
          throw new Exception(ssoex.getMessage());
      }
      }
      else
      {
        System.out.println("SSO Credential found for user:" + TEST_USER+ " site: " + TEST_URL);
      }
     
      // Add another remote principal for the same user
      if ( ssoBroker.hasSSOCredentials(subject, TEST_URL2) == false)
      {
        System.out.println("No SSO Credential for user:" + TEST_USER+ " site: " + TEST_URL2);
       
        // Add credential
        try
      {
          ssoBroker.addCredentialsForSite(subject, REMOTE_USER2, TEST_URL2,REMOTE_PWD_1);
          System.out.println("SSO Credential added for user:" + TEST_USER+ " site: " + TEST_URL2);
      }
      catch(SSOException ssoex)
      {
          System.out.println("SSO Credential add FAILED for user:" + TEST_USER+ " site: " + TEST_URL2);
          ssoex.printStackTrace();
          throw new Exception(ssoex.getMessage());
      }
    }
      else
      {
        System.out.println("SSO Credential found for user:" + TEST_USER+ " site: " + TEST_URL2);
      }
     
      // Add the credentail again -- should get an error
    try
    {
      ssoBroker.addCredentialsForSite(subject, REMOTE_USER2, TEST_URL2,REMOTE_PWD_1);
      throw new Exception("Added same credentail twice -- API should prevent users from doing that.");
     
    }
    catch(SSOException ssoex)
    {
        System.out.println("Adding same SSO Credentialtwice failed (as expected) Message :" + ssoex.getMessage());
    }
    catch( Exception e)
    {
        throw new Exception("Adding SSO Credential twice throw an unandled exception. Error: " + e.getMessage());
    }
     
      // Test if the credential where persisted
     
      // Test credential update
      SSOContext ssocontext = ssoBroker.getCredentials(subject, TEST_URL);
      System.out.println("SSO Credential: User:" + ssocontext.getRemotePrincipalName() + " Password: " + ssocontext.getRemoteCredential()+ " for site: " + TEST_URL);
     
      SSOContext ssocontext2 = ssoBroker.getCredentials(subject, TEST_URL2);
      System.out.println("SSO Credential: User:" + ssocontext.getRemotePrincipalName() + " Password: " + ssocontext.getRemoteCredential() + " for site: " + TEST_URL2);
     
      try
    {
        // Update Remote credential
        System.out.println("SSO Credential Update" );
        ssoBroker.updateCredentialsForSite(subject, REMOTE_USER , TEST_URL, REMOTE_PWD_2);
       
        ssocontext = ssoBroker.getCredentials(subject, TEST_URL);
        System.out.println("SSO Credential updated: User:" + ssocontext.getRemotePrincipalName() + " Password: " + ssocontext.getRemoteCredential());
       
    }
      catch(SSOException ssoex)
    {
        System.out.println("SSO Credential update FAILED for user:" + TEST_USER+ " site: " + TEST_URL);
        throw new Exception(ssoex.getMessage());
    }
     
      /*
       * For hypersonic the cascading deletes are not generated by Torque and the remove credentials
       * fails with a constraint error.
View Full Code Here

public class RedeployTest extends TestCase {
    public void test() throws Exception {
        // create reference to openejb itests
        File file = JarLocation.jarLocation(BasicStatelessBean.class);
        if(!file.exists()){
            throw new Exception("File not found: " + file);
        }

        // These two objects pretty much encompas all the EJB Container
        ConfigurationFactory config = new ConfigurationFactory();
        Assembler assembler = new Assembler();
View Full Code Here

TOP

Related Classes of java.lang.Exception

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.