Package org.apache.hadoop.gateway.filter.rewrite.api

Examples of org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteProcessor


    UrlRewriteRuleDescriptor rule = descriptor.addRule( "test-rule" );
    rule.pattern( "{*}://{host}:{*}/{**}?{**}" );
    UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep( "rewrite" );
    rewrite.template( "{*}://{$hostmap(host)}:{*}/{**}?{**}" );

    UrlRewriteProcessor rewriter = new UrlRewriteProcessor();
    rewriter.initialize( environment, descriptor );

    Template input = Parser.parse( "test-scheme://test-inbound-host:42/test-path/test-file?test-name=test-value" );
    Template output = rewriter.rewrite( resolver, input, UrlRewriter.Direction.IN, null );
    //System.out.println( output );
    assertThat( output, notNullValue() );
    assertThat( output.getHost().getFirstValue().getPattern(), is( "test-inbound-rewritten-host" ) );
  }
View Full Code Here


    UrlRewriteRuleDescriptor rule = descriptor.addRule( "test-rule" );
    rule.pattern( "{*}://{host}:{*}/{**}?{**}" );
    UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep( "rewrite" );
    rewrite.template( "{*}://test-static-host:{*}/{**}?server={$hostmap(host)}&{**}" );

    UrlRewriteProcessor rewriter = new UrlRewriteProcessor();
    rewriter.initialize( environment, descriptor );

    Template input = Parser.parse(
        "test-scheme://test-external-host:42/test-path/test-file?test-name-1=test-value-1&test-name-2=test-value-2" );
    Template output = rewriter.rewrite( resolver, input, UrlRewriter.Direction.OUT, "test-rule" );
    //System.out.println( output );
    assertThat( output, notNullValue() );
    assertThat( output.getHost().getFirstValue().getPattern(), is( "test-static-host" ) );
    assertThat( output.getQuery().get( "server" ).getFirstValue().getPattern(), is( "test-external-host" ) );
    assertThat( output.getQuery().get( "server" ).getValues().size(), is( 1 ) );
View Full Code Here

public class UrlRewriteResponseTest {

  @Test
  public void testResolve() throws Exception {

    UrlRewriteProcessor rewriter = EasyMock.createNiceMock( UrlRewriteProcessor.class );

    ServletContext context = EasyMock.createNiceMock( ServletContext.class );
    EasyMock.expect( context.getServletContextName() ).andReturn( "test-cluster-name" ).anyTimes();
    EasyMock.expect( context.getInitParameter( "test-init-param-name" ) ).andReturn( "test-init-param-value" ).anyTimes();
    EasyMock.expect( context.getAttribute( UrlRewriteServletContextListener.PROCESSOR_ATTRIBUTE_NAME ) ).andReturn( rewriter ).anyTimes();
View Full Code Here

    UrlRewriteRuleDescriptor rule = descriptor.addRule( "test-rule" );
    rule.pattern( "{*}://{host}:{*}/{**}?{qp1}&{qp2}&{**}" );
    UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep( "rewrite" );
    rewrite.template( "{*}://test-static-host:{*}/{qp1}/{qp2}/{**}?server={$hostmap(host)}&{**}" );

    UrlRewriteProcessor rewriter = new UrlRewriteProcessor();
    rewriter.initialize( environment, descriptor );

    Template input = Parser.parse(
        "test-scheme://test-external-host:42/test-path/test-file?qp1=qp1-val&qp2=qp2-val&test-name-1=test-value-1&test-name-2=test-value-2" );
    Template output = rewriter.rewrite( resolver, input, UrlRewriter.Direction.OUT, "test-rule" );
    //System.out.println( output );
    assertThat( output, notNullValue() );
    assertThat( output.getHost().getFirstValue().getPattern(), is( "test-static-host" ) );
    assertThat( output.getQuery().get( "server" ).getFirstValue().getPattern(), is( "test-external-host" ) );
    assertThat( output.getQuery().get( "server" ).getValues().size(), is( 1 ) );
View Full Code Here

    UrlRewriteRuleDescriptor rule = descriptor.addRule( "test-rule" );
    rule.pattern( "{*}://{host}:{*}/{**}?{**}" );
    UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep( "rewrite" );
    rewrite.template( "{*}://{$hostmap(host)}:{*}/{**}?{**}" );

    UrlRewriteProcessor rewriter = new UrlRewriteProcessor();
    rewriter.initialize( environment, descriptor );

    Template input = Parser.parse(
        "test-scheme://test-inbound-unmapped-host:42/test-path/test-file?test-name-1=test-value-1&test-name-2=test-value-2" );
    Template output = rewriter.rewrite( resolver, input, UrlRewriter.Direction.IN, null );
    //System.out.println( output );
    assertThat( output, notNullValue() );
    assertThat( output.getHost().getFirstValue().getPattern(), is( "test-inbound-unmapped-host" ) );
  }
View Full Code Here

    UrlRewriteRuleDescriptor rule = descriptor.addRule( "test-rule" );
    rule.pattern( "{*}://{host}:{*}/{**}?{**}" );
    UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep( "rewrite" );
    rewrite.template( "{*}://{$invalid-function(host)}:{*}/{**}?{**}" );

    UrlRewriteProcessor rewriter = new UrlRewriteProcessor();
    rewriter.initialize( environment, descriptor );

    Template input = Parser.parse( "test-scheme://test-inbound-host:42/test-path/test-file?test-name=test-value" );
    Template output = rewriter.rewrite( resolver, input, UrlRewriter.Direction.IN, null );
    //System.out.println( output );
    assertThat( output, notNullValue() );
    assertThat( output.getHost().getFirstValue().getPattern(), is( "$invalid-function(host)" ) );
  }
View Full Code Here

    UrlRewriteRuleDescriptor rule = descriptor.addRule( "test-rule" );
    rule.pattern( "{*}://{host}:{*}/{**}?{**}" );
    UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep( "rewrite" );
    rewrite.template( "{*}://{$invalid-function(host)}:{*}/{**}?{**}" );

    UrlRewriteProcessor rewriter = new UrlRewriteProcessor();
    rewriter.initialize( environment, descriptor );

    Template input = Parser.parse( "test-scheme://test-inbound-host:42/test-path/test-file?test-name=test-value" );
    Template output = rewriter.rewrite( resolver, input, UrlRewriter.Direction.IN, null );
    //System.out.println( output );
    assertThat( output, notNullValue() );
    assertThat( output.getHost().getFirstValue().getPattern(), is( "$invalid-function(host)" ) );
  }
View Full Code Here

    UrlRewriteRuleDescriptor rule = descriptor.addRule( "test-rule" );
    rule.pattern( "{*}://{host}:{*}/{**}?{**}" );
    UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep( "rewrite" );
    rewrite.template( "{*}://{$hostmap(host)}:{*}/{**}?{**}" );

    UrlRewriteProcessor rewriter = new UrlRewriteProcessor();
    rewriter.initialize( environment, descriptor );

    Template input = Parser.parse( "test-scheme://test-inbound-host:42/test-path/test-file?test-name=test-value" );
    Template output = rewriter.rewrite( resolver, input, UrlRewriter.Direction.IN, null );
    //System.out.println( output );
    assertThat( output, notNullValue() );
    assertThat( output.getHost().getFirstValue().getPattern(), is( "test-inbound-host" ) );
  }
View Full Code Here

    UrlRewriteRuleDescriptor rule = descriptor.addRule( "test-rule" );
    rule.pattern( "{*}://{host}:{*}/{**}?{**}" );
    UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep( "rewrite" );
    rewrite.template( "{*}://{$hostmap(host)}:{*}/{**}?{**}" );

    UrlRewriteProcessor rewriter = new UrlRewriteProcessor();
    rewriter.initialize( environment, descriptor );

    Template input = Parser.parse( "test-scheme://test-inbound-host:42/test-path/test-file?test-name=test-value" );
    Template output = rewriter.rewrite( resolver, input, UrlRewriter.Direction.IN );
    System.out.println( output );
    assertThat( output, notNullValue() );
    assertThat( output.getHost().getFirstValue().getPattern(), is( "test-inbound-rewritten-host" ) );
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteProcessor

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.