Commits

Rafael Goncalves committed 64e0618

Create a environment to test client.

  • Participants
  • Parent commits 353a454

Comments (0)

Files changed (10)

 glob:.settings/*
 glob:.classpath
 glob:nb-configuration.xml
+glob:src/test/var/*
     <packaging>war</packaging>
     <name>VisionDataset</name>
 
-    <properties>
-        <struts2.version>2.1.8.1</struts2.version>
-        <jersey.version>1.8</jersey.version>
-    </properties>
     <repositories>
         <repository>
             <id>maven2-repository.java.net</id>
         </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>
+
+    <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>
+
     <dependencies>
         <dependency>
             <groupId>org.apache.struts</groupId>
                 </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>
+        <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>

File src/main/java/br/usp/ime/vision/dataset/dao/impl/ConnectionFactoryMockup.java

+package br.usp.ime.vision.dataset.dao.impl;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+
+import br.usp.ime.vision.dataset.dao.ConnectionFactory;
+
+public class ConnectionFactoryMockup implements ConnectionFactory {
+
+    public Connection getConnection() throws SQLException {
+        try {
+            Class.forName("org.postgresql.Driver");
+        } catch (ClassNotFoundException e) {
+            e.printStackTrace();
+            return null;
+        }
+        String url = "jdbc:postgresql://127.0.0.1:5432/testvisionds?user=visionDataset&password=visionDataset";
+        Connection conn;
+        conn = DriverManager.getConnection(url);
+        return conn;
+    }
+    
+
+}

File src/main/java/br/usp/ime/vision/dataset/dao/impl/DAOImpl.java

             final Class<?> factoryClass = Class.forName(factoryName);
             connectionFactory = (ConnectionFactory) factoryClass.newInstance();
         } catch (final Exception e) {
+            logger.error("Cant creat factory:", e);
             logger.debug("connection factory fallback: creating a ContextConnectionFactory");
             connectionFactory = new ContextConnectionFactory();
         }

File src/main/resources/config.properties

-MessagesFile=MessageResources.properties
-ConfDir=/etc/visionDataset/conf
-ExtensionsFile=mimeTypeExtensions.properties
-ScriptsDir=/var/local/visionDataset/scripts
-ImagesDir=/var/local/visionDataset/images
-AttachmentDir=/var/local/visionDataset/attachments
-ThumbnailsDir=/var/local/visionDataset/thumbnails
+###Vison Dataset Config.
+#Uncomment to edit default values
+#MessagesFile=MessageResources.properties
+#ConfDir=/etc/visionDataset/conf
+#ExtensionsFile=mimeTypeExtensions.properties
+#ScriptsDir=/var/local/visionDataset/scripts
+#ImagesDir=/var/local/visionDataset/images
+#AttachmentDir=/var/local/visionDataset/attachments
+#ThumbnailsDir=/var/local/visionDataset/thumbnails
 #ServerURL=http://www.vision.ime.usp.br/VisionDataset/
-ServerURL=http://localhost:8080/VisionDataset/

File src/main/resources/internal.properties

+ConnectionFactoryClass=${connectionFactoryClass}
+ServerURL=${visiondatasetUrl}
+
+MessagesFile=MessageResources.properties
+ExtensionsFile=mimeTypeExtensions.properties
+
+ConfDir=${dirPrefix}/etc/visionDataset/conf
+ScriptsDir=${dirPrefix}/var/local/visionDataset/scripts
+ImagesDir=${dirPrefix}/var/local/visionDataset/images
+AttachmentDir=${dirPrefix}/var/local/visionDataset/attachments
+ThumbnailsDir=${dirPrefix}/var/local/visionDataset/thumbnails
+
+#Include so that user can subscribe
 include = /etc/visionDataset/conf/config.properties
-ConnectionFactoryClass=br.usp.ime.vision.dataset.dao.ContextConnectionFactory

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

 
     @Test
     public void testConnectionFactoryClass() {
-        assertEquals("br.usp.ime.vision.dataset.tests.unit.ConnectionFactoryMockup", Configs.getConnectionFactoryClassName());
+        assertEquals("br.usp.ime.vision.dataset.dao.impl.ConnectionFactoryMockup", Configs.getConnectionFactoryClassName());
     }
 
 }

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

-package br.usp.ime.vision.dataset.tests.unit;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
-
-import br.usp.ime.vision.dataset.dao.ConnectionFactory;
-
-public class ConnectionFactoryMockup implements ConnectionFactory {
-
-    public Connection getConnection() throws SQLException {
-        try {
-            Class.forName("org.postgresql.Driver");
-        } catch (ClassNotFoundException e) {
-            e.printStackTrace();
-            return null;
-        }
-        String url = "jdbc:postgresql://127.0.0.1:5432/testvisionds?user=visionDataset&password=visionDataset";
-        Connection conn;
-        conn = DriverManager.getConnection(url);
-        return conn;
-    }
-    
-
-}

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

 
 import org.apache.commons.configuration.ConfigurationException;
 
+import br.usp.ime.vision.dataset.dao.impl.ConnectionFactoryMockup;
+
 public final class TestDatabaseSetup {
 
     public static void setUp() throws SQLException, ConfigurationException {

File src/test/resources/internal.properties

 AttachmentDir=/tmp/var/local/visionDataset/attachments
 ThumbnailsDir=/tmp/var/local/visionDataset/thumbnails
 ServerURL=http://localhost:8080/VisionDataset/
-ConnectionFactoryClass=br.usp.ime.vision.dataset.tests.unit.ConnectionFactoryMockup
+ConnectionFactoryClass=br.usp.ime.vision.dataset.dao.impl.ConnectionFactoryMockup