knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmin...@apache.org
Subject [1/5] knox git commit: [KNOX-670] - Knox should be able to sost simple web apps
Date Thu, 25 Feb 2016 20:54:21 GMT
Repository: knox
Updated Branches:
  refs/heads/master 82539e402 -> a70a3b56c


http://git-wip-us.apache.org/repos/asf/knox/blob/a70a3b56/gateway-test/src/test/resources/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest/test-apps/minimal-test-app/rewrite.xml
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/resources/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest/test-apps/minimal-test-app/rewrite.xml
b/gateway-test/src/test/resources/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest/test-apps/minimal-test-app/rewrite.xml
new file mode 100644
index 0000000..656e229
--- /dev/null
+++ b/gateway-test/src/test/resources/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest/test-apps/minimal-test-app/rewrite.xml
@@ -0,0 +1,17 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<rules/>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/a70a3b56/gateway-test/src/test/resources/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest/test-apps/minimal-test-app/service.xml
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/resources/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest/test-apps/minimal-test-app/service.xml
b/gateway-test/src/test/resources/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest/test-apps/minimal-test-app/service.xml
new file mode 100644
index 0000000..aa16c2c
--- /dev/null
+++ b/gateway-test/src/test/resources/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest/test-apps/minimal-test-app/service.xml
@@ -0,0 +1,21 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<service role="MINIMAL_TEST_APP" name="minimal-test-app" version="1.0.0">
+    <routes>
+        <route path="/**?**"/>
+    </routes>
+</service>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/a70a3b56/gateway-util-common/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-util-common/pom.xml b/gateway-util-common/pom.xml
index 736cc6b..1cbe38d 100644
--- a/gateway-util-common/pom.xml
+++ b/gateway-util-common/pom.xml
@@ -48,10 +48,14 @@
     </build>
 
     <dependencies>
-				<dependency>
-					<groupId>com.fasterxml.jackson.core</groupId>
-					<artifactId>jackson-databind</artifactId>
-				</dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+        </dependency>
 
         <!-- ********** ********** ********** ********** ********** ********** -->
         <!-- ********** Test Dependencies                           ********** -->
@@ -66,7 +70,7 @@
             <groupId>${gateway-group}</groupId>
             <artifactId>gateway-i18n</artifactId>
         </dependency>
-		<dependency>
+        <dependency>
             <groupId>org.apache.directory.server</groupId>
             <artifactId>apacheds-jdbm</artifactId>
         </dependency>
@@ -97,7 +101,7 @@
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
-            <dependency>
+        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-log4j12</artifactId>
         </dependency>

http://git-wip-us.apache.org/repos/asf/knox/blob/a70a3b56/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/Urls.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/Urls.java b/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/Urls.java
index 4d31150..f10b0d6 100644
--- a/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/Urls.java
+++ b/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/Urls.java
@@ -17,11 +17,15 @@
  */
 package org.apache.hadoop.gateway.util;
 
+import java.io.UnsupportedEncodingException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.net.URLCodec;
+
 /**
  *
  */
@@ -108,4 +112,56 @@ public class Urls {
     }
     return domain.substring(idx);
   }
+
+  public static String encode( String str ) {
+    URLCodec codec = new URLCodec();
+    try {
+      return codec.encode( str, "UTF-8" );
+    } catch( UnsupportedEncodingException e ) {
+      throw new IllegalArgumentException( e );
+    }
+  }
+
+  public static String decode( String str ) {
+    URLCodec codec = new URLCodec();
+    try {
+      return codec.decode( str, "UTF-8" );
+    } catch( UnsupportedEncodingException e ) {
+      throw new IllegalArgumentException( e );
+    } catch( DecoderException e ) {
+      throw new IllegalArgumentException( e );
+    }
+  }
+
+  public static String trimLeadingAndTrailingSlash( String s ) {
+    if( s == null ) {
+      return "";
+    } else {
+      int b = 0;
+      int e = s.length();
+      while( b < e && s.charAt( b ) == '/' ) { b++; }
+      while( e > b && s.charAt( e-1 ) == '/' ) { e--; }
+      return s.substring( b, e );
+    }
+  }
+
+  public static String trimLeadingAndTrailingSlashJoin( String... parts ) {
+    StringBuilder s = new StringBuilder();
+    if( parts != null ) {
+      String p = "";
+      String n = "";
+      for( int i=0; i<parts.length; i++ ) {
+        n = trimLeadingAndTrailingSlash( parts[i] );
+        if( !n.isEmpty() ) {
+          if( !p.isEmpty() ) {
+            s.append( '/' );
+          }
+          s.append( n );
+          p = n;
+        }
+      }
+    }
+    return s.toString();
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/a70a3b56/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/XmlUtils.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/XmlUtils.java
b/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/XmlUtils.java
new file mode 100644
index 0000000..1536793
--- /dev/null
+++ b/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/XmlUtils.java
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.gateway.util;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+public class XmlUtils {
+
+  public static Document readXml( File file ) throws ParserConfigurationException, IOException,
SAXException {
+    DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
+    DocumentBuilder b = f.newDocumentBuilder();
+    Document d = b.parse( file );
+    return d;
+  }
+
+  public static void writeXml( Document document, Writer writer ) throws TransformerException
{
+    TransformerFactory f = TransformerFactory.newInstance();
+//    if( f.getClass().getPackage().getName().equals( "com.sun.org.apache.xalan.internal.xsltc.trax"
) ) {
+      f.setAttribute( "indent-number", 4 );
+//    }
+    Transformer t = f.newTransformer();
+    t.setOutputProperty( OutputKeys.INDENT, "yes" );
+    t.setOutputProperty( "{xml.apache.org/xslt}indent-amount", "4" );
+    DOMSource s = new DOMSource( document );
+    StreamResult r = new StreamResult( writer );
+    t.transform( s, r );
+  }
+
+  public static void writeXml( Document document, File file ) throws TransformerException,
IOException {
+    writeXml( document, new FileWriter( file ) );
+  }
+
+
+  public static Document createDocument() throws ParserConfigurationException {
+    DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
+    DocumentBuilder b = f.newDocumentBuilder();
+    Document d = b.newDocument();
+    d.setXmlStandalone( true );
+    return d;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/a70a3b56/gateway-util-common/src/test/java/org/apache/hadoop/gateway/util/UrlsTest.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/test/java/org/apache/hadoop/gateway/util/UrlsTest.java
b/gateway-util-common/src/test/java/org/apache/hadoop/gateway/util/UrlsTest.java
index f55c79c..ac6ce93 100644
--- a/gateway-util-common/src/test/java/org/apache/hadoop/gateway/util/UrlsTest.java
+++ b/gateway-util-common/src/test/java/org/apache/hadoop/gateway/util/UrlsTest.java
@@ -20,6 +20,8 @@ package org.apache.hadoop.gateway.util;
 import org.junit.Assert;
 import org.junit.Test;
 
+import static junit.framework.TestCase.assertEquals;
+
 public class UrlsTest {
 
   /**
@@ -54,4 +56,30 @@ public class UrlsTest {
     // ip addresses can not be wildcarded - may be a completely different domain
     Assert.assertEquals(Urls.getDomainName("http://127.0.0.1", null), null);
   }
+
+  @Test
+  public void testTrimLeadingAndTrailingSlash() {
+    assertEquals( "", Urls.trimLeadingAndTrailingSlash( null ) );
+    assertEquals( "", Urls.trimLeadingAndTrailingSlash( "" ) );
+    assertEquals( "", Urls.trimLeadingAndTrailingSlash( "/" ) );
+    assertEquals( "", Urls.trimLeadingAndTrailingSlash( "//" ) );
+    assertEquals( "x", Urls.trimLeadingAndTrailingSlash( "x" ) );
+    assertEquals( "x/x", Urls.trimLeadingAndTrailingSlash( "x/x" ) );
+    assertEquals( "x", Urls.trimLeadingAndTrailingSlash( "/x/" ) );
+    assertEquals( "x/x", Urls.trimLeadingAndTrailingSlash( "x/x" ) );
+  }
+
+  @Test
+  public void testTrimLeadingAndTrailingSlashJoin() throws Exception {
+    assertEquals( "", Urls.trimLeadingAndTrailingSlashJoin( null ) );
+    assertEquals( "", Urls.trimLeadingAndTrailingSlashJoin( "" ) );
+    assertEquals( "", Urls.trimLeadingAndTrailingSlashJoin( "", "" ) );
+    assertEquals( "x", Urls.trimLeadingAndTrailingSlashJoin( "x" ) );
+    assertEquals( "x", Urls.trimLeadingAndTrailingSlashJoin( "x", "" ) );
+    assertEquals( "x", Urls.trimLeadingAndTrailingSlashJoin( "", "x", "" ) );
+    assertEquals( "x/x", Urls.trimLeadingAndTrailingSlashJoin( "", "x", "", "", "x" ) );
+    assertEquals( "x/x", Urls.trimLeadingAndTrailingSlashJoin( null, "x", null, null, "x"
) );
+    assertEquals( "x/y/z", Urls.trimLeadingAndTrailingSlashJoin( "x", "y", "z" ) );
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/a70a3b56/gateway-util-urltemplate/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-util-urltemplate/pom.xml b/gateway-util-urltemplate/pom.xml
index df91f2e..2f5c309 100644
--- a/gateway-util-urltemplate/pom.xml
+++ b/gateway-util-urltemplate/pom.xml
@@ -64,18 +64,18 @@
             <scope>test</scope>
         </dependency>
 
-        <!--
         <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>javax.servlet-api</artifactId>
             <scope>test</scope>
         </dependency>
-        -->
+        <!--
         <dependency>
             <groupId>org.eclipse.jetty.orbit</groupId>
             <artifactId>javax.servlet</artifactId>
             <scope>test</scope>
         </dependency>
+        -->
 
         <dependency>
             <groupId>org.hamcrest</groupId>

http://git-wip-us.apache.org/repos/asf/knox/blob/a70a3b56/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index c180475..c87486a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -99,7 +99,7 @@
         <gateway-version>0.9.0-SNAPSHOT</gateway-version>
         <gateway-group>org.apache.knox</gateway-group>
         <hadoop-version>2.2.0</hadoop-version>
-        <jetty-version>8.1.14.v20131031</jetty-version>
+        <jetty-version>8.1.18.v20150929</jetty-version>
         <surefire-version>2.16</surefire-version>
         <failsafe-version>2.19.1</failsafe-version>
     </properties>
@@ -670,10 +670,18 @@
                 <version>${jetty-version}</version>
             </dependency>
             <dependency>
+                <groupId>javax.servlet</groupId>
+                <artifactId>javax.servlet-api</artifactId>
+                <version>3.0.1</version>
+            </dependency>
+
+            <!--
+            <dependency>
                 <groupId>org.eclipse.jetty.orbit</groupId>
                 <artifactId>javax.servlet</artifactId>
                 <version>3.0.0.v201112011016</version>
             </dependency>
+            -->
             <!--
             <dependency>
                 <groupId>org.eclipse.jetty</groupId>
@@ -719,6 +727,11 @@
                 <artifactId>httpclient</artifactId>
                 <version>4.3.6</version>
             </dependency>
+            <dependency>
+                <groupId>joda-time</groupId>
+                <artifactId>joda-time</artifactId>
+                <version>2.9.2</version>
+            </dependency>
 
             <!--
             <dependency>
@@ -946,22 +959,22 @@
             <dependency>
                 <groupId>org.jboss.shrinkwrap</groupId>
                 <artifactId>shrinkwrap-api</artifactId>
-                <version>1.0.1</version>
+                <version>1.2.3</version>
             </dependency>
             <dependency>
                 <groupId>org.jboss.shrinkwrap</groupId>
                 <artifactId>shrinkwrap-impl-base</artifactId>
-                <version>1.0.1</version>
+                <version>1.2.3</version>
             </dependency>
             <dependency>
                 <groupId>org.jboss.shrinkwrap.descriptors</groupId>
                 <artifactId>shrinkwrap-descriptors-api-javaee</artifactId>
-                <version>2.0.0-alpha-4</version>
+                <version>2.0.0-alpha-8</version>
             </dependency>
             <dependency>
                 <groupId>org.jboss.shrinkwrap.descriptors</groupId>
                 <artifactId>shrinkwrap-descriptors-impl-javaee</artifactId>
-                <version>2.0.0-alpha-4</version>
+                <version>2.0.0-alpha-8</version>
             </dependency>
             <dependency>
                 <groupId>org.apache.directory.server</groupId>
@@ -1037,6 +1050,11 @@
                 <artifactId>gateway-demo-ldap-launcher</artifactId>
                 <version>${gateway-version}</version>
             </dependency>
+            <dependency>
+                <groupId>net.lingala.zip4j</groupId>
+                <artifactId>zip4j</artifactId>
+                <version>1.3.2</version>
+            </dependency>
 
             <!-- ********** ********** ********** ********** ********** ********** -->
             <!-- ********** Test Dependencies                           ********** -->
@@ -1135,6 +1153,7 @@
                 <scope>test</scope>
             </dependency>
 
+
         </dependencies>
     </dependencyManagement>
 


Mime
View raw message