Rafael Goncalves avatar Rafael Goncalves committed 0a42c62

Add more tests

Comments (0)

Files changed (5)

 <?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/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <groupId>br.usp.ime.vision.dataset</groupId>
-    <artifactId>visiondataset</artifactId>
-    <version>1.1</version>
-    <packaging>war</packaging>
-    <name>VisionDataset</name>
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>br.usp.ime.vision.dataset</groupId>
+	<artifactId>visiondataset</artifactId>
+	<version>1.1</version>
+	<packaging>war</packaging>
+	<name>VisionDataset</name>
+	<description>VisionDataset is a repository of images with image annotation capabilities and a webservice interface.</description>
+	<issueManagement>
+		<system>BitBucket</system>
+		<url>https://bitbucket.org/rafaellg/visiondataset/issues</url>
+	</issueManagement>
 
-    <repositories>
-        <repository>
-            <id>maven2-repository.java.net</id>
-            <name>Java.net Repository for Maven</name>
-            <url>http://download.java.net/maven/2/</url>
-            <layout>default</layout>
-        </repository> 
-    </repositories>
+	<repositories>
+		<repository>
+			<id>maven2-repository.java.net</id>
+			<name>Java.net Repository for Maven</name>
+			<url>http://download.java.net/maven/2/</url>
+			<layout>default</layout>
+		</repository>
+	</repositories>
 
-    <properties>
-        <struts2.version>2.1.8.1</struts2.version>
-        <jersey.version>1.8</jersey.version>
-        <connectionFactoryClass>br.usp.ime.vision.dataset.dao.ContextConnectionFactory</connectionFactoryClass>
-        <visiondatasetUrl>http://vision.ime.usp.br:8080/VisionDataset/</visiondatasetUrl>
-        <dirPrefix></dirPrefix>
-    </properties>
+	<properties>
+		<struts2.version>2.1.8.1</struts2.version>
+		<jersey.version>1.8</jersey.version>
+		<connectionFactoryClass>br.usp.ime.vision.dataset.dao.ContextConnectionFactory</connectionFactoryClass>
+		<visiondatasetUrl>http://vision.ime.usp.br/VisionDataset/</visiondatasetUrl>
+		<dirPrefix></dirPrefix>
+	</properties>
 
-    <profiles>
-        <profile>
-            <id>runtest</id>
-            <properties>
-                <connectionFactoryClass>br.usp.ime.vision.dataset.dao.impl.ConnectionFactoryMockup</connectionFactoryClass>
-                <visiondatasetUrl>http://localhost:8080/VisionDataset/</visiondatasetUrl>
-                <dirPrefix>src/test/</dirPrefix>
-            </properties>
-        </profile>
-        <profile>
-            <id>dev</id>
-            <properties>
-                <visiondatasetUrl>http://localhost:8080/VisionDataset/</visiondatasetUrl>
-            </properties>
-        </profile>
-    </profiles>
+	<profiles>
+		<profile>
+			<id>runtest</id>
+			<properties>
+				<connectionFactoryClass>br.usp.ime.vision.dataset.dao.impl.ConnectionFactoryMockup</connectionFactoryClass>
+				<visiondatasetUrl>http://localhost:8080/VisionDataset/</visiondatasetUrl>
+				<dirPrefix>${basedir}/src/test/</dirPrefix>
+			</properties>
+		</profile>
+		<profile>
+			<id>dev</id>
+			<properties>
+				<visiondatasetUrl>http://localhost:8080/VisionDataset/</visiondatasetUrl>
+			</properties>
+		</profile>
+	</profiles>
 
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.struts</groupId>
-            <artifactId>struts2-core</artifactId>
-            <version>${struts2.version}</version>
-        </dependency>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.struts</groupId>
+			<artifactId>struts2-core</artifactId>
+			<version>${struts2.version}</version>
+		</dependency>
 
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-            <version>1.1.1</version>
-        </dependency>
+		<dependency>
+			<groupId>commons-logging</groupId>
+			<artifactId>commons-logging</artifactId>
+			<version>1.1.1</version>
+		</dependency>
 
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-            <version>1.2.16</version>
-        </dependency>
+		<dependency>
+			<groupId>log4j</groupId>
+			<artifactId>log4j</artifactId>
+			<version>1.2.16</version>
+		</dependency>
 
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <version>1.5.8</version>
-        </dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-log4j12</artifactId>
+			<version>1.5.8</version>
+		</dependency>
 
-        <dependency>
-            <groupId>com.sun.jersey</groupId>
-            <artifactId>jersey-server</artifactId>
-            <version>${jersey.version}</version>
-        </dependency>
+		<dependency>
+			<groupId>com.sun.jersey</groupId>
+			<artifactId>jersey-server</artifactId>
+			<version>${jersey.version}</version>
+		</dependency>
 
-        <dependency>
-            <groupId>com.sun.jersey.contribs</groupId>
-            <artifactId>jersey-multipart</artifactId>
-            <version>${jersey.version}</version>
-        </dependency>
+		<dependency>
+			<groupId>com.sun.jersey.contribs</groupId>
+			<artifactId>jersey-multipart</artifactId>
+			<version>${jersey.version}</version>
+		</dependency>
 
-        <dependency>
-            <groupId>eu.medsea.mimeutil</groupId>
-            <artifactId>mime-util</artifactId>
-            <version>2.1.3</version>
-        </dependency>
+		<dependency>
+			<groupId>eu.medsea.mimeutil</groupId>
+			<artifactId>mime-util</artifactId>
+			<version>2.1.3</version>
+		</dependency>
 
-        <dependency>
-            <groupId>commons-beanutils</groupId>
-            <artifactId>commons-beanutils</artifactId>
-            <version>1.8.3</version>
-        </dependency>
+		<dependency>
+			<groupId>commons-beanutils</groupId>
+			<artifactId>commons-beanutils</artifactId>
+			<version>1.8.3</version>
+		</dependency>
 
-        <dependency>
-            <groupId>com.google.code.gson</groupId>
-            <artifactId>gson</artifactId>
-            <version>1.7.1</version>
-        </dependency>
+		<dependency>
+			<groupId>com.google.code.gson</groupId>
+			<artifactId>gson</artifactId>
+			<version>1.7.1</version>
+		</dependency>
 
-        <dependency>
-            <groupId>postgresql</groupId>
-            <artifactId>postgresql</artifactId>
-            <version>9.0-801.jdbc4</version>
-        </dependency>
+		<dependency>
+			<groupId>postgresql</groupId>
+			<artifactId>postgresql</artifactId>
+			<version>9.0-801.jdbc4</version>
+		</dependency>
 
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-email</artifactId>
-            <version>1.2</version>
-        </dependency>
+		<dependency>
+			<groupId>org.apache.commons</groupId>
+			<artifactId>commons-email</artifactId>
+			<version>1.2</version>
+		</dependency>
 
-        <dependency>
-            <groupId>org.apache.tiles</groupId>
-            <artifactId>tiles-core</artifactId>
-            <version>2.2.1</version>
-        </dependency>
+		<dependency>
+			<groupId>org.apache.tiles</groupId>
+			<artifactId>tiles-core</artifactId>
+			<version>2.2.1</version>
+		</dependency>
 
-        <dependency>
-            <groupId>org.apache.tiles</groupId>
-            <artifactId>tiles-servlet</artifactId>
-            <version>2.2.1</version>
-        </dependency>
+		<dependency>
+			<groupId>org.apache.tiles</groupId>
+			<artifactId>tiles-servlet</artifactId>
+			<version>2.2.1</version>
+		</dependency>
 
-        <dependency>
-            <groupId>org.apache.tiles</groupId>
-            <artifactId>tiles-template</artifactId>
-            <version>2.2.1</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.tiles</groupId>
-            <artifactId>tiles-jsp</artifactId>
-            <version>2.2.1</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-configuration</groupId>
-            <artifactId>commons-configuration</artifactId>
-            <version>1.6</version>
-        </dependency>
+		<dependency>
+			<groupId>org.apache.tiles</groupId>
+			<artifactId>tiles-template</artifactId>
+			<version>2.2.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.tiles</groupId>
+			<artifactId>tiles-jsp</artifactId>
+			<version>2.2.1</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-configuration</groupId>
+			<artifactId>commons-configuration</artifactId>
+			<version>1.6</version>
+		</dependency>
 
-        <!--Test dependencies-->
-        <dependency>
-            <groupId>org.concordion</groupId>
-            <artifactId>concordion</artifactId>
-            <version>1.3.1</version>
-            <scope>test</scope>
-        </dependency>
+		<!--Test dependencies -->
+		<dependency>
+			<groupId>org.concordion</groupId>
+			<artifactId>concordion</artifactId>
+			<version>1.3.1</version>
+			<scope>test</scope>
+		</dependency>
 
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.8.2</version>
-            <scope>test</scope>
-        </dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.8.2</version>
+			<scope>test</scope>
+		</dependency>
 
-        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>jstl</artifactId>
-            <version>1.2</version>
-        </dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>jstl</artifactId>
+			<version>1.2</version>
+		</dependency>
 
-        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>servlet-api</artifactId>
-            <version>2.5</version>
-            <scope>provided</scope>
-        </dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>servlet-api</artifactId>
+			<version>2.5</version>
+			<scope>provided</scope>
+		</dependency>
 
-        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>jsp-api</artifactId>
-            <version>2.0</version>
-            <scope>provided</scope>
-        </dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>jsp-api</artifactId>
+			<version>2.0</version>
+			<scope>provided</scope>
+		</dependency>
 
-    </dependencies>
+	</dependencies>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>tomcat-maven-plugin</artifactId>
-                <version>1.1</version>
-                <configuration>
-                    <path>/VisionDataset</path>
-                    <password>tomcat123</password>
-                    <username>tomcat</username>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.mortbay.jetty</groupId>
-                <artifactId>maven-jetty-plugin</artifactId>
-                <version>6.1.21</version>
-                <configuration>
-                    <scanIntervalSeconds>10</scanIntervalSeconds>
-                    <contextPath>/VisionDataset</contextPath>
-                </configuration>
-            </plugin>
-        </plugins>
-        <resources>
-            <resource>
-                <directory>src/main/resources</directory>
-                <filtering>true</filtering>
-            </resource>
-        </resources>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-site-plugin</artifactId>
+				<version>3.0-beta-2</version>
+				<configuration>
+					<reportPlugins>
+						<plugin>
+							<groupId>org.apache.maven.plugins</groupId>
+							<artifactId>maven-javadoc-plugin</artifactId>
+							<version>2.7</version>
+						</plugin>
+						<plugin>
+							<groupId>org.apache.maven.plugins</groupId>
+							<artifactId>maven-jxr-plugin</artifactId>
+							<version>2.1</version>
+							<configuration>
+								<aggregate>true</aggregate>
+							</configuration>
+						</plugin>
+						<plugin>
+							<groupId>org.apache.maven.plugins</groupId>
+							<artifactId>maven-surefire-report-plugin</artifactId>
+							<version>2.6</version>
+						</plugin>
+						<plugin>
+							<groupId>org.codehaus.mojo</groupId>
+							<artifactId>cobertura-maven-plugin</artifactId>
+							<version>2.4</version>
+							<configuration>
+								<formats>
+									<format>xml</format>
+									<format>html</format>
+								</formats>
+								<instrumentation>
+									<ignores>
+										<ignore>br.usp.ime.vision.dataset.tiles</ignore>
+										<ignore>br.usp.ime.vision.dataset.actions</ignore>
+										<ignore>br.usp.ime.vision.dataset.taglib</ignore>
+									</ignores>
+								</instrumentation>
+							</configuration>
+						</plugin>
+						<plugin>
+							<groupId>org.apache.maven.plugins</groupId>
+							<artifactId>maven-checkstyle-plugin</artifactId>
+							<version>2.6</version>
+						</plugin>
+					</reportPlugins>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>tomcat-maven-plugin</artifactId>
+				<version>1.1</version>
+				<configuration>
+					<path>/VisionDataset</path>
+					<password>tomcat123</password>
+					<username>tomcat</username>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.mortbay.jetty</groupId>
+				<artifactId>maven-jetty-plugin</artifactId>
+				<version>6.1.21</version>
+				<configuration>
+					<scanIntervalSeconds>10</scanIntervalSeconds>
+					<contextPath>/VisionDataset</contextPath>
+				</configuration>
+			</plugin>
+		</plugins>
+		<resources>
+			<resource>
+				<directory>src/main/resources</directory>
+				<filtering>true</filtering>
+			</resource>
+		</resources>
 
-    </build>
-    <organization>
-        <name>Instituto de Matematica e Estatistica, Universidade de Sao Paulo</name>
-        <url>www.ime.usp.br</url>
-    </organization>
-    <url>http://www.vision.ime.usp.br/VisionDataset/</url>
-    <reporting>
-        <plugins>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>findbugs-maven-plugin</artifactId>
-                <version>2.3.3-SNAPSHOT</version>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-checkstyle-plugin</artifactId>
-                <version>2.6</version>
-                <configuration>
-                    <configLocation>config/avalon_checks.xml</configLocation>
-                </configuration>
-            </plugin>
-        </plugins>
-    </reporting>
+	</build>
+	<organization>
+		<name>Instituto de Matematica e Estatistica, Universidade de Sao Paulo</name>
+		<url>www.ime.usp.br</url>
+	</organization>
+	<url>http://www.vision.ime.usp.br/VisionDataset/</url>
+	<reporting>
+		<plugins>
+		</plugins>
+	</reporting>
 </project>

src/main/java/br/usp/ime/vision/dataset/entities/Tag.java

         this.tagName = tagName;
     }
 
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + id;
+        result = prime * result + ((tagName == null) ? 0 : tagName.hashCode());
+        return result;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) return true;
+        if (obj == null) return false;
+        if (getClass() != obj.getClass()) return false;
+        Tag other = (Tag) obj;
+        if (id != other.id) return false;
+        if (tagName == null) {
+            if (other.tagName != null) return false;
+        } else if (!tagName.equals(other.tagName)) return false;
+        return true;
+    }
+    
+
 }

src/site/apt/index.apt

+  First line of first paragraph.
+  Second line of first paragraph.
+  Third line of first paragraph.
+
+  Line 1 of paragraph 2 (separated from first paragraph by an open line).
+  Line 2 of paragraph 2.

src/site/site.xml

+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project>
+  <body>
+    <menu name="Overview">
+      <item name="Introduction" href="index.html"/>
+      <item name="Objetivos" href="objetivos.html"/>
+      <item name="Desenvolvimento" href="usage.html"/>
+      <item name="Arquitetura" href="faq.html"/>
+      <item name="FAQ" href="faq.html"/>
+  </menu>
+  <menu ref="modules" />
+  <menu ref="reports" />
+    <menu name="Examples">
+      <item name="Showing Failure Tests" href="examples/show-failures.html"/>
+      <item name="Changing Report Name" href="examples/changing-report-name.html"/>
+      <item name="Configuring the Output Location of the Report" href="examples/report-custom-location.html"/>
+      <item name="Source Code Cross Reference" href="examples/cross-referencing.html"/>
+    </menu>
+  </body>
+</project>

src/test/java/br/usp/ime/vision/dataset/tests/unit/TagDaoTest.java

+package br.usp.ime.vision.dataset.tests.unit;
+
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import br.usp.ime.vision.dataset.dao.DAOFactory;
+import br.usp.ime.vision.dataset.dao.interfaces.TagDAO;
+import br.usp.ime.vision.dataset.entities.AlbumTag;
+import br.usp.ime.vision.dataset.entities.ImageAnnotation;
+import br.usp.ime.vision.dataset.entities.ImageTag;
+import br.usp.ime.vision.dataset.entities.Tag;
+
+public class TagDaoTest {
+
+    private TagDAO dao;
+
+    @Before
+    public void setUp() throws Exception {
+        TestDatabaseSetup.setUp();
+        this.dao = DAOFactory.getTagDao();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        TestDatabaseSetup.tearDown();
+        this.dao = null;
+    }
+
+    @Test
+    public void testAddAlbumTag() {
+        int id = dao.addAlbumTag(1, "album tag");
+        assertEquals(2, id);
+        List<Tag> albumTags = dao.getAlbumTags(1);
+        assertEquals(2, albumTags.size());
+        assertEquals(id, albumTags.get(0).getId());
+        assertEquals("album tag", albumTags.get(0).getTagName());
+        
+        AlbumTag albumTag = dao.getAlbumTag(1, id);
+        assertEquals(albumTag,albumTags.get(0));
+        
+        dao.deleteAlbumTag(1, id);
+        albumTags = dao.getAlbumTags(1);
+        assertEquals(1, albumTags.size());
+        assertEquals(1, albumTags.get(0).getId());
+        assertEquals("test", albumTags.get(0).getTagName());
+        
+        assertNull(dao.getAlbumTag(1, id));
+        
+    }
+
+    @Test
+    public void testAddImageAnnotation() {
+        int id = dao.addImageAnnotation(3, "image tag", 0, 10, 11, 1);
+        List<ImageAnnotation> list = dao.getImageAnnotations(3);
+        assertEquals(1, list.size());
+        assertEquals(11, list.get(0).getWidth());
+        
+        ImageAnnotation ia = dao.getImageAnnotation(3, id);
+        assertEquals(ia,list.get(0));
+        
+        dao.updateAnnotation(id, "novo", 6, 6, 6, 6);
+        ia = dao.getImageAnnotation(3, id);
+        assertEquals("novo", ia.getTagName());
+        assertEquals(6, ia.getHeight());
+        assertEquals(6, ia.getWidth());
+        assertEquals(6, ia.getX());
+        assertEquals(6, ia.getY());
+        assertEquals(3, ia.getImageId());
+        
+        
+        
+        dao.deleteImageAnnotation(3, id);
+        list = dao.getImageAnnotations(3);
+        assertEquals(0, list.size());
+        
+        assertNull( dao.getImageAnnotation(3, id));
+    }
+    
+    @Test
+    public void testImageTag() {
+        int id = dao.addImageTag(3, "___123___");
+        List<Tag> list = dao.getImageTags(3);
+        assertEquals(3, list.size());
+        assertEquals("___123___", list.get(0).getTagName());
+        
+        ImageTag imageTag = dao.getImageTag(3, id);
+        assertEquals(imageTag, list.get(0));
+        
+        dao.deleteImageTag(3, id);
+        list = dao.getImageTags(3);
+        assertEquals(2, list.size());
+        
+        imageTag = dao.getImageTag(3, id);
+        assertNull(imageTag);
+        
+        
+    }
+
+    @Test
+    public void testGetTagsNames() {
+        List<String> list = dao.getTagsNames();
+        assertEquals("test", list.get(0));
+        assertEquals("asdf", list.get(1));
+        assertEquals("bdgdgbfg", list.get(2));
+        assertEquals(3, list.size());
+        
+    }
+
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.