You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by hossainsaad <ho...@gmail.com> on 2008/04/20 08:23:48 UTC
very new to maven & Eclipse and java
I have wrote one test case in my new work place. now i have seen in other
codes they have POM.xml.
ques # 1==Could anybody tell me what exactly I have to put there to run my
test. I am adding a pom.xml which i tried but did not work. let me know what
i have to add. We are using Spring jdbc template. I am adding the test code
and the pom.xml.
first the test code is :
import java.util.List;
import junit.framework.TestCase;
import org.springframework.context.ApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;
import com.tracfone.core.bean.User;
import com.tracfone.core.component.ApplicationContextLoader;
import com.tracfone.domain.api.user.UserDAO;
public class UserDaoTestCase extends TestCase {
private static final String CONFIG_FILE =
"C:/projects//Sadd/src/test/java/userTestCase.xml";
private JdbcTemplate jdbcTemplate = null;
private UserDAO userDAO = null;
public UserDaoTestCase() {
super();
}
protected void setUp() throws Exception {
ApplicationContext applicationContext =
ApplicationContextLoader.load(CONFIG_FILE);
jdbcTemplate = (JdbcTemplate) applicationContext.getBean("jdbcTemplate");
userDAO = (UserDAO) applicationContext.getBean("userDAO");
jdbcTemplate.execute("delete from table_user where objid=323");
System.out.println("Junit Test case for user setUp3");
jdbcTemplate.execute("INSERT INTO TABLE_USER ( " +
"OBJID, LOGIN_NAME , PASSWORD ) VALUES (323,'testtracfone','test')");
super.setUp();
}
protected void tearDown() throws Exception {
jdbcTemplate.execute("delete from table_user where objid=323");
super.tearDown();
}
public void testFindUser(){
User user = userDAO.findUser("testtracfone");
String password="";
if(user.getPassword()!=null){
password=user.getPassword();
}
String id="";
if(user.getId()!=null){
id=user.getId();
}
assertEquals("323",id);
assertEquals("test",password);
}
public void testFindUsersByGroup(){
List userList = userDAO.findUsersByGroup("ADMINCONSOLE");
//String password="";
assertNotNull(userList);
assertEquals(userList.size(),4);
}
}
the rough pom i have wrote is
<?xml version="1.0" encoding="UTF-8"?>
4.0.0
Sadd
//Ques#2:what should be groupID?? if my folder name is Sadd
simple
// Ques#3what should I put here in artifactId, what does it mean
jar
1.0-SNAPSHOT
simple
http://maven.apache.org
junit
junit
3.8.1
test
org.springframework
spring
2.0
Sadd
// Ques#4 Again if my folder name is Sadd, am i doing right?
com.core
// Ques#5my Sadd folder is dependant on com.core, am i doing right??
1.0
test
org.apache.maven.plugins
maven-compiler-plugin
1.4
1.4
true
org.apache.maven.plugins
maven-surefire-plugin
**/*TestCase.java
true
Ques#6: I have seen environmental.xml also. what it does??
Sorry if my questions are too imple or stupid. I wanted to learn maven by
actually doing a project. thats wht i m trying to do. if anybody could help
me thank you in advance.
--
View this message in context: http://www.nabble.com/very-new-to-maven---Eclipse-and-java-tp16790642s177p16790642.html
Sent from the Maven - Users mailing list archive at Nabble.com.
Re: very new to maven & Eclipse and java
Posted by Lachlan Deck <la...@gmail.com>.
Hi Hossain,
On 20/04/2008, at 4:27 PM, hossainsaad wrote:
> I have wrote one test case in my new work place. now i have seen in
> other
> codes they have POM.xml.
> ques # 1==Could anybody tell me what exactly I have to put there to
> run my
> test. I am adding a pom.xml which i tried but did not work. let me
> know what
> i have to add. We are using Spring jdbc template. I am adding the
> test code
> and the pom.xml.
I'm also relatively new to maven... but I think you'll find that
you'll have better success if you do the tutorial here:
http://maven.apache.org/guides/getting-started/index.html
There's one bug in the tutorial under 'How do I create documentation?'
you should type the following rather than what's written.
mvn site:site
> the rough pom i have wrote is
>
> //Ques#2:what should be groupID?? if my folder name is Sadd
Think of groupId like packages in java. It's up to you - but you'd
normally use your reverse domain, for example.
> <artifactId>simple</artifactId>
>
> // Ques#3what should I put here in artifactId, what does it mean
Something that uniquely identifies your project/artifact (i.e., the
thing you're building) from other artifacts that might live one day in
a repository.
> <dependency>
> <groupId>Sadd</groupId>
> // Ques#4 Again if my folder name is Sadd, am i doing right?
Doesn't hurt. But it doesn't matter.
> <artifactId>com.core</artifactId>
> // Ques#5my Sadd folder is dependant on com.core, am i doing right??
Check the pom declaration for core. They should match. artifactIds
shouldn't have '.'s in them. They're usually the final part of a fully
qualified id.
It sounds like the group id for core should be Sadd.com
i.e.,
<artifactId>core</artifactId>
<groupId>Sadd.com</groupId>
> Sorry if my questions are too imple or stupid. I wanted to learn
> maven by
> actually doing a project. thats wht i m trying to do. if anybody
> could help
> me thank you in advance.
I think maven is one of those things that you really need to do some
reading first - before trying to piece things together like you've
attempted to. See the tutorial link above... you should find after
going through it bit by bit that you'll have a better idea of things.
with regards,
--
Lachlan Deck
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: very new to maven & Eclipse and java
Posted by hossainsaad <ho...@gmail.com>.
Sorry for the mess. I m posting again:
I have wrote one test case in my new work place. now i have seen in other
codes they have POM.xml.
ques # 1==Could anybody tell me what exactly I have to put there to run my
test. I am adding a pom.xml which i tried but did not work. let me know what
i have to add. We are using Spring jdbc template. I am adding the test code
and the pom.xml.
first the test code is :
import java.util.List;
import junit.framework.TestCase;
import org.springframework.context.ApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;
import com.tracfone.core.bean.User;
import com.tracfone.core.component.ApplicationContextLoader;
import com.tracfone.domain.api.user.UserDAO;
public class UserDaoTestCase extends TestCase {
private static final String CONFIG_FILE =
"C:/projects//Sadd/src/test/java/userTestCase.xml";
private JdbcTemplate jdbcTemplate = null;
private UserDAO userDAO = null;
public UserDaoTestCase() {
super();
}
protected void setUp() throws Exception {
ApplicationContext applicationContext =
ApplicationContextLoader.load(CONFIG_FILE);
jdbcTemplate = (JdbcTemplate) applicationContext.getBean("jdbcTemplate");
userDAO = (UserDAO) applicationContext.getBean("userDAO");
jdbcTemplate.execute("delete from table_user where objid=323");
System.out.println("Junit Test case for user setUp3");
jdbcTemplate.execute("INSERT INTO TABLE_USER ( " +
"OBJID, LOGIN_NAME , PASSWORD ) VALUES (323,'testtracfone','test')");
super.setUp();
}
protected void tearDown() throws Exception {
jdbcTemplate.execute("delete from table_user where objid=323");
super.tearDown();
}
public void testFindUser(){
User user = userDAO.findUser("testtracfone");
String password="";
if(user.getPassword()!=null){
password=user.getPassword();
}
String id="";
if(user.getId()!=null){
id=user.getId();
}
assertEquals("323",id);
assertEquals("test",password);
}
public void testFindUsersByGroup(){
List userList = userDAO.findUsersByGroup("ADMINCONSOLE");
//String password="";
assertNotNull(userList);
assertEquals(userList.size(),4);
}
}
the rough pom i have wrote is
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Sadd</groupId>
//Ques#2:what should be groupID?? if my folder name is Sadd
<artifactId>simple</artifactId>
// Ques#3what should I put here in artifactId, what does it mean
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>simple</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>Sadd</groupId>
// Ques#4 Again if my folder name is Sadd, am i doing right?
<artifactId>com.core</artifactId>
// Ques#5my Sadd folder is dependant on com.core, am i doing right??
<version>1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.4</source>
<target>1.4</target>
<debug>true</debug>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*TestCase.java</include>
</includes>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
Ques#6: I have seen environmental.xml also. what it does??
Sorry if my questions are too imple or stupid. I wanted to learn maven by
actually doing a project. thats wht i m trying to do. if anybody could help
me thank you in advance.
--
View this message in context: http://www.nabble.com/very-new-to-maven---Eclipse-and-java-tp16790642s177p16790643.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org