You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jv...@apache.org on 2005/10/04 23:47:10 UTC

svn commit: r294926 - in /maven/components/trunk/maven-site/src/site/apt/guides/getting-started: index.apt introduction-to-repositories.apt

Author: jvanzyl
Date: Tue Oct  4 14:47:05 2005
New Revision: 294926

URL: http://svn.apache.org/viewcvs?rev=294926&view=rev
Log:
o explain how to use resources in tests

Modified:
    maven/components/trunk/maven-site/src/site/apt/guides/getting-started/index.apt
    maven/components/trunk/maven-site/src/site/apt/guides/getting-started/introduction-to-repositories.apt

Modified: maven/components/trunk/maven-site/src/site/apt/guides/getting-started/index.apt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-site/src/site/apt/guides/getting-started/index.apt?rev=294926&r1=294925&r2=294926&view=diff
==============================================================================
--- maven/components/trunk/maven-site/src/site/apt/guides/getting-started/index.apt (original)
+++ maven/components/trunk/maven-site/src/site/apt/guides/getting-started/index.apt Tue Oct  4 14:47:05 2005
@@ -448,9 +448,56 @@
 
 +----+
 
-~~* How do I filter resources against a properties file?
+ To use resources with your unit tests you follow the same pattern except the directory you place resources in
+ is ${basedir}/src/test/resources which are then availabe to you at the base of the classpath. So you would have a
+ project directory structure that would look like the following:
+
++---+
+
+my-app
+|-- pom.xml
+`-- src
+    |-- main
+    |   |-- java
+    |   |   `-- com
+    |   |       `-- mycompany
+    |   |           `-- app
+    |   |               `-- App.java
+    |   `-- resources
+    |       `-- META-INF
+    |           |-- application.properties
+    |           `-- application.properties~
+    `-- test
+        |-- java
+        |   `-- com
+        |       `-- mycompany
+        |           `-- app
+        |               `-- AppTest.java
+        `-- resources
+            `-- test.properties
++---+
+
+ So in a unit test you could use a simple snippet of code like the following to access the resource required for
+ testing:
+
++----+
+
+...
+
+// Retrieve resource
+InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( "test.properties" );
+
+// Do something with the resource
+
+...
 
-~~* How do I filter resources against my POM?
++----+
+
+* How do I filter resources against a properties file?
+
+* How do I filter resources against my POM?
+
++----+
 
 FYI - In beta-2, while the other technique is still supported, the
 recommended way is finally settled:
@@ -471,17 +518,12 @@
 
 ~~* How do I setup a proxy if I'm behind a firewall so I can get my external dependencies?
 
-~~* How do I install my JAR in my local repository?
-~~  o Explain the standard layout of the m2 repository
-
 ~~* How do I deploy my jar in my remote repository?
 
 ~~* How do I deploy my jar in Ibiblio?
 
 ~~* How do I create documentation?
 ~~  o Explain the different formats APT/xdoc/docbook/FAQML
-
-~~* How do I generate my site?
 
 ~~* How do I use plug-ins?
   o Explain that a plug-in consists of one or more mojos

Modified: maven/components/trunk/maven-site/src/site/apt/guides/getting-started/introduction-to-repositories.apt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-site/src/site/apt/guides/getting-started/introduction-to-repositories.apt?rev=294926&r1=294925&r2=294926&view=diff
==============================================================================
--- maven/components/trunk/maven-site/src/site/apt/guides/getting-started/introduction-to-repositories.apt (original)
+++ maven/components/trunk/maven-site/src/site/apt/guides/getting-started/introduction-to-repositories.apt Tue Oct  4 14:47:05 2005
@@ -7,3 +7,5 @@
  ------
 
 Introduction to Repositories
+
+~~  o Explain the standard layout of the m2 repository



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org