Changeset 2858
- Timestamp:
- 11/07/07 16:33:03 (5 years ago)
- Files:
-
- trunk/build.xml (modified) (1 diff)
- trunk/ivy.xml (modified) (1 diff)
- trunk/src/test/java/org/sarugo/xtc/restlet/TemplateDirectoryTests.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build.xml
r2854 r2858 1 <project name="xtc" default="help" xmlns:ivy="antlib:org.apache.ivy.ant">1 <project name="xtc" default="help"> 2 2 <!-- Sarugo common ant configuration --> 3 3 <property name="ant.lib.dir" value="ant" /> 4 4 <property name="ant.server" value="http://ant.sarugo.org" /> 5 <property name="sarugo.ant.file" value="${ant.lib.dir}/common-build.xml" /> 6 <!-- Ant-Eclipse --> 7 <property name="ant.eclipse.url" value="http://trac.sarugo.org/ant-eclipse/attachment/wiki/WikiStart/ant-eclipse.jar?format=raw" /> 8 <property name="ant.eclipse.file" value="${ant.lib.dir}/ant-eclipse.jar" /> 9 <condition property="download-ant.eclipse.required"> 5 <property name="build.common.url" value="${ant.server}/build-common.xml" /> 6 <property name="build.common.file" value="${ant.lib.dir}/build-common.xml" /> 7 <condition property="download-build.common.required"> 10 8 <not> 11 <available file="${ ant.eclipse.file}" type="file" />9 <available file="${build.common.file}" type="file" /> 12 10 </not> 13 11 </condition> 14 <!-- Ivy configuration -->15 <property name="ivy.server" value="${ant.server}/ivy" />16 <property name="ivy.version" value="2.0.0-alpha-1-incubating" />17 <property name="ivy.dest.file" value="${ant.lib.dir}/ivy-${ivy.version}.jar" />18 <condition property="download-ivy.required">19 <not>20 <available file="${ivy.dest.file}" type="file" />21 </not>22 </condition>23 <!-- Project Configuration -->24 <property name="src.dir" value="src" />25 <property name="build.dir" value="build" />26 <property name="dist.dir" value="dist" />27 <property name="lib.dir" value="lib" />28 <property file="build.properties"/>29 12 <condition property="bootstrap.required"> 30 13 <not> 31 <and> 32 <available file="${ant.lib.dir}" type="dir" /> 33 <available file="${lib.dir}" type="dir" /> 34 </and> 14 <available file="${ant.lib.dir}" type="dir" /> 35 15 </not> 36 16 </condition> 37 17 38 <target name="download-ivy" if="download-ivy.required"> 39 <!-- download Ivy from web site so that it can be used even without any special installation --> 40 <get src="${ivy.server}/${ivy.version}/ivy-${ivy.version}.jar" dest="${ivy.dest.file}" usetimestamp="true" /> 18 <target name="download-build.common"> 19 <get src="${build.common.url}" dest="${build.common.file}" usetimestamp="true" /> 41 20 </target> 42 21 43 <target name="download-ant.eclipse" if="download-ant.eclipse.required"> 44 <get src="${ant.eclipse.url}" dest="${ant.eclipse.file}"/> 45 </target> 22 <import file="${build.common.file}" optional="true"/> 46 23 47 <target name="bootstrap" description="Download s common ant scripts and libraries">24 <target name="bootstrap" description="Download build dependencies and libraries"> 48 25 <mkdir dir="${ant.lib.dir}" /> 49 <antcall target="download-ivy" /> 50 <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpath="${ivy.dest.file}" /> 51 <ivy:configure file="ivysettings.xml" /> 52 <ivy:resolve file="ivy.xml" /> 53 <ivy:retrieve pattern="${lib.dir}/[artifact]-[revision].[ext]" /> 54 <antcall target="download-ant.eclipse" /> 55 <taskdef name="eclipse" classname="org.sarugo.ant.eclipse.EclipseTask" classpath="${ant.eclipse.file}" /> 56 <eclipse> 57 <sourcepath> 58 <dirset dir="${src.dir}" includes="main/*" /> 59 <dirset dir="${src.dir}" includes="test/*" /> 60 </sourcepath> 61 <globmapper from="${src.dir}/*" to="${build.dir}/*"/> 62 <classpath> 63 <fileset dir="${lib.dir}" includes="**/*.jar" /> 64 </classpath> 65 </eclipse> 66 </target> 67 68 <target name="pre-init" if="bootstrap.required"> 69 <fail message="You need to run ant bootstrap" /> 70 </target> 71 72 <target name="init" depends="pre-init"> 73 <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpath="${ivy.dest.file}" /> 74 </target> 75 76 <target name="compile" depends="init" description="Compile the library"> 77 <mkdir dir="${build.dir}/main/java" /> 78 <javac source="1.5" target="1.5" destdir="${build.dir}/main/java"> 79 <src path="${src.dir}/main/java" /> 80 <classpath> 81 <dirset dir="${build.dir}"> 82 <include name="main/*" /> 83 </dirset> 84 <fileset dir="${lib.dir}" includes="**/*.jar" /> 85 </classpath> 86 </javac> 87 <copy todir="${build.dir}/main"> 88 <fileset dir="${src.dir}/main" excludes="java/**"/> 89 </copy> 90 </target> 91 92 <target name="test" depends="compile" description="Build and run unit tests"> 93 <mkdir dir="${build.dir}/test/java" /> 94 <javac source="1.5" target="1.5" destdir="${build.dir}/test/java"> 95 <src path="${src.dir}/test/java" /> 96 <classpath> 97 <dirset dir="${build.dir}"> 98 <include name="main/*" /> 99 <include name="test/*" /> 100 </dirset> 101 <fileset dir="${lib.dir}" includes="**/*.jar" /> 102 </classpath> 103 </javac> 104 <copy todir="${build.dir}/test"> 105 <fileset dir="${src.dir}/test" excludes="java/**"/> 106 </copy> 107 <junit printsummary="on"> 108 <classpath> 109 <dirset dir="${build.dir}"> 110 <include name="main/*" /> 111 <include name="test/*" /> 112 </dirset> 113 <fileset dir="${lib.dir}" includes="**/*.jar" /> 114 </classpath> 115 <batchtest> 116 <fileset dir="${src.dir}/test/java"> 117 <include name="**/*Test.java" /> 118 <include name="**/*Tests.java" /> 119 </fileset> 120 </batchtest> 121 </junit> 122 </target> 123 124 <target name="package" depends="compile" description="Build distribution files"> 125 <mkdir dir="${dist.dir}" /> 126 <jar destfile="${dist.dir}/${project.name}-${project.rev}.jar"> 127 <fileset dir="${build.dir}/main/java" /> 128 <fileset dir="${build.dir}/main/resources" /> 129 </jar> 130 <!-- Use ivy to copy the runtime dependencies to distribution directory --> 131 <ivy:configure file="ivysettings.xml" /> 132 <ivy:resolve file="ivy.xml" /> 133 <ivy:retrieve pattern="${dist.dir}/[artifact]-[revision].[ext]" conf="default" /> 134 </target> 135 136 <target name="integration-test" depends="package" description="Test distribution files"> 137 </target> 138 139 <target name="publish" depends="package" description="Publish distribution to Ivy repository"> 140 <ivy:configure file="ivysettings.xml" /> 141 <ivy:resolve file="ivy.xml" /> 142 <ivy:publish resolver="local" artifactspattern="${dist.dir}/[artifact]-[revision].[ext]" overwrite="true" /> 143 </target> 144 145 <target name="clean" description="Clean the project built files (not dist)"> 146 <delete includeemptydirs="true" failonerror="false"> 147 <fileset dir="${build.dir}" /> 148 </delete> 149 </target> 150 151 <target name="clean-dist" depends="clean" description="Clean compiled, packaged and downloaded library files"> 152 <delete includeemptydirs="true" failonerror="false"> 153 <fileset dir="${dist.dir}" /> 154 </delete> 155 </target> 156 157 <target name="clean-all" depends="clean-dist" description="Clean all generated (or downloaded) files"> 158 <delete includeemptydirs="true" failonerror="false"> 159 <fileset dir="${ant.lib.dir}" /> 160 <fileset dir="${lib.dir}" /> 161 </delete> 26 <antcall target="download-build.common"/> 27 <antcall target="common.bootstrap"/> 162 28 </target> 163 29 164 30 <target name="help"> 165 31 <echo message="Run ant -p to see a list of targets." /> 166 <echo message="Most likely you want to test or package." />167 32 </target> 168 33 trunk/ivy.xml
r2851 r2858 11 11 <dependency org="org.restlet" name="org.restlet" rev="1.0.2" conf="default"/> 12 12 <dependency org="com.noelios.restlet" name="com.noelios.restlet.ext.simple" rev="1.0.2" conf="default"/> 13 <dependency org="com.noelios.restlet" name="com.noelios.restlet.ext.net" rev="1.0.2" conf="test->default"/> 13 14 <dependency org="de.odysseus.juel" name="juel" rev="2.1.0" conf="default"/> 14 15 <dependency org="junit" name="junit" rev="3.8.1" conf="test->default"/> trunk/src/test/java/org/sarugo/xtc/restlet/TemplateDirectoryTests.java
r2851 r2858 4 4 import java.io.File; 5 5 6 import org.restlet.Client; 6 7 import org.restlet.Component; 7 import org.restlet.data.Method;8 8 import org.restlet.data.Protocol; 9 import org.restlet.data.Request;10 9 import org.restlet.data.Response; 11 10 import org.sarugo.xtc.XtcTestFixture; … … 14 13 15 14 public void testSimpleRepresentation() throws Exception { 15 String dirUri = "file://" + new File(".").getCanonicalPath(); 16 16 Component component = new Component(); 17 component.getServers().add(Protocol. FILE);17 component.getServers().add(Protocol.HTTP, 9684); 18 18 component.getClients().add(Protocol.FILE); 19 19 TemplateDirectory directory = new TemplateDirectory(component 20 .getContext(), new File(".").toURI().toString());21 component.getDefaultHost().attach( directory);20 .getContext(), dirUri); 21 component.getDefaultHost().attach("", directory); 22 22 component.start(); 23 File templateFile = new File("build/test/resources/restlet.xhtml"); 24 String uri = templateFile.toURI().toString() 25 + "?message=Hello%20World!"; 26 Request request = new Request(Method.GET, uri); 27 Response response = directory.handle(request); 23 String uri = "http://localhost:9684/build/test/resources/restlet.xhtml?message=Hello%20World!"; 24 Response response = new Client(Protocol.HTTP).get(uri); 28 25 ByteArrayOutputStream bos = new ByteArrayOutputStream(); 29 26 response.getEntity().write(bos);
