roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gma...@apache.org
Subject svn commit: r1499866 - in /roller/trunk: ./ app/ app/src/main/java/org/apache/roller/weblogger/pojos/ app/src/test/java/org/apache/roller/weblogger/business/ app/src/test/java/org/apache/roller/weblogger/util/ app/src/test/resources/
Date Thu, 04 Jul 2013 20:49:47 GMT
Author: gmazza
Date: Thu Jul  4 20:49:47 2013
New Revision: 1499866

URL: http://svn.apache.org/r1499866
Log:
JUnit tests with OpenJPA, Hibernate and EclipseLink JPA now all pass; changes to WeblogPermission
and MediaFileTest so the latter two would work.

Modified:
    roller/trunk/app/pom.xml
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/TaskLock.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogPermission.java
    roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/MediaFileTest.java
    roller/trunk/app/src/test/java/org/apache/roller/weblogger/util/LinkbackExtractorTest.java
    roller/trunk/app/src/test/resources/roller-custom.properties
    roller/trunk/pom.xml

Modified: roller/trunk/app/pom.xml
URL: http://svn.apache.org/viewvc/roller/trunk/app/pom.xml?rev=1499866&r1=1499865&r2=1499866&view=diff
==============================================================================
--- roller/trunk/app/pom.xml (original)
+++ roller/trunk/app/pom.xml Thu Jul  4 20:49:47 2013
@@ -113,8 +113,9 @@
              <non-jta-data-source> element, as EclipseLink tries to do a
              JNDI connection instead of relying on the jdbc properties if
              the former is available.
-         As of 6/30/2013, running mvn clean install with EclipseLink JPA
-         returns 30 failures and 14 errors.
+         4.) In src/test/resources/roller-custom.properties, uncomment any
+             eclipselink.* properties (JPA stack logging, etc.) desired
+         As of 4 July 2013, no JUnit failures with EclipseLink 2.5.0
 
         <dependency>
             <groupId>org.eclipse.persistence</groupId>
@@ -122,18 +123,24 @@
             <version>2.5.0</version>
         </dependency>
 -->
-        <!-- Hibernate deps (for sometimes testing purposes)
+
+        <!-- To run JUnit tests using Hibernate, follow above instructions
+             given for EclipseLink with appropriate modifications.
+             As of 4 July 2013, no JUnit failures with Hibernate 4.2.1-Final
+
         <dependency>
             <groupId>org.hibernate</groupId>
             <artifactId>hibernate-entitymanager</artifactId>
-            <version>4.2.1-Final</version>
+            <version>4.2.1.Final</version>
         </dependency>
+
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-jdk14</artifactId>
             <version>1.6.1</version>
             <scope>runtime</scope>
-        </dependency> -->
+        </dependency>
+-->
 
         <dependency>
             <groupId>log4j</groupId>
@@ -876,7 +883,7 @@
 
                     <!-- Ensure tests will run even if 'openjpa' profile not active -->
                     <forkMode>once</forkMode>
-                    <argLine>-javaagent:"${user.home}/.m2/repository/org/apache/openjpa/openjpa/${openjpa.version}/openjpa-${openjpa.version}.jar"</argLine>
+                    <!--argLine>-javaagent:"${user.home}/.m2/repository/org/apache/openjpa/openjpa/${openjpa.version}/openjpa-${openjpa.version}.jar"</argLine-->
                     
                     <systemProperties>
                         <property>

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/TaskLock.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/TaskLock.java?rev=1499866&r1=1499865&r2=1499866&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/TaskLock.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/TaskLock.java Thu Jul
 4 20:49:47 2013
@@ -108,7 +108,7 @@ public class TaskLock implements Seriali
     
     @Override
     public int hashCode() {
-        // our natrual key, or business key, is our name
+        // our natural key, or business key, is our name
         return this.getName().hashCode();
     }
     

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogPermission.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogPermission.java?rev=1499866&r1=1499865&r2=1499866&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogPermission.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/WeblogPermission.java
Thu Jul  4 20:49:47 2013
@@ -22,9 +22,12 @@ import java.io.Serializable;
 import java.security.Permission;
 import java.util.ArrayList;
 import java.util.List;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 
+
 /**
  * Permission for one specific weblog
  * @ejb:bean name="WeblogPermission"
@@ -87,14 +90,6 @@ public class WeblogPermission extends Ob
         return null;
     }
 
-    public boolean equals(Object arg0) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public int hashCode() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
     public boolean implies(Permission perm) {
         if (perm instanceof WeblogPermission) {
             WeblogPermission rperm = (WeblogPermission)perm;
@@ -129,6 +124,25 @@ public class WeblogPermission extends Ob
         }
         return sb.toString();
     }
+
+    public boolean equals(Object other) {
+        if (other == this) return true;
+        if (other instanceof WeblogPermission != true) return false;
+        WeblogPermission o = (WeblogPermission)other;
+        return new EqualsBuilder()
+                .append(getUserName(), o.getUserName())
+                .append(getObjectId(), o.getObjectId())
+                .append(getActions(), o.getActions())
+                .isEquals();
+    }
+
+    public int hashCode() {
+        return new HashCodeBuilder()
+                .append(getUserName())
+                .append(getObjectId())
+                .append(getActions())
+                .toHashCode();
+    }
 }
 
 

Modified: roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/MediaFileTest.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/MediaFileTest.java?rev=1499866&r1=1499865&r2=1499866&view=diff
==============================================================================
--- roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/MediaFileTest.java
(original)
+++ roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/MediaFileTest.java
Thu Jul  4 20:49:47 2013
@@ -75,7 +75,7 @@ public class MediaFileTest extends TestC
         Weblog testWeblog = null;
 
         // TODO: Setup code, to be moved to setUp method.
-        System.out.println("Before setting up weblogger");
+        log.info("Before setting up weblogger");
         // setup weblogger
         try {
             testUser = TestUtils.setupUser("mediaFileTestUser8");
@@ -172,7 +172,7 @@ public class MediaFileTest extends TestC
         Weblog testWeblog = null;
 
         // TODO: Setup code, to be moved to setUp method.
-        System.out.println("Before setting up weblogger");
+        log.info("Before setting up weblogger");
         // setup weblogger
         try {
             testUser = TestUtils.setupUser("mediaFileTestUser");
@@ -658,23 +658,23 @@ public class MediaFileTest extends TestC
 	        //TestUtils.endSession(true);
 	
 	        for (int i = 0; i < 15; i++) {
-		        rootDirectory = mfMgr.getMediaFileDirectory(rootDirectory.getId());	
-		        testWeblog = TestUtils.getManagedWebsite(testWeblog);
-	            MediaFile mediaFile = new MediaFile();
-	            mediaFile.setName("test_file<index>.jpg".replace("<index>", i +
""));
-	            mediaFile.setDescription("This is a test image");
-	            mediaFile.setCopyrightText("test copyright text");
-	            mediaFile.setSharedForGallery(true);
-	            mediaFile.setLength(2000);
-	            mediaFile.setWeblog(testWeblog);
-	            mediaFile.setInputStream(getClass().getResourceAsStream(TEST_IMAGE));
-	            mediaFile.setContentType("image/jpeg");
-	            mfMgr.createMediaFile(testWeblog, mediaFile, new RollerMessages());
-	            rootDirectory.getMediaFiles().add(mediaFile);
-	            mediaFile.setDirectory(rootDirectory);
-	            assertNotNull(mediaFile.getId());
-	            assertNotNull(mediaFile.getId().length() > 0);
-		        TestUtils.endSession(true);
+                rootDirectory = mfMgr.getMediaFileDirectory(rootDirectory.getId());
+                testWeblog = TestUtils.getManagedWebsite(testWeblog);
+                MediaFile mediaFile = new MediaFile();
+                mediaFile.setName("test_file<index>.jpg".replace("<index>", i
+ ""));
+                mediaFile.setDescription("This is a test image");
+                mediaFile.setCopyrightText("test copyright text");
+                mediaFile.setSharedForGallery(true);
+                mediaFile.setLength(2000);
+                mediaFile.setWeblog(testWeblog);
+                mediaFile.setInputStream(getClass().getResourceAsStream(TEST_IMAGE));
+                mediaFile.setContentType("image/jpeg");
+                mediaFile.setDirectory(rootDirectory);
+                mfMgr.createMediaFile(testWeblog, mediaFile, new RollerMessages());
+                rootDirectory.getMediaFiles().add(mediaFile);
+                assertNotNull(mediaFile.getId());
+                assertNotNull(mediaFile.getId().length() > 0);
+                TestUtils.endSession(true);
 	        }
 	        
 	        testWeblog = TestUtils.getManagedWebsite(testWeblog);

Modified: roller/trunk/app/src/test/java/org/apache/roller/weblogger/util/LinkbackExtractorTest.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/test/java/org/apache/roller/weblogger/util/LinkbackExtractorTest.java?rev=1499866&r1=1499865&r2=1499866&view=diff
==============================================================================
--- roller/trunk/app/src/test/java/org/apache/roller/weblogger/util/LinkbackExtractorTest.java
(original)
+++ roller/trunk/app/src/test/java/org/apache/roller/weblogger/util/LinkbackExtractorTest.java
Thu Jul  4 20:49:47 2013
@@ -34,7 +34,7 @@ public class LinkbackExtractorTest exten
     public LinkbackExtractorTest(String arg0) {
         super(arg0);
     }
-    
+
     public static void main(String[] args) {
     }
     
@@ -55,24 +55,23 @@ public class LinkbackExtractorTest exten
     public void testLinkbackExtractor() throws Exception {
         String[][] testrefs = new String[][]
         {
+            // Second URL contains a link to the first
             {
-                "http://www.rollerweblogger.org/page/roller",
-                        "http://staff.develop.com/halloway/weblog/2003/01/23.html"
+                "http://www.atomenabled.org",
+                        "http://rollerweblogger.org/roller/entry/wip_feed_based_integration"
             },
             {
-                "http://postneo.com/",
-                        "http://www.rollerweblogger.org/page/roller/20030125"
+                "http://rollermobile.blogspot.com/",
+                        "http://rollerweblogger.org/project/date/20110523"
             }
         };
-        
-        for ( int i=0; i<testrefs.length; i++ ) {
-            String refurl = testrefs[i][0];
-            String requrl = testrefs[i][1];
-            LinkbackExtractor le = new LinkbackExtractor(refurl,requrl);
-            System.out.println(le.getTitle());
-            System.out.println(le.getPermalink());
-            System.out.println(le.getExcerpt());
-        }
+
+        LinkbackExtractor le = new LinkbackExtractor(testrefs[0][0],testrefs[0][1]);
+        assertEquals("AtomEnabled.org", le.getTitle());
+        le = new LinkbackExtractor(testrefs[1][0],testrefs[1][1]);
+        assertEquals("Apache Roller Mobile Platform", le.getTitle());
+
+        // todo: le.getPermalink() and le.getExcerpt() working
     }
     
     public static Test suite() {

Modified: roller/trunk/app/src/test/resources/roller-custom.properties
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/test/resources/roller-custom.properties?rev=1499866&r1=1499865&r2=1499866&view=diff
==============================================================================
--- roller/trunk/app/src/test/resources/roller-custom.properties (original)
+++ roller/trunk/app/src/test/resources/roller-custom.properties Thu Jul  4 20:49:47 2013
@@ -11,8 +11,9 @@ openjpa.ConnectionRetainMode=always
 openjpa.Log=commons
 
 #see http://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging
-#eclipselink.logging.file=output.log
-#eclipselink.logging.level=ALL
+#eclipselink.logging.file=target/eclipselink.log
+# OFF, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, ALL
+#eclipselink.logging.level=FINER
 
 hibernate.dialect=org.hibernate.dialect.DerbyDialect
 hibernate.transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory

Modified: roller/trunk/pom.xml
URL: http://svn.apache.org/viewvc/roller/trunk/pom.xml?rev=1499866&r1=1499865&r2=1499866&view=diff
==============================================================================
--- roller/trunk/pom.xml (original)
+++ roller/trunk/pom.xml Thu Jul  4 20:49:47 2013
@@ -33,4 +33,17 @@
         <module>app</module>
     </modules>
 
-</project>
\ No newline at end of file
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-idea-plugin</artifactId>
+                <version>2.2</version>
+                <configuration>
+                    <downloadSources>true</downloadSources>
+                </configuration>
+            </plugin>
+         </plugins>
+     </build>
+
+</project>



Mime
View raw message