jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaqu...@apache.org
Subject svn commit: r830055 - in /incubator/jspwiki/trunk: ChangeLog build.xml etc/ldap/slapd.conf src/java/org/apache/wiki/Release.java src/java/org/apache/wiki/content/jcr/JCRWikiPage.java tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
Date Tue, 27 Oct 2009 04:34:37 GMT
Author: ajaquith
Date: Tue Oct 27 04:34:36 2009
New Revision: 830055

URL: http://svn.apache.org/viewvc?rev=830055&view=rev
Log:
Fixed single last unit test bug. Although LDAP tests won't work if a test LDAP server isn't
running, all other unit tests run 100% clean. This is the first time that has happened in
at least a year. Test times: 7 minutes 51 seconds for 1024 tests. Added Ant script to start
OpenLDAP test fixture if available. Fixed JCRWikiPage bug that was causing JCR exceptions
when attributes were not set.

Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/build.xml
    incubator/jspwiki/trunk/etc/ldap/slapd.conf
    incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/content/jcr/JCRWikiPage.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=830055&r1=830054&r2=830055&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Tue Oct 27 04:34:36 2009
@@ -1,3 +1,18 @@
+2009-10-26 Andrew Jaquith <ajaquith AT apache DOT org>
+
+        * 3.0.0-svn-173
+
+        * Fixed single last unit test bug. Although LDAP tests won't work
+        if a test LDAP server isn't running, all other unit tests run
+        100% clean. This is the first time that has happened in at
+        least a year. Test times: 7 minutes 51 seconds for 1024 tests.
+
+        * Added Ant script to start OpenLDAP test fixture if
+        available.
+
+        * Fixed JCRWikiPage bug that was causing JCR exceptions when
+        attributes were not set. 
+
 2009-10-25 Andrew Jaquith <ajaquith AT apache DOT org>
 
         * 3.0.0-svn-172

Modified: incubator/jspwiki/trunk/build.xml
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/build.xml?rev=830055&r1=830054&r2=830055&view=diff
==============================================================================
--- incubator/jspwiki/trunk/build.xml (original)
+++ incubator/jspwiki/trunk/build.xml Tue Oct 27 04:34:36 2009
@@ -103,9 +103,11 @@
   <property name="tests.classpath" value="${build}/tests/classpath" />
   <property name="tests.webinf" value="${tests.classpath}/WEB-INF" />
   <property name="tests.db" value="${build}/tests/db" />
+  <property name="tests.ldap" value="${build}/tests/ldap" />
   <property name="tests.pagedir" value="${build}/tests/priha" />
   <property name="tests.reports" value="${build}/tests/reports" />
   <property name="tests.workdir" value="${build}/tests/workdir" />
+  <available property="openldap" file="/usr/libexec/slapd" value="/usr/libexec/slapd"
/>
   
   <!-- The location of the JAR file for the test classes -->
   <property name="testjarfile" location="${build}/${ant.project.name}-tests.jar" />
@@ -756,7 +758,7 @@
 
        More info http://ant.apache.org/faq.html#delegating-classloader
    -->
-  <target name="tests" depends="jar,tests-init,jartests,tests-db-init"
+  <target name="tests" depends="jar,tests-init,jartests,tests-db-init,tests-ldap-init"
           description="Runs the JUnit tests.">
 
     <junit printsummary="yes" haltonfailure="no" fork="yes" forkmode="once" maxmemory="512m">
@@ -1302,6 +1304,74 @@
   </target>
 
   <!-- ============================================================== -->
+
+  <!-- OpenLDAP server startup/shutdown (for testing LDAP integration) -->
+
+  <!-- Special "init" target for OpenLDAP -->
+  <target name="tests-ldap-init" depends="ldap-check-start,ldap-start" if="openldap" />
+
+  <target name="ldap-check-start" if="openldap">
+    <echo message="Checking to see if OpenLDAP server is running already." />
+    <condition property="ldap.up">
+      <socket server="localhost" port="4890" />
+    </condition>
+  </target>
+
+  <target name="ldap-start" depends="ldap-check-start" unless="ldap.up" if="openldap"
+    description="Starts OpenLDAP for testing.">
+    <echo message="Starting OpenLDAP server on localhost." />
+    <delete dir="${tests.ldap}" />
+    <mkdir dir="${tests.ldap}" />
+    <mkdir dir="${tests.ldap}/data" />
+    <exec executable="${openldap}" dir="." spawn="true">
+      <arg value="-f" />
+      <arg value="${basedir}/etc/ldap/slapd.conf" />
+      <arg value="-h" />
+      <arg value="ldap://127.0.0.1:4890/" />
+      <arg value="-d" />
+      <arg value="-1" />
+      <arg value="-u" />
+      <arg value="${env.USER}" />
+    </exec>
+    <sleep seconds="3" />
+    <echo message="Loading sample schema." />
+    <exec executable="ldapadd" dir=".">
+      <arg value="-x" />
+      <arg value="-h" />
+      <arg value="127.0.0.1" />
+      <arg value="-p" />
+      <arg value="4890" />
+      <arg value="-D" />
+      <arg value="cn=Manager,dc=jspwiki,dc=org" />
+      <arg value="-w" />
+      <arg value="test" />
+      <arg value="-f" />
+      <arg value="${basedir}/etc/ldap/test.ldif" />
+    </exec>
+    <sleep seconds="3" />
+    <available file="${tests.ldap}/slapd.pid" property="ldap.up"/>
+    <fail unless="ldap.up">OpenLDAP didn't appear to start up properly. You can start
it manually from the command line as follows:
+   ${openldap} -f etc/ldap/slapd.conf -h "ldap://127.0.0.1:4890/" -d -1 -u ${env.USER}
+    </fail>
+    <echo message="Done." />
+  </target>
+
+  <target name="ldap-stop" depends="ldap-check-start" if="ldap.up"
+    description="Shuts down the OpenLDAP test server, if it's up.">
+    <echo message="Shutting down OpenLDAP server on localhost." />
+    <exec executable="killall">
+      <arg value="-u" />
+      <arg value="arj" />
+      <arg value="-c" />
+      <arg value="slapd" />
+    </exec>
+    <delete dir="${tests.ldap}/data" />
+    <delete file="${tests.ldap}/slapd.args" />
+    <delete file="${tests.ldap}/slapd.pid" />
+    <echo message="Done." />
+  </target>
+
+  <!-- ============================================================== -->
   <target name="i18n-create-template" description="Creates a given directory structure
with all the needed files to make an i18n jar">
 	<input message="i18n template code to generate (ie: es_ES):" addproperty="i18n.template"
/>
 

Modified: incubator/jspwiki/trunk/etc/ldap/slapd.conf
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/etc/ldap/slapd.conf?rev=830055&r1=830054&r2=830055&view=diff
==============================================================================
--- incubator/jspwiki/trunk/etc/ldap/slapd.conf (original)
+++ incubator/jspwiki/trunk/etc/ldap/slapd.conf Tue Oct 27 04:34:36 2009
@@ -2,8 +2,8 @@
 include       /private/etc/openldap/schema/cosine.schema
 include       /private/etc/openldap/schema/inetorgperson.schema
 include       /private/etc/openldap/schema/nis.schema
-pidfile       /Users/arj/workspace/ldap/run/slapd.pid
-argsfile      /Users/arj/workspace/ldap/run/slapd.args
+pidfile       build/tests/ldap/slapd.pid
+argsfile      build/tests/ldap/slapd.args
 database      bdb
 suffix        "dc=jspwiki,dc=org"
 # Use SASL so we can use DIGEST-MD5 authentication
@@ -31,6 +31,6 @@
 rootdn        "cn=Manager,dc=jspwiki,dc=org"
 rootpw        {SSHA}RJMzbtilrHxvREvaJP7eTBZzSN1Za73l
 
-directory	    /Users/arj/workspace/ldap/data
+directory	    build/tests/ldap/data
 index         objectClass,uid,uidNumber,gidNumber             eq
 index         cn,mail,surname,givenname                       eq,subinitial

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=830055&r1=830054&r2=830055&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Tue Oct 27 04:34:36 2009
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "172";
+    public static final String     BUILD         = "173";
 
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/content/jcr/JCRWikiPage.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/jcr/JCRWikiPage.java?rev=830055&r1=830054&r2=830055&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/content/jcr/JCRWikiPage.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/content/jcr/JCRWikiPage.java Tue Oct
27 04:34:36 2009
@@ -136,7 +136,17 @@
      */
     public Node getJCRNode() throws RepositoryException
     {
-        return m_engine.getContentManager().getJCRNode(m_jcrPath);
+        Node node;
+        try
+        {
+            node = m_engine.getContentManager().getJCRNode(m_jcrPath);
+        }
+        catch ( PathNotFoundException e )
+        {
+            // If the Node was never created, create one now
+            node = m_engine.getContentManager().createJCRNode( m_jcrPath );
+        }
+        return node;
     }
     
     /**
@@ -157,6 +167,8 @@
 
     /**
      * {@inheritDoc}
+     * This implementation looks up the JCR {@link Property} with the name {@code key}.
+     * If the attribute is found, its value is found. If not, {@code null} is returned.
      */
     public Serializable getAttribute( String key )
     {
@@ -173,6 +185,11 @@
                 throw new IllegalStateException( "The value returned by " + key + " was not
a Serializable, as expected.");
             }
         }
+        catch( PathNotFoundException e )
+        {
+            // This just means the attribute does not exist. No worries...
+            return null;
+        }
         catch( ItemNotFoundException e )
         {
             log.error( "ItemNotFoundException occurred while getting Attribute " + key, e
);
@@ -182,8 +199,6 @@
             // the following exception still occurs quite often, so no stacktrace for now
             log.info( "RepositoryException occurred while getting Attribute " + key + " :
"  +  e );
         }
-        // until this is fixed we want some more diagnostic info 
-        log.info("attribute value for key " + key + " is not Serializable, returning null
value");
         return null;
     }
 
@@ -224,7 +239,7 @@
             // the right thing to do here.
             getJCRNode().setProperty( key, attribute.toString() );
         }
-        catch(RepositoryException e) 
+        catch( RepositoryException e ) 
         {
             log.error( "Exception occurred while setting (Serializable) attribute " + key,
e );
         }

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java?rev=830055&r1=830054&r2=830055&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
(original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
Tue Oct 27 04:34:36 2009
@@ -69,9 +69,11 @@
 
     public void tearDown() throws Exception
     {
-        testEngine.emptyRepository();
-        
-        testEngine.shutdown();
+        if ( testEngine != null )
+        {
+            testEngine.emptyRepository();
+            testEngine.shutdown();
+        }
     }
 
     private void newPage( String name )
@@ -128,6 +130,8 @@
         props.load( TestEngine.findTestProperties() );
 
         props.setProperty( "jspwiki.translatorReader.useRelNofollow", "true" );
+        testEngine.shutdown();
+
         TestEngine testEngine2 = new TestEngine( props );
 
         WikiContext context = testEngine2.getWikiContextFactory().newViewContext( testEngine2.createPage(
PAGE_NAME ) );
@@ -531,6 +535,8 @@
 
         assertEquals( "This should be a <a class=\"external\" href=\"http://www.regex.fi/\"
rel=\"nofollow\">link</a>",
                       translate_nofollow(src) );
+
+        testEngine = null;
     }
 
     //



Mime
View raw message