How to use wrapping against reexport issues shown in the project
authorJaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 09:54:15 +0200
changeset 97a1dd8447b30f
parent 96 368cc7f2f54e
child 98 9d2007487823
How to use wrapping against reexport issues shown in the project
samples/reexport/build.xml
samples/reexport/nbproject/project.xml
samples/reexport/src-testwrap/usage/UseQueryTest.java
samples/reexport/src-wrap1.0/query/Query.java
samples/reexport/src-wrap2.0/query/Query.java
     1.1 --- a/samples/reexport/build.xml	Sat Jun 14 09:54:14 2008 +0200
     1.2 +++ b/samples/reexport/build.xml	Sat Jun 14 09:54:15 2008 +0200
     1.3 @@ -15,21 +15,49 @@
     1.4              <param name="version" value="query"/>
     1.5              <param name="cp" value="build/api1.0/classes"/>
     1.6          </antcall>
     1.7 +        <antcall target="-build-one">
     1.8 +            <param name="version" value="wrap1.0"/>
     1.9 +            <param name="cp" value="build/api1.0/classes"/>
    1.10 +        </antcall>
    1.11 +        <antcall target="-build-one">
    1.12 +            <param name="version" value="wrap2.0"/>
    1.13 +            <param name="cp" value="build/api2.0/classes"/>
    1.14 +        </antcall>
    1.15          
    1.16          <antcall target="-build-one">
    1.17              <param name="version" value="test"/>
    1.18              <param name="cp" value="build/api1.0/classes:build/query/classes:${junit.jar}"/>
    1.19          </antcall>
    1.20 +        <antcall target="-build-one">
    1.21 +            <param name="version" value="testwrap"/>
    1.22 +            <param name="cp" value="build/wrap1.0/classes:${junit.jar}"/>
    1.23 +        </antcall>
    1.24      </target>
    1.25      
    1.26      <target name="test" depends="build">
    1.27          <echo level="info" message="Running the Test against Query and Version 1.0 of String. This should succeeds."/>
    1.28          <antcall target="-run-one">
    1.29              <param name="version" value="api1.0"/>
    1.30 +            <param name="queryversion" value="query"/>
    1.31 +            <param name="test" value="test"/>
    1.32          </antcall>
    1.33          <echo level="info" message="Running the Test against Query and Version 2.0 of String. This should fail."/>
    1.34          <antcall target="-run-one">
    1.35              <param name="version" value="api2.0"/>
    1.36 +            <param name="queryversion" value="query"/>
    1.37 +            <param name="test" value="test"/>
    1.38 +        </antcall>
    1.39 +        <echo level="info" message="Running the Test against Wrapping Query 1.0. This should succeeds."/>
    1.40 +        <antcall target="-run-one">
    1.41 +            <param name="version" value="api1.0"/>
    1.42 +            <param name="queryversion" value="wrap1.0"/>
    1.43 +            <param name="test" value="testwrap"/>
    1.44 +        </antcall>
    1.45 +        <echo level="info" message="Running the Test against Wrapping Query 2.0. This should succeeds."/>
    1.46 +        <antcall target="-run-one">
    1.47 +            <param name="version" value="api2.0"/>
    1.48 +            <param name="queryversion" value="wrap2.0"/>
    1.49 +            <param name="test" value="testwrap"/>
    1.50          </antcall>
    1.51      </target>
    1.52      
    1.53 @@ -43,17 +71,17 @@
    1.54      
    1.55      <target name="-run-one">
    1.56          <fail message="You need to specify API version number" unless="version"/>
    1.57 -        <mkdir dir="build/testresults"/>
    1.58 -        <junit dir="build/test/classes" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
    1.59 +        <mkdir dir="build/${test}results"/>
    1.60 +        <junit dir="build/${test}/classes" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
    1.61              <batchtest todir="build/testresults">
    1.62 -                <fileset dir="build/test/classes">
    1.63 +                <fileset dir="build/${test}/classes">
    1.64                      <filename name="**/*Test.class"/>
    1.65                  </fileset>
    1.66              </batchtest>
    1.67              <classpath>
    1.68                  <path location="build/${version}/classes"/>
    1.69 -                <path location="build/query/classes"/>
    1.70 -                <path location="build/test/classes"/>
    1.71 +                <path location="build/${queryversion}/classes"/>
    1.72 +                <path location="build/${test}/classes"/>
    1.73                  <path location="${junit.jar}"/>
    1.74              </classpath>
    1.75              <formatter type="brief" usefile="false"/>
     2.1 --- a/samples/reexport/nbproject/project.xml	Sat Jun 14 09:54:14 2008 +0200
     2.2 +++ b/samples/reexport/nbproject/project.xml	Sat Jun 14 09:54:15 2008 +0200
     2.3 @@ -29,11 +29,29 @@
     2.4                      <encoding>UTF-8</encoding>
     2.5                  </source-folder>
     2.6                  <source-folder>
     2.7 +                    <label>src-wrap1.0</label>
     2.8 +                    <type>java</type>
     2.9 +                    <location>src-wrap1.0</location>
    2.10 +                    <encoding>UTF-8</encoding>
    2.11 +                </source-folder>
    2.12 +                <source-folder>
    2.13 +                    <label>src-wrap2.0</label>
    2.14 +                    <type>java</type>
    2.15 +                    <location>src-wrap2.0</location>
    2.16 +                    <encoding>UTF-8</encoding>
    2.17 +                </source-folder>
    2.18 +                <source-folder>
    2.19                      <label>test</label>
    2.20                      <type>java</type>
    2.21                      <location>src-test</location>
    2.22                      <encoding>UTF-8</encoding>
    2.23                  </source-folder>
    2.24 +                <source-folder>
    2.25 +                    <label>test</label>
    2.26 +                    <type>java</type>
    2.27 +                    <location>src-testwrap</location>
    2.28 +                    <encoding>UTF-8</encoding>
    2.29 +                </source-folder>
    2.30              </folders>
    2.31              <ide-actions>
    2.32                  <action name="build">
    2.33 @@ -64,13 +82,25 @@
    2.34                          <location>src-api2.0</location>
    2.35                      </source-folder>
    2.36                      <source-folder style="packages">
    2.37 -                        <label>Query using api.String</label>
    2.38 +                        <label>Query reexporting api.String</label>
    2.39                          <location>src-query</location>
    2.40                      </source-folder>
    2.41                      <source-folder style="packages">
    2.42 -                        <label>Usage of the API</label>
    2.43 +                        <label>Query wrapping api.String 1.0</label>
    2.44 +                        <location>src-wrap1.0</location>
    2.45 +                    </source-folder>
    2.46 +                    <source-folder style="packages">
    2.47 +                        <label>Query wrapping api.String 2.0</label>
    2.48 +                        <location>src-wrap2.0</location>
    2.49 +                    </source-folder>
    2.50 +                    <source-folder style="packages">
    2.51 +                        <label>Usage of the reexporting Query</label>
    2.52                          <location>src-test</location>
    2.53                      </source-folder>
    2.54 +                    <source-folder style="packages">
    2.55 +                        <label>Usage of the wrapping Query</label>
    2.56 +                        <location>src-testwrap</location>
    2.57 +                    </source-folder>
    2.58                      <source-file>
    2.59                          <location>build.xml</location>
    2.60                      </source-file>
    2.61 @@ -98,10 +128,25 @@
    2.62                  <source-level>1.5</source-level>
    2.63              </compilation-unit>
    2.64              <compilation-unit>
    2.65 +                <package-root>src-wrap1.0</package-root>
    2.66 +                <classpath mode="compile">src-api1.0</classpath>
    2.67 +                <source-level>1.5</source-level>
    2.68 +            </compilation-unit>
    2.69 +            <compilation-unit>
    2.70 +                <package-root>src-wrap2.0</package-root>
    2.71 +                <classpath mode="compile">src-api2.0</classpath>
    2.72 +                <source-level>1.5</source-level>
    2.73 +            </compilation-unit>
    2.74 +            <compilation-unit>
    2.75                  <package-root>src-test</package-root>
    2.76                  <classpath mode="compile">src-api1.0:src-query:../libs/dist/junit-4.4.jar</classpath>
    2.77                  <source-level>1.5</source-level>
    2.78              </compilation-unit>
    2.79 +            <compilation-unit>
    2.80 +                <package-root>src-testwrap</package-root>
    2.81 +                <classpath mode="compile">src-wrap1.0:../libs/dist/junit-4.4.jar</classpath>
    2.82 +                <source-level>1.5</source-level>
    2.83 +            </compilation-unit>
    2.84          </java-data>
    2.85      </configuration>
    2.86  </project>
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/samples/reexport/src-testwrap/usage/UseQueryTest.java	Sat Jun 14 09:54:15 2008 +0200
     3.3 @@ -0,0 +1,23 @@
     3.4 +package usage;
     3.5 +
     3.6 +import org.junit.Test;
     3.7 +import static org.junit.Assert.*;
     3.8 +import query.Query;
     3.9 +
    3.10 +public class UseQueryTest {
    3.11 +    
    3.12 +    public UseQueryTest() {
    3.13 +    }            
    3.14 +
    3.15 +    @Test public void verifyThatQueryReturnsHello() {
    3.16 +        Query query = new Query();
    3.17 +        Query.Sequence reply = query.computeReply();
    3.18 +        assertEquals("Length is correct", 5, reply.length());
    3.19 +        
    3.20 +        assertEquals('H', reply.charAt(0));
    3.21 +        assertEquals('e', reply.charAt(1));
    3.22 +        assertEquals('l', reply.charAt(2));
    3.23 +        assertEquals('l', reply.charAt(3));
    3.24 +        assertEquals('o', reply.charAt(4));
    3.25 +    }
    3.26 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/samples/reexport/src-wrap1.0/query/Query.java	Sat Jun 14 09:54:15 2008 +0200
     4.3 @@ -0,0 +1,28 @@
     4.4 +package query;
     4.5 +
     4.6 +import api.String;
     4.7 +
     4.8 +// BEGIN: reexport.wrap1.0
     4.9 +public final class Query {
    4.10 +    public static final class Sequence {
    4.11 +        private String data;
    4.12 +        
    4.13 +        Sequence(String data) {
    4.14 +            this.data = data;
    4.15 +        }
    4.16 +
    4.17 +        public int length() {
    4.18 +            return data.length();
    4.19 +        }
    4.20 +
    4.21 +        public char charAt(int i) {
    4.22 +            return data.charAt(i);
    4.23 +        }
    4.24 +    }
    4.25 +    
    4.26 +    public Sequence computeReply() {
    4.27 +        char[] hello = { 'H', 'e', 'l', 'l', 'o' };
    4.28 +        return new Sequence(new String(hello));
    4.29 +    }
    4.30 +}
    4.31 +// END: reexport.wrap1.0
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/samples/reexport/src-wrap2.0/query/Query.java	Sat Jun 14 09:54:15 2008 +0200
     5.3 @@ -0,0 +1,28 @@
     5.4 +package query;
     5.5 +
     5.6 +import api.String;
     5.7 +
     5.8 +// BEGIN: reexport.wrap2.0
     5.9 +public final class Query {
    5.10 +    public static final class Sequence {
    5.11 +        private String data;
    5.12 +        
    5.13 +        Sequence(String data) {
    5.14 +            this.data = data;
    5.15 +        }
    5.16 +
    5.17 +        public int length() {
    5.18 +            return data.getSize();
    5.19 +        }
    5.20 +
    5.21 +        public char charAt(int i) {
    5.22 +            return data.charAt(i);
    5.23 +        }
    5.24 +    }
    5.25 +    
    5.26 +    public Sequence computeReply() {
    5.27 +        char[] hello = { 'H', 'e', 'l', 'l', 'o' };
    5.28 +        return new Sequence(new String(hello));
    5.29 +    }
    5.30 +}
    5.31 +// END: reexport.wrap2.0