• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Change
  • Next Change →

Changeset 102 for branches/omero

Show
Ignore:
Timestamp:
06/09/05 12:08:03 (4 years ago)
Author:
jmoore
Message:

Ha Ha. Things are working.


Unit/Integration testing works on a switch in maven "maven.test.mode"
All current tests passed, though there will be issues with nulls in
the returned objects.

Location:
branches/omero
Files:
2 removed
13 modified
3 moved

  • components/client/.springBeans (modified) (1 diff)
  • components/client/src/client.properties (deleted)
  • components/client/test/org/openmicroscopy/omero/client/itests/OmeroGrinderTest.java (moved) (moved from branches/omero/components/client/test/org/openmicroscopy/omero/client/OmeroGrinderTest.java) (2 diffs)
  • components/client/test/org/openmicroscopy/omero/client/itests/OmeroHierarchyBrowsingIntegrationTest.java (moved) (moved from branches/omero/components/client/test/org/openmicroscopy/omero/client/OmeroHierarchyBrowsingIntegrationTest.java) (1 diff)
  • components/client/test/org/openmicroscopy/omero/client/itests/test.xml (moved) (moved from branches/omero/components/client/test/org/openmicroscopy/omero/client/test.xml) (1 diff)
  • components/client/test/org/openmicroscopy/omero/client/tests (deleted)
  • components/server/.classpath (modified) (2 diffs)
  • components/server/maven.xml (modified) (1 diff)
  • components/server/project.xml (modified) (3 diffs)
  • components/server/src/org/openmicroscopy/omero/logic/HierarchyBrowsingImpl.java (modified) (10 diffs)
  • components/server/src/org/openmicroscopy/omero/logic/queries.hbm.xml (modified) (2 diffs)
  • components/server/src/spring.properties (modified) (1 diff)
  • components/server/test/org/openmicroscopy/omero/server/itests/OmeroServiceTest.java (modified) (1 diff)
  • components/server/test/org/openmicroscopy/omero/server/utests/HierarchyBrowsingUnitTest.java (modified) (1 diff)
  • components/server/web/WEB-INF/config-test.xml (modified) (1 diff)
  • components/server/web/WEB-INF/data.xml (modified) (1 diff)
  • components/server/web/WEB-INF/web.xml (modified) (1 diff)
  • maven.xml (modified) (2 diffs)

Legend:

Unmodified
Added
Removed
  • branches/omero/components/client/.springBeans

    r98 r102  
    22<beansProjectDescription> 
    33        <configs> 
    4                 <config>test/org/openmicroscopy/omero/tests/client/test.xml</config> 
     4                <config>test/org/openmicroscopy/omero/client/itests/test.xml</config> 
    55                <config>src/org/openmicroscopy/omero/client/spring.xml</config> 
    66        </configs> 
  • branches/omero/components/client/test/org/openmicroscopy/omero/client/itests/OmeroGrinderTest.java

    r101 r102  
    22 * Created on Jun 7, 2005 
    33 */ 
    4 package org.openmicroscopy.omero.tests.client; 
     4package org.openmicroscopy.omero.client.itests; 
    55 
    66import org.openmicroscopy.omero.tests.AbstractOmeroHierarchyBrowserIntegrationTest; 
    … …  
    2121        return new String[]{ 
    2222                "org/openmicroscopy/omero/client/spring.xml", 
    23                 "org/openmicroscopy/omero/tests/client/test.xml"};  
     23                "org/openmicroscopy/omero/client/itests/test.xml"};  
    2424    } 
    2525     
  • branches/omero/components/client/test/org/openmicroscopy/omero/client/itests/OmeroHierarchyBrowsingIntegrationTest.java

    r101 r102  
    22 * Created on Jun 7, 2005 
    33*/ 
    4 package org.openmicroscopy.omero.tests.client; 
     4package org.openmicroscopy.omero.client.itests; 
    55 
    66import java.util.HashSet; 
  • branches/omero/components/client/test/org/openmicroscopy/omero/client/itests/test.xml

    r101 r102  
    1313            <property name="driverClassName"><value>${database.driver}</value></property> 
    1414        <property name="url"><value>${database.url}</value></property> 
    15             <property name="username"><value>${database.user}</value></property> 
     15            <property name="username"><value>${database.username}</value></property> 
    1616            <property name="password"><value>${database.password}</value></property> 
    1717        </bean> 
  • branches/omero/components/server/.classpath

    r99 r102  
    11<?xml version="1.0" encoding="UTF-8"?> 
    22<classpath> 
    3         <classpathentry kind="src" path="src"/> 
    4         <classpathentry kind="src" path="web/WEB-INF"/> 
    5         <classpathentry excluding="WEB-INF/|WEB-INF/" kind="src" path="web"/> 
    6         <classpathentry output="target/test-classes" kind="src" path="test"/> 
    7         <classpathentry output="target/test-classes" kind="src" path="itest"/> 
     3        <classpathentry excluding=".svn" kind="src" path="src"/> 
     4        <classpathentry excluding=".svn" kind="src" path="web"/> 
     5        <classpathentry excluding=".svn" kind="src" path="test"/> 
    86        <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-3.8.1.jar"/> 
    97        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 
    … …  
    3331        <classpathentry kind="var" path="MAVEN_REPO/dbunit/jars/dbunit-2.1.jar"/> 
    3432        <classpathentry kind="var" path="MAVEN_REPO/groovy/jars/groovy-all-1.0-beta-10.jar"/> 
    35         <classpathentry kind="output" path="target/classes"/> 
     33        <classpathentry kind="output" path="target/eclipse"/> 
    3634</classpath> 
  • branches/omero/components/server/maven.xml

    r98 r102  
    1414   <attainGoal name="tomcat:install"/> 
    1515 </goal> 
    16  
    17   <!-- For internal development. TODO --> 
    18   <preGoal name="war:war"> 
    19     <attainGoal name="jar:install"/> 
    20   </preGoal> 
    2116 
    2217 <!-- DB STUFF: TODO Perhaps in a build.xml (or use appfuses) --> 
  • branches/omero/components/server/project.xml

    r100 r102  
    179179    </dependency> 
    180180    <dependency> 
     181      <groupId>commons-lang</groupId> 
     182      <artifactId>commons-lang</artifactId> 
     183      <version>2.0</version> 
     184    </dependency> 
     185    <dependency> 
    181186      <groupId>commons-pool</groupId> 
    182187      <artifactId>commons-pool</artifactId> 
    … …  
    247252        <include>**/*Test.java</include> 
    248253      </includes> 
     254      <resources> 
     255        <resource> 
     256          <directory>${pom.build.unitTestSourceDirectory}</directory> 
     257          <includes> 
     258            <include>**/*.xml</include> 
     259            <include>**/*.properties</include> 
     260          </includes> 
     261        </resource> 
     262      </resources> 
    249263    </unitTest> 
    250264    <resources> 
    … …  
    253267        <includes> 
    254268          <include>**/*.hbm.xml</include> 
     269          <include>**/*.properties</include> 
     270        </includes> 
     271      </resource> 
     272      <resource> 
     273        <directory>web</directory> 
     274        <includes> 
     275          <include>**/*.xml</include> 
    255276        </includes> 
    256277      </resource> 
  • branches/omero/components/server/src/org/openmicroscopy/omero/logic/HierarchyBrowsingImpl.java

    r95 r102  
    3838 
    3939//Java imports 
     40import java.lang.reflect.InvocationTargetException; 
     41import java.lang.reflect.Method; 
    4042import java.util.HashMap; 
    4143import java.util.HashSet; 
    … …  
    4648 
    4749//Third-party libraries 
    48  
     50import org.hibernate.Hibernate; 
    4951 
    5052//Application-internal dependencies 
    … …  
    100102        } 
    101103 
    102         return containerDao.loadHierarchy(arg0, arg1); 
     104        return clean(containerDao.loadHierarchy(arg0, arg1)); 
    103105 
    104106    } 
    … …  
    115117        } 
    116118 
    117         return containerDao.loadHierarchy(arg0, arg1); 
     119        return clean(containerDao.loadHierarchy(arg0, arg1)); 
    118120 
    119121    } 
    … …  
    174176        } 
    175177 
    176         return hierarchies; 
     178        return (Set) clean(hierarchies); 
    177179 
    178180    } 
    … …  
    239241        } 
    240242 
    241         return hierarchies; 
     243        return (Set) clean(hierarchies); 
    242244    } 
    243245 
    … …  
    253255 
    254256        List result = annotationDao.findImageAnnotations(arg0); 
    255         return sortImageAnnotations(result); 
     257        return (Map) clean(sortImageAnnotations(result)); 
    256258 
    257259    } 
    … …  
    270272        List result = annotationDao.findImageAnnotationsForExperimenter(arg0, 
    271273                arg1); 
    272         return sortImageAnnotations(result); 
     274        return (Map) clean(sortImageAnnotations(result)); 
    273275 
    274276    } 
    … …  
    309311 
    310312        List result = annotationDao.findDataListAnnotations(arg0); 
    311         return sortDatasetAnnotations(result); 
     313        return (Map) clean(sortDatasetAnnotations(result)); 
    312314 
    313315    } 
    … …  
    354356    } 
    355357 
     358    /** top-level call. If this is not initialized abort */ 
     359    Object clean(Object obj){ 
     360        if (! Hibernate.isInitialized(obj)){ 
     361            throw new IllegalStateException("If the return object is not initialized then we can't send it."); 
     362        } 
     363        Set done = new HashSet(); 
     364        hessianClean(obj,done); 
     365        return obj; 
     366    } 
     367        
     368    void hessianClean(Object obj, Set done) { 
     369         
     370        if (null==obj) return; 
     371        if (done.contains(obj)) return; 
     372        done.add(obj); 
     373         
     374        if (obj instanceof Map) { 
     375            Map map = (Map) obj; 
     376            for (Iterator i = map.values().iterator(); i.hasNext();) { 
     377                Object value = i.next(); 
     378                hessianClean(value,done); 
     379            } 
     380        } else if (obj instanceof Set) { 
     381            Set set = (Set) obj; 
     382            for (Iterator i = set.iterator(); i.hasNext();) { 
     383                Object item = i.next(); 
     384                hessianClean(item,done); 
     385            } 
     386        } else { // TODO can check for super class when implemented 
     387            Method[] methods = obj.getClass().getDeclaredMethods(); 
     388            for (int i = 0; i < methods.length; i++) { 
     389                Method method = methods[i]; 
     390                if (method.getName().startsWith("get")){ 
     391                    if (0==method.getParameterTypes().length){ 
     392                        Object result=invokeGetter(obj,method); 
     393                        if (! Hibernate.isInitialized(result)){ 
     394                            Method setter = getSetterForGetter(methods,method); 
     395                            if (null==setter){ 
     396                                throw new IllegalStateException("No setter for getter; this will explode"); 
     397                            } 
     398                            setToNull(obj,setter); 
     399                        } else { 
     400                            hessianClean(result,done); 
     401                        } 
     402                    } 
     403                } 
     404            } 
     405             
     406        } 
     407    } 
     408     
     409    Method getSetterForGetter(Method[] methods, Method getter){ 
     410        for (int i = 0; i < methods.length; i++) { 
     411            Method method = methods[i]; 
     412            if (method.getName().startsWith("set")){ 
     413                if (method.getName().substring(1).equals(getter.getName().substring(1))){ 
     414                    return method; 
     415                } 
     416            } 
     417        } 
     418        return null; 
     419    } 
     420     
     421    Object invokeGetter(Object target, Method getter){ 
     422        Object result=null; 
     423        try { 
     424            result = getter.invoke(target,new Object[]{}); 
     425        } catch (IllegalArgumentException e) { 
     426            // TODO Auto-generated catch block 
     427            e.printStackTrace(); 
     428        } catch (IllegalAccessException e) { 
     429            // TODO Auto-generated catch block 
     430            e.printStackTrace(); 
     431        } catch (InvocationTargetException e) { 
     432            // TODO Auto-generated catch block 
     433            e.printStackTrace(); 
     434        } 
     435        return result; 
     436    } 
     437     
     438    void setToNull(Object obj, Method setter){ 
     439        RuntimeException re = new RuntimeException("Error trying to set to null");  
     440 
     441        try { 
     442            setter.invoke(obj,new Object[]{null}); 
     443        } catch (IllegalArgumentException e) { 
     444            // TODO Auto-generated catch block 
     445            e.printStackTrace(); 
     446            throw re; 
     447        } catch (IllegalAccessException e) { 
     448            // TODO Auto-generated catch block 
     449            e.printStackTrace(); 
     450            throw re; 
     451        } catch (InvocationTargetException e) { 
     452            // TODO Auto-generated catch block 
     453            e.printStackTrace(); 
     454            throw re; 
     455        } 
     456    } 
    356457 
    357458 
  • branches/omero/components/server/src/org/openmicroscopy/omero/logic/queries.hbm.xml

    r95 r102  
    66<hibernate-mapping> 
    77  <!-- load*Hierarchy  
    8         TODO if all ids where called *.getId() then we could merge these 
     8        TODO if all ids where called *.getId() then we could merge these  
    99        --> 
    1010         
    … …  
    3131  <!-- find*Hierarchies --> 
    3232  <query name="findPDI"><![CDATA[ 
    33         from Image as i where i in (:img_list) 
     33        from Image as i join fetch i.datasets as ds join fetch ds.projects as prj  
     34          where i in (:img_list) 
    3435  ]]></query>    
    3536   
    3637  <query name="findCGCI"><![CDATA[ 
    37         from Image as i where i in (:img_list) 
     38        from Image as i join fetch i.classifications as cla  
     39          where i in (:img_list) 
    3840  ]]></query>    
    3941   
  • branches/omero/components/server/src/spring.properties

    r98 r102  
     1# Database and Server properties generated from build properties TODO remove from svn 
     2#Wed Jun 08 22:55:04 CEST 2005 
     3database.username=josh 
    14TODO=deprecate 
    2 db.url=jdbc:postgresql://localhost/ome 
     5server.host=localhost 
     6db.url=jdbc\:postgresql\://localhost/ome 
     7database.show_sql=true 
     8database.url=jdbc\:postgresql\://localhost/ome 
     9local.path=/home/josh/code/omero/components/server/target/classes 
     10db.driver=org.postgresql.Driver 
     11server.port=8080 
     12db.dialect=org.hibernate.dialect.PostgreSQLDialect 
     13database.password="" 
     14database.dialect=org.hibernate.dialect.PostgreSQLDialect 
    315db.user=josh 
     16database.driver=org.postgresql.Driver 
    417db.password="" 
    5 db.driver=org.postgresql.Driver 
    6 db.dialect=org.hibernate.dialect.PostgreSQLDialect 
    7 #show_sql=false 
  • branches/omero/components/server/test/org/openmicroscopy/omero/server/itests/OmeroServiceTest.java

    r99 r102  
    1919     */ 
    2020    protected String[] getConfigLocations() { 
    21         System.out.println(System.getProperty("user.dir")); 
     21 
    2222        return new String[]{ 
    2323                "WEB-INF/services.xml", 
    24                 "org/openmicroscopy/omero/tests/client/test.xml", 
    25                 "WEB-INF/dao.xml"};  
     24                "WEB-INF/dao.xml", 
     25                "WEB-INF/data.xml", 
     26                "WEB-INF/config-test.xml"};  
    2627    } 
    2728     
  • branches/omero/components/server/test/org/openmicroscopy/omero/server/utests/HierarchyBrowsingUnitTest.java

    r95 r102  
    1 package org.openmicroscopy.omero.tests; 
     1package org.openmicroscopy.omero.server.utests; 
    22 
    33import java.util.ArrayList; 
  • branches/omero/components/server/web/WEB-INF/config-test.xml

    r49 r102  
    99                <property name="locations"> 
    1010                <list> 
    11                         <value>target/classes/spring.properties</value> 
     11                        <value>spring.properties</value> 
    1212                </list> 
    1313                </property> 
    1414        </bean> 
    1515 
     16        <!-- Add this config file to the getConfigLocations() of your tests 
     17                if you want data and interfaces injected --> 
     18        <bean id="data" class="org.openmicroscopy.omero.tests.OMEPerformanceData" init-method="init"> 
     19                <property name="dataSource" ref="dataSource"/> 
     20        </bean> 
     21 
    1622</beans> 
  • branches/omero/components/server/web/WEB-INF/data.xml

    r99 r102  
    4646            <property name="driverClassName"><value>${database.driver}</value></property> 
    4747        <property name="url"><value>${database.url}</value></property> 
    48             <property name="username"><value>${database.user}</value></property> 
     48            <property name="username"><value>${database.username}</value></property> 
    4949            <property name="password"><value>${database.password}</value></property> 
    5050        </bean> 
  • branches/omero/components/server/web/WEB-INF/web.xml

    r98 r102  
    5858                /WEB-INF/services.xml  
    5959                /WEB-INF/dao.xml                         
     60                /WEB-INF/data.xml                        
    6061<!--                    /WEB-INF/security.xml --> 
    6162        </param-value> 
  • branches/omero/maven.xml

    r100 r102  
    4343      <ant:mkdir dir="${maven.build.dest}"/> 
    4444      <ant:propertyfile  
    45         comment=" Database and Server properties generated from build properties"  
    46                         file="${maven.build.dest}/spring.properties"> 
     45        comment=" Database and Server properties generated from build 
     46properties TODO remove from svn"  
     47                        file="${basedir}/src/spring.properties"> 
    4748         <ant:entry key="database.driver" value="${database.driver}"/> 
    4849         <ant:entry key="database.url" value="${database.url}"/> 
    … …  
    6768   </goal> 
    6869 
     70 <!-- from: http://java2.5341.com/msg/33178.html --> 
    6971  <goal name="filterTests"> 
    7072   <j:set var="testModeX" value="${maven.test.mode}X" /> 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/