This commit is contained in:
100
YACOSTest/src/org/yacos/tests/core/ArticleManagerTest.java
Normal file
100
YACOSTest/src/org/yacos/tests/core/ArticleManagerTest.java
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
package org.yacos.tests.core;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.naming.Context;
|
||||||
|
import javax.naming.InitialContext;
|
||||||
|
import javax.naming.NamingException;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import org.yacos.core.article.Article;
|
||||||
|
import org.yacos.core.article.IArticleManager;
|
||||||
|
import org.yacos.core.conferences.Conference;
|
||||||
|
import org.yacos.core.conferences.IConferenceManager;
|
||||||
|
import org.yacos.core.exceptions.PKAlreadyUsedException;
|
||||||
|
import org.yacos.core.users.IUserManager;
|
||||||
|
import org.yacos.core.users.User;
|
||||||
|
|
||||||
|
public class ArticleManagerTest {
|
||||||
|
|
||||||
|
static IArticleManager am;
|
||||||
|
static IConferenceManager cm;
|
||||||
|
static IUserManager um;
|
||||||
|
User author;
|
||||||
|
Conference conf;
|
||||||
|
static int articleId;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpManager() throws NamingException, PKAlreadyUsedException {
|
||||||
|
Context context = new InitialContext();
|
||||||
|
am = (IArticleManager) context.lookup("ArticleManagerBean/remote");
|
||||||
|
um = (IUserManager) context.lookup("UserManagerBean/remote");
|
||||||
|
cm = (IConferenceManager) context.lookup("ConferenceManagerBean/remote");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setupArticleTest() throws PKAlreadyUsedException{
|
||||||
|
//ajout d'un user
|
||||||
|
if (um.exists("max")){
|
||||||
|
author = um.getUser("max");
|
||||||
|
}else{
|
||||||
|
author = um.addUser("max","pw","maxime","dagn","ipint", "e@e.fr");
|
||||||
|
}
|
||||||
|
//ajout d'une conf
|
||||||
|
conf = cm.getConference(1);
|
||||||
|
|
||||||
|
//ajout d'un article
|
||||||
|
//Article article = am.addArticle("title", "topic", "url_article", author, new ArrayList<String>(), 1, conf);
|
||||||
|
//articleId = article.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addArticleTest(){
|
||||||
|
List<String> secondaryAuthors = new ArrayList<String>();
|
||||||
|
Article article = am.addArticle("title", "topic", "url_article", author, secondaryAuthors, 1, conf);
|
||||||
|
assertEquals(article.getTitle(), am.getArticle(article.getId()).getTitle());
|
||||||
|
articleId = article.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateArticleTest(){
|
||||||
|
Article article = am.getArticle(articleId);
|
||||||
|
article.setTitle("titre2");
|
||||||
|
am.updateArticle(article);
|
||||||
|
article = am.getArticle(articleId);
|
||||||
|
assertEquals("titre2", article.getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void removeArticleTest(){
|
||||||
|
am.removeArticle(am.getArticle(articleId));
|
||||||
|
assertNull(am.getArticle(articleId));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getArticlesOfConfTest(){
|
||||||
|
|
||||||
|
//ajout d'un article
|
||||||
|
List<String> secondaryAuthors = new ArrayList<String>();
|
||||||
|
Article article = am.addArticle("title", "topic", "url_article", author, secondaryAuthors, 1, conf);
|
||||||
|
articleId = article.getId();
|
||||||
|
|
||||||
|
List<Article> list = am.getArticles(conf);
|
||||||
|
assertFalse("tableau vide", list.isEmpty());
|
||||||
|
assertEquals("title", list.get(list.size()-1).getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getArticleOfConfAndAuthor(){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user