ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r805273 - in /ant/sandbox/antlibs/compress/trunk/src: main/org/apache/ant/compress/ main/org/apache/ant/compress/conditions/ tests/antunit/
Date Tue, 18 Aug 2009 04:29:02 GMT
Author: bodewig
Date: Tue Aug 18 04:29:02 2009
New Revision: 805273

URL: http://svn.apache.org/viewvc?rev=805273&view=rev
Log:
initial cut at some conditions

Added:
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasGroupId.java
  (with props)
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasGroupName.java
  (with props)
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasMode.java
  (with props)
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasUserId.java
  (with props)
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasUserName.java
  (with props)
    ant/sandbox/antlibs/compress/trunk/src/tests/antunit/conditions-test.xml   (with props)
Modified:
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
    ant/sandbox/antlibs/compress/trunk/src/tests/antunit/tarentry-test.xml

Modified: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml?rev=805273&r1=805272&r2=805273&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml (original)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml Tue Aug
18 04:29:02 2009
@@ -82,4 +82,25 @@
     name="zipfileset"
     classname="org.apache.ant.compress.resources.ZipFileSet"
     />
+
+  <typedef
+     name="hasusername"
+    classname="org.apache.ant.compress.conditions.HasUserName"
+    />
+  <typedef
+     name="hasgroupname"
+     classname="org.apache.ant.compress.conditions.HasGroupName"
+    />
+  <typedef
+     name="hasuserid"
+     classname="org.apache.ant.compress.conditions.HasUserId"
+    />
+  <typedef
+     name="hasgroupid"
+     classname="org.apache.ant.compress.conditions.HasGroupId"
+    />
+  <typedef
+     name="hasmode"
+     classname="org.apache.ant.compress.conditions.HasMode"
+    />
 </antlib>

Added: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasGroupId.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasGroupId.java?rev=805273&view=auto
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasGroupId.java
(added)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasGroupId.java
Tue Aug 18 04:29:02 2009
@@ -0,0 +1,70 @@
+/*
+ *  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.
+ *
+ */
+
+package org.apache.ant.compress.conditions;
+
+import org.apache.ant.compress.resources.CommonsCompressArchiveResource;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.taskdefs.condition.Condition;
+import org.apache.tools.ant.types.resources.TarResource;
+
+/**
+ * Tests the group id of an archive entry.
+ */
+public class HasGroupId extends ProjectComponent implements Condition {
+    private CommonsCompressArchiveResource ccResource;
+    private TarResource antResource;
+    private int id = -1;
+
+    public void add(TarResource r) {
+        if (ccResource != null || antResource != null) {
+            throw new BuildException("only one resource can be tested");
+        }
+        antResource = r;
+    }
+
+    public void add(CommonsCompressArchiveResource r) {
+        if (ccResource != null || antResource != null) {
+            throw new BuildException("only one resource can be tested");
+        }
+        ccResource = r;
+    }
+
+    public void setId(int i) {
+        id = i;
+    }
+
+    protected void validate() throws BuildException {
+        if (ccResource == null && antResource == null) {
+            throw new BuildException("you must specify a resource");
+        }
+        if (id < 0) {
+            throw new BuildException("id is required");
+        }
+    }
+
+    public boolean eval() throws BuildException {
+        validate();
+        int actual = ccResource != null
+            ? ccResource.getGid() : antResource.getGid();
+        log("expected: " + id + ", actual: " + actual, Project.MSG_VERBOSE);
+        return id == actual;
+    }
+}

Propchange: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasGroupId.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasGroupName.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasGroupName.java?rev=805273&view=auto
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasGroupName.java
(added)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasGroupName.java
Tue Aug 18 04:29:02 2009
@@ -0,0 +1,69 @@
+/*
+ *  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.
+ *
+ */
+
+package org.apache.ant.compress.conditions;
+
+import org.apache.ant.compress.resources.TarResource;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.taskdefs.condition.Condition;
+
+/**
+ * Tests the group name of a tar entry.
+ */
+public class HasGroupName extends ProjectComponent implements Condition {
+    private TarResource ccResource;
+    private org.apache.tools.ant.types.resources.TarResource antResource;
+    private String name;
+
+    public void add(org.apache.tools.ant.types.resources.TarResource r) {
+        if (ccResource != null || antResource != null) {
+            throw new BuildException("only one resource can be tested");
+        }
+        antResource = r;
+    }
+
+    public void add(TarResource r) {
+        if (ccResource != null || antResource != null) {
+            throw new BuildException("only one resource can be tested");
+        }
+        ccResource = r;
+    }
+
+    public void setName(String n) {
+        name = n;
+    }
+
+    protected void validate() throws BuildException {
+        if (ccResource == null && antResource == null) {
+            throw new BuildException("you must specify a resource");
+        }
+        if (name == null) {
+            throw new BuildException("name is required");
+        }
+    }
+
+    public boolean eval() throws BuildException {
+        validate();
+        String actual = ccResource != null
+            ? ccResource.getGroup() : antResource.getGroup();
+        log("expected: " + name + ", actual: " + actual, Project.MSG_VERBOSE);
+        return name.equals(actual);
+    }
+}

Propchange: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasGroupName.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasMode.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasMode.java?rev=805273&view=auto
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasMode.java
(added)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasMode.java
Tue Aug 18 04:29:02 2009
@@ -0,0 +1,60 @@
+/*
+ *  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.
+ *
+ */
+
+package org.apache.ant.compress.conditions;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.taskdefs.condition.Condition;
+import org.apache.tools.ant.types.resources.ArchiveResource;
+
+/**
+ * Tests the mode of an archive entry.
+ */
+public class HasMode extends ProjectComponent implements Condition {
+    private ArchiveResource resource;
+    private int mode = -1;
+
+    public void add(ArchiveResource r) {
+        if (resource != null) {
+            throw new BuildException("only one resource can be tested");
+        }
+        resource = r;
+    }
+
+    public void setMode(int i) {
+        mode = i;
+    }
+
+    protected void validate() throws BuildException {
+        if (resource == null) {
+            throw new BuildException("you must specify a resource");
+        }
+        if (mode < 0) {
+            throw new BuildException("mode is required");
+        }
+    }
+
+    public boolean eval() throws BuildException {
+        validate();
+        int actual = resource.getMode();
+        log("expected: " + mode + ", actual: " + actual, Project.MSG_VERBOSE);
+        return mode == actual;
+    }
+}

Propchange: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasMode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasUserId.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasUserId.java?rev=805273&view=auto
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasUserId.java
(added)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasUserId.java
Tue Aug 18 04:29:02 2009
@@ -0,0 +1,70 @@
+/*
+ *  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.
+ *
+ */
+
+package org.apache.ant.compress.conditions;
+
+import org.apache.ant.compress.resources.CommonsCompressArchiveResource;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.taskdefs.condition.Condition;
+import org.apache.tools.ant.types.resources.TarResource;
+
+/**
+ * Tests the user id of an archive entry.
+ */
+public class HasUserId extends ProjectComponent implements Condition {
+    private CommonsCompressArchiveResource ccResource;
+    private TarResource antResource;
+    private int id = -1;
+
+    public void add(TarResource r) {
+        if (ccResource != null || antResource != null) {
+            throw new BuildException("only one resource can be tested");
+        }
+        antResource = r;
+    }
+
+    public void add(CommonsCompressArchiveResource r) {
+        if (ccResource != null || antResource != null) {
+            throw new BuildException("only one resource can be tested");
+        }
+        ccResource = r;
+    }
+
+    public void setId(int i) {
+        id = i;
+    }
+
+    protected void validate() throws BuildException {
+        if (ccResource == null && antResource == null) {
+            throw new BuildException("you must specify a resource");
+        }
+        if (id < 0) {
+            throw new BuildException("id is required");
+        }
+    }
+
+    public boolean eval() throws BuildException {
+        validate();
+        int actual = ccResource != null
+            ? ccResource.getUid() : antResource.getUid();
+        log("expected: " + id + ", actual: " + actual, Project.MSG_VERBOSE);
+        return id == actual;
+    }
+}

Propchange: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasUserId.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasUserName.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasUserName.java?rev=805273&view=auto
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasUserName.java
(added)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasUserName.java
Tue Aug 18 04:29:02 2009
@@ -0,0 +1,69 @@
+/*
+ *  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.
+ *
+ */
+
+package org.apache.ant.compress.conditions;
+
+import org.apache.ant.compress.resources.TarResource;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.taskdefs.condition.Condition;
+
+/**
+ * Tests the user name of a tar entry.
+ */
+public class HasUserName extends ProjectComponent implements Condition {
+    private TarResource ccResource;
+    private org.apache.tools.ant.types.resources.TarResource antResource;
+    private String name;
+
+    public void add(org.apache.tools.ant.types.resources.TarResource r) {
+        if (ccResource != null || antResource != null) {
+            throw new BuildException("only one resource can be tested");
+        }
+        antResource = r;
+    }
+
+    public void add(TarResource r) {
+        if (ccResource != null || antResource != null) {
+            throw new BuildException("only one resource can be tested");
+        }
+        ccResource = r;
+    }
+
+    public void setName(String n) {
+        name = n;
+    }
+
+    protected void validate() throws BuildException {
+        if (ccResource == null && antResource == null) {
+            throw new BuildException("you must specify a resource");
+        }
+        if (name == null) {
+            throw new BuildException("name is required");
+        }
+    }
+
+    public boolean eval() throws BuildException {
+        validate();
+        String actual = ccResource != null
+            ? ccResource.getUserName() : antResource.getUserName();
+        log("expected: " + name + ", actual: " + actual, Project.MSG_VERBOSE);
+        return name.equals(actual);
+    }
+}

Propchange: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/conditions/HasUserName.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ant/sandbox/antlibs/compress/trunk/src/tests/antunit/conditions-test.xml
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/tests/antunit/conditions-test.xml?rev=805273&view=auto
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/tests/antunit/conditions-test.xml (added)
+++ ant/sandbox/antlibs/compress/trunk/src/tests/antunit/conditions-test.xml Tue Aug 18 04:29:02
2009
@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<project default="antunit"
+         xmlns:au="antlib:org.apache.ant.antunit"
+         xmlns:cond="antlib:org.apache.tools.ant.types.conditions"
+         xmlns:cmp="antlib:org.apache.ant.compress">
+
+  <import file="antunit-base.xml" />
+
+  <target name="fail-testHasUserName">
+    <au:assertTrue>
+      <cmp:hasusername name="bodewig">
+        <tarentry name="asf-logo.gif">
+          <file file="../resources/asf-logo.gif.tar"/>
+        </tarentry>
+      </cmp:hasusername>
+    </au:assertTrue>
+  </target>
+
+  <target name="fail-testHasGroupName">
+    <au:assertTrue>
+      <cmp:hasgroupname name="bodewig">
+        <tarentry name="asf-logo.gif">
+          <file file="../resources/asf-logo.gif.tar"/>
+        </tarentry>
+      </cmp:hasgroupname>
+    </au:assertTrue>
+  </target>
+
+  <target name="fail-testHasUserId">
+    <au:assertTrue>
+      <cmp:hasuserid id="500">
+        <tarentry name="asf-logo.gif">
+          <file file="../resources/asf-logo.gif.tar"/>
+        </tarentry>
+      </cmp:hasuserid>
+    </au:assertTrue>
+  </target>
+
+  <target name="fail-testHasGroupId">
+    <au:assertTrue>
+      <cmp:hasgroupid id="500">
+        <tarentry name="asf-logo.gif">
+          <file file="../resources/asf-logo.gif.tar"/>
+        </tarentry>
+      </cmp:hasgroupid>
+    </au:assertTrue>
+  </target>
+
+  <target name="testHasMode">
+    <au:assertTrue>
+      <cmp:hasmode mode="33188">
+        <tarentry name="asf-logo.gif">
+          <file file="../resources/asf-logo.gif.tar"/>
+        </tarentry>
+      </cmp:hasmode>
+    </au:assertTrue>
+  </target>
+
+</project>

Propchange: ant/sandbox/antlibs/compress/trunk/src/tests/antunit/conditions-test.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ant/sandbox/antlibs/compress/trunk/src/tests/antunit/tarentry-test.xml
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/tests/antunit/tarentry-test.xml?rev=805273&r1=805272&r2=805273&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/tests/antunit/tarentry-test.xml (original)
+++ ant/sandbox/antlibs/compress/trunk/src/tests/antunit/tarentry-test.xml Tue Aug 18 04:29:02
2009
@@ -64,5 +64,21 @@
         </cmp:tarentry>
       </cond:islastmodified>
     </au:assertTrue>
+    <!--
+    <au:assertTrue>
+      <cmp:hasusername name="bodewig">
+        <cmp:tarentry name="asf-logo.gif">
+          <file file="../resources/asf-logo.gif.tar"/>
+        </cmp:tarentry>
+      </cmp:hasusername>
+    </au:assertTrue>
+    <au:assertTrue>
+      <cmp:hasgroupname name="bodewig">
+        <cmp:tarentry name="asf-logo.gif">
+          <file file="../resources/asf-logo.gif.tar"/>
+        </cmp:tarentry>
+      </cmp:hasgroupname>
+    </au:assertTrue>
+    -->
   </target>
 </project>



Mime
View raw message