Package org.apache.commons.codec

Examples of org.apache.commons.codec.Encoder


  /** Must be thread-safe. */
  protected Encoder getEncoder() {
    // Unfortunately, Commons-Codec doesn't offer any thread-safe guarantees so we must play it safe and instantiate
    // every time.  A simple benchmark showed this as negligible.
    try {
      Encoder encoder = clazz.newInstance();
      // Try to set the maxCodeLength
      if(maxCodeLength != null && setMaxCodeLenMethod != null) {
        setMaxCodeLenMethod.invoke(encoder, maxCodeLength);
      }
      return encoder;
View Full Code Here


            (RssFeedServlet) client.newInvocation( "http://localhost/feeds/unauthorized-repo" ).getServlet();
        assertNotNull( servlet );

        WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/unauthorized-repo" );

        Encoder encoder = new Base64();
        String userPass = "unauthUser:unauthPass";
        String encodedUserPass = new String( (byte[]) encoder.encode( userPass.getBytes() ) );
        request.setHeaderField( "Authorization", "BASIC " + encodedUserPass );

        try
        {
            WebResponse resp = client.getResponse( request );
View Full Code Here

        MockHttpServletRequest request = new MockHttpServletRequest();
        request.setRequestURI( "/feeds/unauthorized-repo" );
        request.addHeader( "User-Agent", "Apache Archiva unit test" );
        request.setMethod( "GET" );

        Encoder encoder = new Base64();
        String userPass = "unauthUser:unauthPass";
        String encodedUserPass = new String( (byte[]) encoder.encode( userPass.getBytes() ) );
        request.addHeader( "Authorization", "BASIC " + encodedUserPass );

        MockHttpServletResponse mockHttpServletResponse = new MockHttpServletResponse();
        rssFeedServlet.doGet( request, mockHttpServletResponse );
View Full Code Here

  /** Must be thread-safe. */
  protected Encoder getEncoder() {
    // Unfortunately, Commons-Codec doesn't offer any thread-safe guarantees so we must play it safe and instantiate
    // every time.  A simple benchmark showed this as negligible.
    try {
      Encoder encoder = clazz.newInstance();
      // Try to set the maxCodeLength
      if(maxCodeLength != null && setMaxCodeLenMethod != null) {
        setMaxCodeLenMethod.invoke(encoder, maxCodeLength);
      }
      return encoder;
View Full Code Here

        assertNotNull( servlet );
   
       
        WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/unauthorized-repo" );
       
        Encoder encoder = new Base64();
        String userPass = "unauthUser:unauthPass";
        String encodedUserPass = new String( ( byte[] ) encoder.encode( userPass.getBytes() ) );       
        request.setHeaderField( "Authorization", "BASIC " + encodedUserPass );       
       
        try
        {
            WebResponse response = client.getResponse( request );
View Full Code Here

        assertNotNull( servlet );
   
       
        WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/unauthorized-repo" );
       
        Encoder encoder = new Base64();
        String userPass = "unauthUser:unauthPass";
        String encodedUserPass = new String( ( byte[] ) encoder.encode( userPass.getBytes() ) );       
        request.setHeaderField( "Authorization", "BASIC " + encodedUserPass );       
       
        try
        {
            WebResponse resp = client.getResponse( request );
View Full Code Here

    assertTokenStreamContents(filter, expected);
  }
 
  /** blast some random strings through the analyzer */
  public void testRandomStrings() throws IOException {
    Encoder encoders[] = new Encoder[] {
      new Metaphone(), new DoubleMetaphone(), new Soundex(), new RefinedSoundex(), new Caverphone2()
    };
   
    for (final Encoder e : encoders) {
      Analyzer a = new Analyzer() {
View Full Code Here

      checkRandomData(random(), b, 1000*RANDOM_MULTIPLIER);
    }
  }
 
  public void testEmptyTerm() throws IOException {
    Encoder encoders[] = new Encoder[] {
        new Metaphone(), new DoubleMetaphone(), new Soundex(), new RefinedSoundex(), new Caverphone2()
    };
    for (final Encoder e : encoders) {
      Analyzer a = new Analyzer() {
        @Override
View Full Code Here

     *
     * @throws EncoderException problem
     */
    @Test
    public void testEncoder() throws EncoderException {
        Encoder enc = new Base64();
        for (int i = 0; i < STRINGS.length; i++) {
            if (STRINGS[i] != null) {
                byte[] base64 = utf8(STRINGS[i]);
                byte[] binary = BYTES[i];
                boolean b = Arrays.equals(base64, (byte[]) enc.encode(binary));
                assertTrue("Encoder test-" + i, b);
            }
        }
    }
View Full Code Here

        MockHttpServletRequest request = new MockHttpServletRequest();
        request.setRequestURI( "/feeds/unauthorized-repo" );
        request.addHeader( "User-Agent", "Apache Archiva unit test" );
        request.setMethod( "GET" );

        Encoder encoder = new Base64();
        String userPass = "unauthUser:unauthPass";
        String encodedUserPass = new String( (byte[]) encoder.encode( userPass.getBytes() ) );
        request.addHeader( "Authorization", "BASIC " + encodedUserPass );

        MockHttpServletResponse mockHttpServletResponse = new MockHttpServletResponse();
        rssFeedServlet.doGet( request, mockHttpServletResponse );
View Full Code Here

TOP

Related Classes of org.apache.commons.codec.Encoder

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.