You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by dk...@apache.org on 2006/08/28 20:54:46 UTC

svn commit: r437778 [29/42] - in /incubator/tuscany/java: ./ buildtools/ buildtools/src/main/resources/ das/ das/rdb/ das/rdb/src/main/java/org/apache/tuscany/das/rdb/ das/rdb/src/main/java/org/apache/tuscany/das/rdb/generator/impl/ das/rdb/src/main/ja...

Modified: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DateConversionTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DateConversionTestCase.java?rev=437778&r1=437777&r2=437778&view=diff
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DateConversionTestCase.java (original)
+++ incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DateConversionTestCase.java Mon Aug 28 11:53:49 2006
@@ -1,363 +1,363 @@
-/**
- *
- *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.tuscany.sdo.test;
-
-import java.lang.reflect.Method;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-import junit.framework.TestCase;
-
-import commonj.sdo.helper.DataHelper;
-
-// DateConversionTestCase insures that the DataHelper conversions accurately
-// retain the information in the specified fields (e.g. month, day or year).
-// It also provides coverage for the DataHelper API.
-// Note that toDate is called each time Test.initialize() is called.
-
-public class DateConversionTestCase extends TestCase
-{
-    private static Calendar test_calendar;
-    private static Date test_date;
-    private static DataHelper data_helper;
-    
-    private static final TestType TO_DATE_TIME = new TestType("toDateTime", new int [] {Calendar.YEAR, Calendar.MONTH, 
-            Calendar.DAY_OF_MONTH, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND});
-    private static final TestType TO_DURATION = new TestType("toDuration", new int [] {Calendar.YEAR, Calendar.MONTH, 
-            Calendar.DAY_OF_MONTH, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND});
-    private static final TestType TO_TIME = new TestType("toTime", new int [] {Calendar.HOUR_OF_DAY, Calendar.MINUTE, 
-            Calendar.SECOND, Calendar.MILLISECOND});
-    private static final TestType TO_DAY = new TestType("toDay", new int[] {Calendar.DAY_OF_MONTH});
-    private static final TestType TO_MONTH = new TestType("toMonth", new int[] {Calendar.MONTH});
-    private static final TestType TO_MONTH_DAY = new TestType("toMonthDay", new int[] {Calendar.MONTH, Calendar.DAY_OF_MONTH});
-    private static final TestType TO_YEAR = new TestType("toYear", new int[] {Calendar.YEAR});
-    private static final TestType TO_YEAR_MONTH= new TestType("toYearMonth",  new int[] {Calendar.YEAR, Calendar.MONTH});
-    private static final TestType TO_YEAR_MONTH_DAY = new TestType("toYearMonthDay",  new int[] {Calendar.YEAR, 
-            Calendar.MONTH, Calendar.DAY_OF_MONTH});    
-    
-    public DateConversionTestCase() throws Exception
-    {
-        data_helper = DataHelper.INSTANCE;
-        test_calendar = new GregorianCalendar();
-        test_calendar.setTime(new Date(System.currentTimeMillis()));
-        test_date = test_calendar.getTime();  
-    }
-    
-    private static class TestType
-    {
-        private static final Class[] DATE_CLASS_ARRAY = {Date.class};
-        private static final Class[] CALENDAR_CLASS_ARRAY = {Calendar.class};
-        
-        Method date_method;
-        Method calendar_method;
-        int [] compare_fields;  
-        
-        public TestType (String method_name, int [] compare_fields)
-        {
-            try
-            {
-                this.date_method = DataHelper.class.getMethod(method_name, DATE_CLASS_ARRAY);
-            }
-            catch (NoSuchMethodException e)
-            {
-                this.date_method = null;
-            }
-                
-            this.compare_fields = compare_fields;    
-            try
-            {
-                this.calendar_method = DataHelper.class.getMethod(method_name, CALENDAR_CLASS_ARRAY);
-            }
-            catch (NoSuchMethodException e)
-            {
-                this.calendar_method = null;
-            }
-
-        }
-        
-        public Method getDateMethod()
-        {
-            return this.date_method;
-        }
-        
-        public Method getCalendarMethod()
-        {
-            return this.calendar_method;
-        }
-    }
-    
-    private static class Test
-    {
-        String from_type;
-        Date from_date;    
-        Calendar from_calendar;
-        Class expected_exception;
-        
-        public Test ()
-        {
-            this.from_date = null;
-            this.from_calendar = null;
-            expected_exception = null;
-        }
-        
-        public void initialize (TestType from_type)
-        {            
-            this.from_type = from_type.getDateMethod().getName();
-            
-            try
-            {    
-                String date_string = (String) from_type.getDateMethod().invoke(data_helper, new Object[] {test_date});
-                this.from_date = data_helper.toDate(date_string);
-                date_string = (String) from_type.getCalendarMethod().invoke(data_helper, new Object[] {test_calendar});
-                this.from_calendar = data_helper.toCalendar(date_string);
-            }
-            catch (Exception e)
-            {
-                this.from_date = null;
-                this.from_calendar = null;
-            }
-            
-        }
-        
-        // This method is needed because there is not a toDate(Date) method in DataHelper.
-        
-        public void initializeToDate()
-        {
-            this.from_calendar = test_calendar;
-            this.from_date = test_date;
-            this.from_type = "toDate";
-        }
-        
-        public void attemptConversion (TestType to_type) throws Exception
-        {
-            executeConversion(to_type.getDateMethod(), new Object[] {this.from_date}, to_type.compare_fields);
-            executeConversion(to_type.getCalendarMethod(), new Object[] {this.from_calendar}, to_type.compare_fields);
-        }
-        
-        private void executeConversion (Method conversion, Object[] parm, int [] compare_fields) throws Exception
-        {
-            String result;
-            
-            try
-            {
-                result = (String) conversion.invoke(data_helper, parm);
-            }
-            catch (Exception e)
-            {
-                System.err.println("An unexpected exception was thrown while calling " + conversion.getName() + 
-                        " after initializing with " + this.from_type + ".");
-                throw e;
-            }
-
-             assertTrue("The expected value did not result when calling " + conversion.getName() + 
-                    " after initializing with " + this.from_type + ".", compareFields(parm[0], result, compare_fields));
-        }
-        
-        private boolean compareFields(Object compare_to, String output, int [] compare_fields)
-        {
-            Calendar result = data_helper.toCalendar(output);
-            Calendar expected;
-            
-            if (compare_to instanceof Calendar)
-                expected = (GregorianCalendar) test_calendar;
-            else
-            {
-                expected = new GregorianCalendar();
-                expected.setTime((Date) test_date);
-            }
-            
-            for (int i = 0; i < compare_fields.length; i++)
-            {
-                if (expected.get(compare_fields[i]) != result.get(compare_fields[i]))
-                   return false;
-            }
-            return true;
-        }
-        
-    }
-
-    /*
-    public void testConversionsFromDay() throws Exception
-    {
-        Test FromDay = new Test();
-        
-        FromDay.initialize(TO_DAY);
-        
-        FromDay.attemptConversion(TO_DAY);
-    }
-
-    public void testConversionsFromDate() throws Exception
-    {
-        Test FromDate = new Test();
-        
-        FromDate.initializeToDate();
-        
-        FromDate.attemptConversion(TO_DATE_TIME);
-        FromDate.attemptConversion(TO_DURATION);
-        FromDate.attemptConversion(TO_TIME);
-        FromDate.attemptConversion(TO_DAY);
-        FromDate.attemptConversion(TO_MONTH);
-        FromDate.attemptConversion(TO_MONTH_DAY);
-        FromDate.attemptConversion(TO_YEAR);
-        FromDate.attemptConversion(TO_YEAR_MONTH);
-        FromDate.attemptConversion(TO_YEAR_MONTH_DAY);           
-    }
-  
-    public void testConversionsFromDateTime() throws Exception
-    {
-        Test FromDateTime = new Test();
-        
-        FromDateTime.initialize(TO_DATE_TIME);
-
-        FromDateTime.attemptConversion(TO_DATE_TIME);
-        FromDateTime.attemptConversion(TO_DURATION);
-        FromDateTime.attemptConversion(TO_TIME);
-        FromDateTime.attemptConversion(TO_DAY);
-        FromDateTime.attemptConversion(TO_MONTH);
-        FromDateTime.attemptConversion(TO_MONTH_DAY);
-        FromDateTime.attemptConversion(TO_YEAR);
-        FromDateTime.attemptConversion(TO_YEAR_MONTH);
-        FromDateTime.attemptConversion(TO_YEAR_MONTH_DAY);            
-    }
-    
-    public void testConversionsFromDuration() throws Exception
-    {
-        Test FromDuration = new Test();
-        
-        FromDuration.initialize(TO_DURATION);
-
-        FromDuration.attemptConversion(TO_DURATION);
-        FromDuration.attemptConversion(TO_DATE_TIME);
-        FromDuration.attemptConversion(TO_TIME);
-        FromDuration.attemptConversion(TO_DAY);
-        FromDuration.attemptConversion(TO_MONTH);
-        FromDuration.attemptConversion(TO_MONTH_DAY);
-        FromDuration.attemptConversion(TO_YEAR);
-        FromDuration.attemptConversion(TO_YEAR_MONTH);
-        FromDuration.attemptConversion(TO_YEAR_MONTH_DAY);                   
-    }
-    
-    public void testConversionsFromMonth() throws Exception
-    {
-        Test FromMonth = new Test();
-        
-        FromMonth.initialize(TO_MONTH);
-
-        FromMonth.attemptConversion(TO_MONTH);           
-    } 
-    
-    public void testConversionsFromMonthDay() throws Exception
-    {
-        Test FromMonthDay = new Test();
-        
-        FromMonthDay.initialize(TO_MONTH_DAY);
-        FromMonthDay.attemptConversion(TO_MONTH_DAY);
-        FromMonthDay.attemptConversion(TO_MONTH);
-        FromMonthDay.attemptConversion(TO_DAY);       
-    } 
-
-    public void testConversionsFromTime() throws Exception
-    {
-        Test FromTime = new Test();
-        
-        FromTime.initialize(TO_TIME);
-
-        FromTime.attemptConversion(TO_TIME);     
-    } 
-    
-    public void testConversionsFromYear() throws Exception
-    {
-        Test FromYear = new Test();
-
-        FromYear.initialize(TO_YEAR);
-
-        FromYear.attemptConversion(TO_YEAR);         
-    } 
- 
-    public void testConversionsFromYearMonth() throws Exception
-    {
-        Test FromYearMonth = new Test();
-        
-        FromYearMonth.initialize(TO_YEAR_MONTH);
-
-        FromYearMonth.attemptConversion(TO_YEAR_MONTH);
-        FromYearMonth.attemptConversion(TO_MONTH);
-        FromYearMonth.attemptConversion(TO_YEAR);       
-    } 
-    
-    public void testConversionsFromYearMonthDay() throws Exception
-    {
-        Test FromYearMonthDay = new Test();
-        
-        FromYearMonthDay.initialize(TO_YEAR_MONTH_DAY);
-
-        FromYearMonthDay.attemptConversion(TO_YEAR_MONTH_DAY);
-        FromYearMonthDay.attemptConversion(TO_YEAR_MONTH);
-        FromYearMonthDay.attemptConversion(TO_MONTH_DAY);
-        FromYearMonthDay.attemptConversion(TO_YEAR);        
-        FromYearMonthDay.attemptConversion(TO_MONTH);
-        FromYearMonthDay.attemptConversion(TO_DAY);      
-    } 
-    */
-
-    // Ensure that strings that should be recognized by toDate do not 
-    // result in a null Date value.
-    
-    public void testToDateFormats() throws Exception
-    {
-        String[] validStrings = 
-        {
-            "2006-03-31T03:30:45.123Z",
-            "-2006-03-31T03:30:45.1Z",
-            "2006-03-31T03:30:45Z",
-            "2006-03-31T03:30:45.123",
-            "2006-03-31T03:30:45.1",
-            "-2006-03-31T03:30:45",
-            "2006-03-31T03:30:45.123 EDT",
-            "2006-03-31T03:30:45.1 EDT",
-            "2006-03-31T03:30:45 EDT",
-            "---05 PST",
-            "---04",
-            "--12 GMT",
-            "--12",
-            "--08-08 EST",
-            "--08-08",
-            "1976-08-08 PDT",
-            "1976-08-08",
-            "88-12 CST",
-            "1988-12",
-            "2005 CDT",
-            "1999",
-            "P2006Y 08M 10D T 12H 24M 07S",
-            "P2006Y 10D T 12H",
-            "-P2006Y 08M 10D T 07S.2",
-            "P08M 10D T 07H",
-            "-P 04M 10DT12H 24S.88",
-            "PT12H"
-        };
-        
-        for (int i = 0; i < validStrings.length; i++)
-        {
-           assertNotNull("DataHelper.toData() should not return null for '" + validStrings[i] + "'.", 
-                   data_helper.toDate(validStrings[i]));
-        }
-
-    }
-    
-}
-
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.lang.reflect.Method;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import junit.framework.TestCase;
+
+import commonj.sdo.helper.DataHelper;
+
+// DateConversionTestCase insures that the DataHelper conversions accurately
+// retain the information in the specified fields (e.g. month, day or year).
+// It also provides coverage for the DataHelper API.
+// Note that toDate is called each time Test.initialize() is called.
+
+public class DateConversionTestCase extends TestCase
+{
+    private static Calendar test_calendar;
+    private static Date test_date;
+    private static DataHelper data_helper;
+    
+    private static final TestType TO_DATE_TIME = new TestType("toDateTime", new int [] {Calendar.YEAR, Calendar.MONTH, 
+            Calendar.DAY_OF_MONTH, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND});
+    private static final TestType TO_DURATION = new TestType("toDuration", new int [] {Calendar.YEAR, Calendar.MONTH, 
+            Calendar.DAY_OF_MONTH, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND});
+    private static final TestType TO_TIME = new TestType("toTime", new int [] {Calendar.HOUR_OF_DAY, Calendar.MINUTE, 
+            Calendar.SECOND, Calendar.MILLISECOND});
+    private static final TestType TO_DAY = new TestType("toDay", new int[] {Calendar.DAY_OF_MONTH});
+    private static final TestType TO_MONTH = new TestType("toMonth", new int[] {Calendar.MONTH});
+    private static final TestType TO_MONTH_DAY = new TestType("toMonthDay", new int[] {Calendar.MONTH, Calendar.DAY_OF_MONTH});
+    private static final TestType TO_YEAR = new TestType("toYear", new int[] {Calendar.YEAR});
+    private static final TestType TO_YEAR_MONTH= new TestType("toYearMonth",  new int[] {Calendar.YEAR, Calendar.MONTH});
+    private static final TestType TO_YEAR_MONTH_DAY = new TestType("toYearMonthDay",  new int[] {Calendar.YEAR, 
+            Calendar.MONTH, Calendar.DAY_OF_MONTH});    
+    
+    public DateConversionTestCase() throws Exception
+    {
+        data_helper = DataHelper.INSTANCE;
+        test_calendar = new GregorianCalendar();
+        test_calendar.setTime(new Date(System.currentTimeMillis()));
+        test_date = test_calendar.getTime();  
+    }
+    
+    private static class TestType
+    {
+        private static final Class[] DATE_CLASS_ARRAY = {Date.class};
+        private static final Class[] CALENDAR_CLASS_ARRAY = {Calendar.class};
+        
+        Method date_method;
+        Method calendar_method;
+        int [] compare_fields;  
+        
+        public TestType (String method_name, int [] compare_fields)
+        {
+            try
+            {
+                this.date_method = DataHelper.class.getMethod(method_name, DATE_CLASS_ARRAY);
+            }
+            catch (NoSuchMethodException e)
+            {
+                this.date_method = null;
+            }
+                
+            this.compare_fields = compare_fields;    
+            try
+            {
+                this.calendar_method = DataHelper.class.getMethod(method_name, CALENDAR_CLASS_ARRAY);
+            }
+            catch (NoSuchMethodException e)
+            {
+                this.calendar_method = null;
+            }
+
+        }
+        
+        public Method getDateMethod()
+        {
+            return this.date_method;
+        }
+        
+        public Method getCalendarMethod()
+        {
+            return this.calendar_method;
+        }
+    }
+    
+    private static class Test
+    {
+        String from_type;
+        Date from_date;    
+        Calendar from_calendar;
+        Class expected_exception;
+        
+        public Test ()
+        {
+            this.from_date = null;
+            this.from_calendar = null;
+            expected_exception = null;
+        }
+        
+        public void initialize (TestType from_type)
+        {            
+            this.from_type = from_type.getDateMethod().getName();
+            
+            try
+            {    
+                String date_string = (String) from_type.getDateMethod().invoke(data_helper, new Object[] {test_date});
+                this.from_date = data_helper.toDate(date_string);
+                date_string = (String) from_type.getCalendarMethod().invoke(data_helper, new Object[] {test_calendar});
+                this.from_calendar = data_helper.toCalendar(date_string);
+            }
+            catch (Exception e)
+            {
+                this.from_date = null;
+                this.from_calendar = null;
+            }
+            
+        }
+        
+        // This method is needed because there is not a toDate(Date) method in DataHelper.
+        
+        public void initializeToDate()
+        {
+            this.from_calendar = test_calendar;
+            this.from_date = test_date;
+            this.from_type = "toDate";
+        }
+        
+        public void attemptConversion (TestType to_type) throws Exception
+        {
+            executeConversion(to_type.getDateMethod(), new Object[] {this.from_date}, to_type.compare_fields);
+            executeConversion(to_type.getCalendarMethod(), new Object[] {this.from_calendar}, to_type.compare_fields);
+        }
+        
+        private void executeConversion (Method conversion, Object[] parm, int [] compare_fields) throws Exception
+        {
+            String result;
+            
+            try
+            {
+                result = (String) conversion.invoke(data_helper, parm);
+            }
+            catch (Exception e)
+            {
+                System.err.println("An unexpected exception was thrown while calling " + conversion.getName() + 
+                        " after initializing with " + this.from_type + ".");
+                throw e;
+            }
+
+             assertTrue("The expected value did not result when calling " + conversion.getName() + 
+                    " after initializing with " + this.from_type + ".", compareFields(parm[0], result, compare_fields));
+        }
+        
+        private boolean compareFields(Object compare_to, String output, int [] compare_fields)
+        {
+            Calendar result = data_helper.toCalendar(output);
+            Calendar expected;
+            
+            if (compare_to instanceof Calendar)
+                expected = (GregorianCalendar) test_calendar;
+            else
+            {
+                expected = new GregorianCalendar();
+                expected.setTime((Date) test_date);
+            }
+            
+            for (int i = 0; i < compare_fields.length; i++)
+            {
+                if (expected.get(compare_fields[i]) != result.get(compare_fields[i]))
+                   return false;
+            }
+            return true;
+        }
+        
+    }
+
+    /*
+    public void testConversionsFromDay() throws Exception
+    {
+        Test FromDay = new Test();
+        
+        FromDay.initialize(TO_DAY);
+        
+        FromDay.attemptConversion(TO_DAY);
+    }
+
+    public void testConversionsFromDate() throws Exception
+    {
+        Test FromDate = new Test();
+        
+        FromDate.initializeToDate();
+        
+        FromDate.attemptConversion(TO_DATE_TIME);
+        FromDate.attemptConversion(TO_DURATION);
+        FromDate.attemptConversion(TO_TIME);
+        FromDate.attemptConversion(TO_DAY);
+        FromDate.attemptConversion(TO_MONTH);
+        FromDate.attemptConversion(TO_MONTH_DAY);
+        FromDate.attemptConversion(TO_YEAR);
+        FromDate.attemptConversion(TO_YEAR_MONTH);
+        FromDate.attemptConversion(TO_YEAR_MONTH_DAY);           
+    }
+  
+    public void testConversionsFromDateTime() throws Exception
+    {
+        Test FromDateTime = new Test();
+        
+        FromDateTime.initialize(TO_DATE_TIME);
+
+        FromDateTime.attemptConversion(TO_DATE_TIME);
+        FromDateTime.attemptConversion(TO_DURATION);
+        FromDateTime.attemptConversion(TO_TIME);
+        FromDateTime.attemptConversion(TO_DAY);
+        FromDateTime.attemptConversion(TO_MONTH);
+        FromDateTime.attemptConversion(TO_MONTH_DAY);
+        FromDateTime.attemptConversion(TO_YEAR);
+        FromDateTime.attemptConversion(TO_YEAR_MONTH);
+        FromDateTime.attemptConversion(TO_YEAR_MONTH_DAY);            
+    }
+    
+    public void testConversionsFromDuration() throws Exception
+    {
+        Test FromDuration = new Test();
+        
+        FromDuration.initialize(TO_DURATION);
+
+        FromDuration.attemptConversion(TO_DURATION);
+        FromDuration.attemptConversion(TO_DATE_TIME);
+        FromDuration.attemptConversion(TO_TIME);
+        FromDuration.attemptConversion(TO_DAY);
+        FromDuration.attemptConversion(TO_MONTH);
+        FromDuration.attemptConversion(TO_MONTH_DAY);
+        FromDuration.attemptConversion(TO_YEAR);
+        FromDuration.attemptConversion(TO_YEAR_MONTH);
+        FromDuration.attemptConversion(TO_YEAR_MONTH_DAY);                   
+    }
+    
+    public void testConversionsFromMonth() throws Exception
+    {
+        Test FromMonth = new Test();
+        
+        FromMonth.initialize(TO_MONTH);
+
+        FromMonth.attemptConversion(TO_MONTH);           
+    } 
+    
+    public void testConversionsFromMonthDay() throws Exception
+    {
+        Test FromMonthDay = new Test();
+        
+        FromMonthDay.initialize(TO_MONTH_DAY);
+        FromMonthDay.attemptConversion(TO_MONTH_DAY);
+        FromMonthDay.attemptConversion(TO_MONTH);
+        FromMonthDay.attemptConversion(TO_DAY);       
+    } 
+
+    public void testConversionsFromTime() throws Exception
+    {
+        Test FromTime = new Test();
+        
+        FromTime.initialize(TO_TIME);
+
+        FromTime.attemptConversion(TO_TIME);     
+    } 
+    
+    public void testConversionsFromYear() throws Exception
+    {
+        Test FromYear = new Test();
+
+        FromYear.initialize(TO_YEAR);
+
+        FromYear.attemptConversion(TO_YEAR);         
+    } 
+ 
+    public void testConversionsFromYearMonth() throws Exception
+    {
+        Test FromYearMonth = new Test();
+        
+        FromYearMonth.initialize(TO_YEAR_MONTH);
+
+        FromYearMonth.attemptConversion(TO_YEAR_MONTH);
+        FromYearMonth.attemptConversion(TO_MONTH);
+        FromYearMonth.attemptConversion(TO_YEAR);       
+    } 
+    
+    public void testConversionsFromYearMonthDay() throws Exception
+    {
+        Test FromYearMonthDay = new Test();
+        
+        FromYearMonthDay.initialize(TO_YEAR_MONTH_DAY);
+
+        FromYearMonthDay.attemptConversion(TO_YEAR_MONTH_DAY);
+        FromYearMonthDay.attemptConversion(TO_YEAR_MONTH);
+        FromYearMonthDay.attemptConversion(TO_MONTH_DAY);
+        FromYearMonthDay.attemptConversion(TO_YEAR);        
+        FromYearMonthDay.attemptConversion(TO_MONTH);
+        FromYearMonthDay.attemptConversion(TO_DAY);      
+    } 
+    */
+
+    // Ensure that strings that should be recognized by toDate do not 
+    // result in a null Date value.
+    
+    public void testToDateFormats() throws Exception
+    {
+        String[] validStrings = 
+        {
+            "2006-03-31T03:30:45.123Z",
+            "-2006-03-31T03:30:45.1Z",
+            "2006-03-31T03:30:45Z",
+            "2006-03-31T03:30:45.123",
+            "2006-03-31T03:30:45.1",
+            "-2006-03-31T03:30:45",
+            "2006-03-31T03:30:45.123 EDT",
+            "2006-03-31T03:30:45.1 EDT",
+            "2006-03-31T03:30:45 EDT",
+            "---05 PST",
+            "---04",
+            "--12 GMT",
+            "--12",
+            "--08-08 EST",
+            "--08-08",
+            "1976-08-08 PDT",
+            "1976-08-08",
+            "88-12 CST",
+            "1988-12",
+            "2005 CDT",
+            "1999",
+            "P2006Y 08M 10D T 12H 24M 07S",
+            "P2006Y 10D T 12H",
+            "-P2006Y 08M 10D T 07S.2",
+            "P08M 10D T 07H",
+            "-P 04M 10DT12H 24S.88",
+            "PT12H"
+        };
+        
+        for (int i = 0; i < validStrings.length; i++)
+        {
+           assertNotNull("DataHelper.toData() should not return null for '" + validStrings[i] + "'.", 
+                   data_helper.toDate(validStrings[i]));
+        }
+
+    }
+    
+}
+

Propchange: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DateConversionTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DateConversionTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java?rev=437778&r1=437777&r2=437778&view=diff
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java (original)
+++ incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java Mon Aug 28 11:53:49 2006
@@ -1,632 +1,632 @@
-/**
- *
- *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.tuscany.sdo.test;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.math.BigDecimal;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sdo.util.SDOUtil;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.Property;
-import commonj.sdo.Sequence;
-import commonj.sdo.Type;
-import commonj.sdo.helper.DataFactory;
-import commonj.sdo.helper.TypeHelper;
-import commonj.sdo.helper.XMLDocument;
-import commonj.sdo.helper.XMLHelper;
-import commonj.sdo.helper.XSDHelper;
-
-public class DefineTypeTestCase extends TestCase 
-{
-  private static final String CUSTOMER1_XML = "/customer1.xml";
-  private static final String CUSTOMER2_XML = "/customer2.xml";
-  private static final String OPEN_XML = "/open2.xml";
-  private static final String MIXED_XML = "/mixed2.xml";
-  private static final String MIXEDOPEN_XML = "/mixedopen.xml";
-  
-  public void testDefineTypeRoundTrip() throws Exception {
-    TypeHelper types = SDOUtil.createTypeHelper();
-    DataFactory factory = SDOUtil.createDataFactory(types);
-    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
-
-    Type intType = types.getType("commonj.sdo", "Int");
-    Type stringType = types.getType("commonj.sdo", "String");
-    
-    // create a new Type for Customers
-    DataObject customerType = factory.create("commonj.sdo",
-    "Type");
-    customerType.set("uri", "http://example.com/customer");
-    customerType.set("name", "Customer");
-    
-    // create a customer number property
-    DataObject custNumProperty = customerType.createDataObject("property");
-    custNumProperty.set("name", "custNum");
-    custNumProperty.set("type", intType);
-     
-    // create a first name property
-    DataObject firstNameProperty =
-    customerType.createDataObject("property");
-    firstNameProperty.set("name", "firstName");
-    firstNameProperty.set("type", stringType);
-
-    // create a last name property
-    DataObject lastNameProperty = customerType.createDataObject("property");
-    lastNameProperty.set("name", "lastName");
-    lastNameProperty.set("type", stringType);
-
-    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    xmlHelper.save(customerType, "commonj.sdo", "type", baos);
-    
-    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-    XMLDocument xdoc = xmlHelper.load(bais);
-
-    customerType = xdoc.getRootObject();
-    
-    // now define the Customer type so that customers can be made
-    types.define(customerType);
-    
-    DataObject customer1 = factory.create("http://example.com/customer",
-    "Customer");
-    
-    customer1.setInt("custNum", 1);
-    customer1.set("firstName", "John");
-    customer1.set("lastName", "Adams");
-    DataObject customer2 = factory.create("http://example.com/customer",
-    "Customer");    
-    customer2.setInt("custNum", 2);
-    customer2.set("firstName", "Jeremy");
-    customer2.set("lastName", "Pavick");
-    
-    assertNotNull(customer1);
-    Type type = customer1.getType();
-    assertNotNull(type.getProperty("custNum"));
-    assertNotNull(type.getProperty("firstName"));
-    assertNotNull(type.getProperty("lastName"));
-    assertEquals(type.getProperty("custNum").getType(), intType);
-    assertEquals(type.getProperty("firstName").getType(), stringType);
-    assertEquals(type.getProperty("lastName").getType(), stringType);
-    
-    assertNotNull(customer2);
-    type = customer2.getType();
-    assertNotNull(type.getProperty("custNum"));
-    assertNotNull(type.getProperty("firstName"));
-    assertNotNull(type.getProperty("lastName"));
-    assertEquals(type.getProperty("custNum").getType(), intType);
-    assertEquals(type.getProperty("firstName").getType(), stringType);
-    assertEquals(type.getProperty("lastName").getType(), stringType);
-    
-    baos = new ByteArrayOutputStream();
-    xmlHelper.save(
-      customer1, 
-      "http://example.com/customer",
-      "Customer", baos);
-    assertTrue(
-      TestUtil.equalXmlFiles(
-        new ByteArrayInputStream(baos.toByteArray()), 
-        getClass().getResource(CUSTOMER1_XML)));
-    
-    baos = new ByteArrayOutputStream();
-    xmlHelper.save(
-      customer2, 
-      "http://example.com/customer",
-      "Customer", baos);
-    assertTrue(
-        TestUtil.equalXmlFiles(
-          new ByteArrayInputStream(baos.toByteArray()), 
-          getClass().getResource(CUSTOMER2_XML)));
-  }
-  
-  public void testDefineType() throws Exception 
-  {
-    TypeHelper types = SDOUtil.createTypeHelper();
-    DataFactory factory = SDOUtil.createDataFactory(types);
-    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
-
-    Type intType = types.getType("commonj.sdo", "Int");
-    Type stringType = types.getType("commonj.sdo", "String");
-    
-    // create a new Type for Customers
-    DataObject customerType = factory.create("commonj.sdo",
-    "Type");
-    customerType.set("uri", "http://example.com/customer");
-    customerType.set("name", "Customer");
-
-    // create a customer number property
-    DataObject custNumProperty = customerType.createDataObject("property");
-    custNumProperty.set("name", "custNum");
-    custNumProperty.set("type", intType);
-
-    // create a first name property
-    DataObject firstNameProperty =
-    customerType.createDataObject("property");
-    firstNameProperty.set("name", "firstName");
-    firstNameProperty.set("type", stringType);
-
-    // create a last name property
-    DataObject lastNameProperty = customerType.createDataObject("property");
-    lastNameProperty.set("name", "lastName");
-    lastNameProperty.set("type", stringType);
-
-    // now define the Customer type so that customers can be made
-    types.define(customerType);
-    
-    DataObject customer1 = factory.create("http://example.com/customer",
-    "Customer");
-    customer1.setInt("custNum", 1);
-    customer1.set("firstName", "John");
-    customer1.set("lastName", "Adams");
-    DataObject customer2 = factory.create("http://example.com/customer",
-    "Customer");    
-    customer2.setInt("custNum", 2);
-    customer2.set("firstName", "Jeremy");
-    customer2.set("lastName", "Pavick");
-
-    assertNotNull(customer1);
-    Type type = customer1.getType();
-    assertNotNull(type.getProperty("custNum"));
-    assertNotNull(type.getProperty("firstName"));
-    assertNotNull(type.getProperty("lastName"));
-    assertEquals(type.getProperty("custNum").getType(), intType);
-    assertEquals(type.getProperty("firstName").getType(), stringType);
-    assertEquals(type.getProperty("lastName").getType(), stringType);
-    
-    assertNotNull(customer2);
-    type = customer2.getType();
-    assertNotNull(type.getProperty("custNum"));
-    assertNotNull(type.getProperty("firstName"));
-    assertNotNull(type.getProperty("lastName"));
-    assertEquals(type.getProperty("custNum").getType(), intType);
-    assertEquals(type.getProperty("firstName").getType(), stringType);
-    assertEquals(type.getProperty("lastName").getType(), stringType);
-    
-    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    xmlHelper.save(
-      customer1, 
-      "http://example.com/customer",
-      "Customer", baos);
-    assertTrue(
-      TestUtil.equalXmlFiles(
-        new ByteArrayInputStream(baos.toByteArray()), 
-        getClass().getResource(CUSTOMER1_XML)));
-    
-    baos = new ByteArrayOutputStream();
-    xmlHelper.save(
-      customer2, 
-      "http://example.com/customer",
-      "Customer", baos);
-    assertTrue(
-        TestUtil.equalXmlFiles(
-          new ByteArrayInputStream(baos.toByteArray()), 
-          getClass().getResource(CUSTOMER2_XML)));
-  }
-  
-  public void testDefineDataType() throws Exception 
-  {
-    TypeHelper types = SDOUtil.createTypeHelper();
-    DataFactory factory = SDOUtil.createDataFactory(types);
-    XSDHelper xsdHelper = SDOUtil.createXSDHelper(types);
-    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
-
-    Property javaClassProperty = xsdHelper.getGlobalProperty("commonj.sdo/java", "javaClass", false);
-    
-    // create a data types
-    DataObject intType = factory.create("commonj.sdo", "Type");
-    intType.set("uri", "http://example.com/customer");
-    intType.set("name", "MyIntType");
-    intType.setBoolean("dataType", true);
-    intType.set(javaClassProperty, "int");
-    
-    DataObject stringType = factory.create("commonj.sdo", "Type");
-    stringType.set("uri", "http://example.com/customer");
-    stringType.set("name", "MyStringType");
-    stringType.setBoolean("dataType", true);
-    stringType.set(javaClassProperty, "java.lang.String");
-    
-    // create a new Type for Customers
-    DataObject customerType = factory.create("commonj.sdo",
-    "Type");
-    customerType.set("uri", "http://example.com/customer");
-    customerType.set("name", "Customer");
-    
-    // create a customer number property
-    DataObject custNumProperty = customerType.createDataObject("property");
-    custNumProperty.set("name", "custNum");
-    custNumProperty.set("type", intType);
-
-    // create a first name property
-    DataObject firstNameProperty =
-    customerType.createDataObject("property");
-    firstNameProperty.set("name", "firstName");
-    firstNameProperty.set("type", stringType);
-
-    // create a last name property
-    DataObject lastNameProperty = customerType.createDataObject("property");
-    lastNameProperty.set("name", "lastName");
-    lastNameProperty.set("type", stringType);
-
-    // now define the Customer type so that customers can be made
-    types.define(customerType);
-    
-    DataObject customer1 = factory.create("http://example.com/customer",
-    "Customer");
-    
-    customer1.setInt("custNum", 1);
-    customer1.set("firstName", "John");
-    customer1.set("lastName", "Adams");
-    DataObject customer2 = factory.create("http://example.com/customer",
-    "Customer");
-    customer2.setInt("custNum", 2);
-    customer2.set("firstName", "Jeremy");
-    customer2.set("lastName", "Pavick");
-    
-    assertNotNull(customer1);
-    Type type = customer1.getType();
-    assertNotNull(type.getProperty("custNum"));
-    assertNotNull(type.getProperty("firstName"));
-    assertNotNull(type.getProperty("lastName"));
-    assertNotNull(type.getProperty("custNum"));
-    assertNotNull(type.getProperty("firstName"));
-    assertNotNull(type.getProperty("lastName"));
-    
-    type = type.getProperty("custNum").getType();
-    assertEquals(type.getURI(), "http://example.com/customer");
-    assertEquals(type.getName(), "MyIntType");
-    assertTrue(type.isDataType());
-    
-    assertNotNull(customer2);
-    type = customer2.getType();
-    assertNotNull(type.getProperty("custNum"));
-    assertNotNull(type.getProperty("firstName"));
-    assertNotNull(type.getProperty("lastName"));
-    assertNotNull(type.getProperty("custNum"));
-    assertNotNull(type.getProperty("firstName"));
-    assertNotNull(type.getProperty("lastName"));
-    
-    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    xmlHelper.save(
-      customer1, 
-      "http://example.com/customer",
-      "Customer", baos);
-    assertTrue(
-      TestUtil.equalXmlFiles(
-        new ByteArrayInputStream(baos.toByteArray()), 
-        getClass().getResource(CUSTOMER1_XML)));
-    
-    baos = new ByteArrayOutputStream();
-    xmlHelper.save(
-      customer2, 
-      "http://example.com/customer",
-      "Customer", baos);
-    assertTrue(
-        TestUtil.equalXmlFiles(
-          new ByteArrayInputStream(baos.toByteArray()), 
-          getClass().getResource(CUSTOMER2_XML)));
-  }
-  
-  public void testFastDefineType() throws Exception 
-  {
-    TypeHelper types = SDOUtil.createTypeHelper();
-    DataFactory factory = SDOUtil.createDataFactory(types);
-    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
-
-    Type intType = types.getType("commonj.sdo", "Int");
-    Type stringType = types.getType("commonj.sdo", "String");
-    
-    // create a new Type for Customers
-    Type customerType = SDOUtil.createType(types, "http://example.com/customer", "Customer", false);
-
-    // create a customer number property
-    SDOUtil.createProperty(customerType, "custNum", intType);
-
-    // create a first name property
-    SDOUtil.createProperty(customerType, "firstName", stringType);
-
-    // create a last name property
-    SDOUtil.createProperty(customerType, "lastName", stringType);
-
-    DataObject customer1 = factory.create("http://example.com/customer",
-    "Customer");
-    customer1.setInt("custNum", 1);
-    customer1.set("firstName", "John");
-    customer1.set("lastName", "Adams");
-    DataObject customer2 = factory.create("http://example.com/customer",
-    "Customer");
-    customer2.setInt("custNum", 2);
-    customer2.set("firstName", "Jeremy");
-    customer2.set("lastName", "Pavick");
-    
-    assertNotNull(customer1);
-    Type type = customer1.getType();
-    assertNotNull(type.getProperty("custNum"));
-    assertNotNull(type.getProperty("firstName"));
-    assertNotNull(type.getProperty("lastName"));
-    assertEquals(type.getProperty("custNum").getType(), intType);
-    assertEquals(type.getProperty("firstName").getType(), stringType);
-    assertEquals(type.getProperty("lastName").getType(), stringType);
-    
-    assertNotNull(customer2);
-    type = customer2.getType();
-    assertNotNull(type.getProperty("custNum"));
-    assertNotNull(type.getProperty("firstName"));
-    assertNotNull(type.getProperty("lastName"));
-    assertEquals(type.getProperty("custNum").getType(), intType);
-    assertEquals(type.getProperty("firstName").getType(), stringType);
-    assertEquals(type.getProperty("lastName").getType(), stringType);  
-    
-    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    xmlHelper.save(
-      customer1, 
-      "http://example.com/customer",
-      "Customer", baos);
-    assertTrue(
-      TestUtil.equalXmlFiles(
-        new ByteArrayInputStream(baos.toByteArray()), 
-        getClass().getResource(CUSTOMER1_XML)));
-    
-    baos = new ByteArrayOutputStream();
-    xmlHelper.save(
-      customer2, 
-      "http://example.com/customer",
-      "Customer", baos);
-    assertTrue(
-        TestUtil.equalXmlFiles(
-          new ByteArrayInputStream(baos.toByteArray()), 
-          getClass().getResource(CUSTOMER2_XML)));
-  }
-  
-  public void testDefineSequencedType() throws Exception 
-  {
-    
-    TypeHelper types = SDOUtil.createTypeHelper();
-    DataFactory factory = SDOUtil.createDataFactory(types);
-    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
-    
-    Type stringType = types.getType("commonj.sdo", "String");
-    Type decimalType = types.getType("commonj.sdo", "Decimal");
-    
-    // Define a new mixed type - MixedQuote
-    DataObject mixedQuoteType = factory.create("commonj.sdo", "Type");
-    mixedQuoteType.set("uri", "http://www.example.com/mixed");
-    mixedQuoteType.set("name", "MixedQuote");
-    mixedQuoteType.set("sequenced", Boolean.TRUE);
-    
-    DataObject symbolProperty = mixedQuoteType.createDataObject("property");
-    symbolProperty.set("name", "symbol");
-    symbolProperty.set("type", stringType);
-    
-    DataObject companyNameProperty = mixedQuoteType.createDataObject("property");
-    companyNameProperty.set("name", "companyName");
-    companyNameProperty.set("type", stringType);
-    
-    DataObject priceProperty = mixedQuoteType.createDataObject("property");
-    priceProperty.set("name", "price");
-    priceProperty.set("type", decimalType);
-    
-    DataObject quotesProperty = mixedQuoteType.createDataObject("property");
-    quotesProperty.set("name", "quotes");
-    quotesProperty.set("type", mixedQuoteType);
-    quotesProperty.set("many", Boolean.TRUE);
-    quotesProperty.set("containment", Boolean.TRUE);
-    
-    types.define(mixedQuoteType);
-    
-    DataObject quote = factory.create("http://www.example.com/mixed", "MixedQuote");
-
-    assertTrue(quote.getType().isSequenced());
-    
-    Sequence sequence = quote.getSequence();
-
-    sequence.add("\n  ");
-
-    quote.setString("symbol", "fbnt");
-
-    sequence.add("\n  ");
-
-    quote.setString("companyName", "FlyByNightTechnology");
-
-    sequence.add("\n  some text\n  ");
-
-    DataObject child = quote.createDataObject("quotes");
-    child.setBigDecimal("price", new BigDecimal("2000.0"));
-
-    sequence.add("\n  more text\n  ");
-
-    // quote.setBigDecimal("price", new BigDecimal("1000.0"));
-    sequence.add("price", new BigDecimal("1000.0"));
-
-    sequence.add("\n");
-
-    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    xmlHelper.save(quote, "http://www.example.com/mixed", "mixedStockQuote", baos);
-    assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(MIXED_XML)));
-  }
-  
-  public void testDefineSequencedOpenType() throws Exception 
-  {
-    
-    TypeHelper types = SDOUtil.createTypeHelper();
-    DataFactory factory = SDOUtil.createDataFactory(types);
-    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
-    
-    Type stringType = types.getType("commonj.sdo", "String");
-    Type decimalType = types.getType("commonj.sdo", "Decimal");
-    
-    // Define a new mixed type - MixedQuote
-    DataObject mixedQuoteType = factory.create("commonj.sdo", "Type");
-    mixedQuoteType.set("uri", "http://www.example.com/mixed");
-    mixedQuoteType.set("name", "MixedOpenQuote");
-    mixedQuoteType.set("sequenced", Boolean.TRUE);
-    mixedQuoteType.set("open", Boolean.TRUE);
-    
-//    DataObject symbolProperty = mixedQuoteType.createDataObject("property");
-//    symbolProperty.set("name", "symbol");
-//    symbolProperty.set("type", stringType);
-    
-    DataObject companyNameProperty = mixedQuoteType.createDataObject("property");
-    companyNameProperty.set("name", "companyName");
-    companyNameProperty.set("type", stringType);
-    
-    DataObject priceProperty = mixedQuoteType.createDataObject("property");
-    priceProperty.set("name", "price");
-    priceProperty.set("type", decimalType);
-    
-    DataObject quotesProperty = mixedQuoteType.createDataObject("property");
-    quotesProperty.set("name", "quotes");
-    quotesProperty.set("type", mixedQuoteType);
-    quotesProperty.set("many", Boolean.TRUE);
-    quotesProperty.set("containment", Boolean.TRUE);
-    
-    types.define(mixedQuoteType);
-    
-    // Define a global type
-    DataObject globalType = factory.create("commonj.sdo", "Type");
-    globalType.set("uri", "http://www.example.com/open");
-    // Don't set the type's name - null is used for types containing global properties.
-    
-    DataObject symbolProperty = globalType.createDataObject("property");
-    symbolProperty.set("name", "symbol");
-    symbolProperty.set("type", stringType);
-    symbolProperty.set("containment", Boolean.TRUE);
-    
-    types.define(globalType);
-    
-    DataObject quote = factory.create("http://www.example.com/mixed", "MixedOpenQuote");
-
-    assertTrue(quote.getType().isSequenced());
-    
-    Sequence sequence = quote.getSequence();
-
-    sequence.add("\n  ");
-
-    Type definedGlobalType = types.getType("http://www.example.com/open", null);
-    
-    Property definedSymbolProperty = definedGlobalType.getProperty("symbol");
-    quote.setString(definedSymbolProperty, "fbnt");
-
-    sequence.add("\n  ");
-
-    quote.setString("companyName", "FlyByNightTechnology");
-
-    sequence.add("\n  some text\n  ");
-
-    DataObject child = quote.createDataObject("quotes");
-    child.setBigDecimal("price", new BigDecimal("2000.0"));
-
-    sequence.add("\n  more text\n  ");
-
-    // quote.setBigDecimal("price", new BigDecimal("1000.0"));
-    sequence.add("price", new BigDecimal("1000.0"));
-
-    sequence.add("\n");
-
-    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    xmlHelper.save(quote, "http://www.example.com/mixed", "mixedOpenStockQuote", baos);
-    assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(MIXEDOPEN_XML)));
-  }
-
-  
-  public void testDefineOpenType() throws Exception 
-  {
-    TypeHelper types = SDOUtil.createTypeHelper();
-    DataFactory factory = SDOUtil.createDataFactory(types);
-    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
-    
-    Type stringType = types.getType("commonj.sdo", "String");
-    Type decimalType = types.getType("commonj.sdo", "Decimal");
-    
-    // Define a new open type - OpenQuote
-    DataObject openQuoteType = factory.create("commonj.sdo", "Type");
-    openQuoteType.set("uri", "http://www.example.com/open");
-    openQuoteType.set("name", "OpenQuote");
-    openQuoteType.set("open", Boolean.TRUE);
-    openQuoteType.setBoolean("open", true);
-    
-    types.define(openQuoteType);
-    
-    // Define new type - CompanyType
-    DataObject companyType = factory.create("commonj.sdo", "Type");
-    companyType.set("uri", "http://www.example.com/open");
-    companyType.set("name", "CompanyType");
-    
-    // Create CompanyType property - "name"
-    DataObject nameProperty = companyType.createDataObject("property");
-    nameProperty.set("name", "name");
-    nameProperty.set("type", stringType);
-    nameProperty.set("containment", Boolean.TRUE);
-    
-    types.define(companyType);
-    
-    // Define a global type
-    DataObject globalType = factory.create("commonj.sdo", "Type");
-    globalType.set("uri", "http://www.example.com/open");
-    // Don't set the type's name - null is used for types containing global properties.
-    
-    DataObject symbolProperty = globalType.createDataObject("property");
-    symbolProperty.set("name", "symbol");
-    symbolProperty.set("type", stringType);
-    symbolProperty.set("containment", Boolean.TRUE);
-    
-    // Define a global property - company
-    DataObject companyProperty = globalType.createDataObject("property");
-    companyProperty.set("name", "company");
-    companyProperty.set("type", companyType);
-    companyProperty.set("containment", Boolean.TRUE);
-    
-    // Define a global property - price
-    DataObject priceProperty = globalType.createDataObject("property");
-    priceProperty.set("name", "price");
-    priceProperty.set("type", decimalType);
-    
-    types.define(globalType);
-    
-    // Create DataObject instances
-    DataObject openQuote = factory.create("http://www.example.com/open", "OpenQuote");
-    
-    assertTrue(openQuote.getType().isOpen());
-    
-    // Get global type
-    Type definedGlobalType = types.getType("http://www.example.com/open", null);
-    
-    Property definedSymbolProperty = definedGlobalType.getProperty("symbol");
-    openQuote.set(definedSymbolProperty, "s1");
-    
-    Property definedCompanyProperty = definedGlobalType.getProperty("company");
-    
-    DataObject company = openQuote.createDataObject(definedCompanyProperty);
-    company.setString("name", "FlyByNightTechnology");
-      
-    Property definedPriceProperty = definedGlobalType.getProperty("price");
-    openQuote.setBigDecimal(definedPriceProperty, new BigDecimal("1000.0"));
-    
-    assertEquals(definedPriceProperty.getType(), decimalType);
-    
-    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    xmlHelper.save(
-      openQuote, 
-      "http://www.example.com/open",
-      "openStockQuote", baos);
-    assertTrue(
-      TestUtil.equalXmlFiles(
-        new ByteArrayInputStream(baos.toByteArray()), 
-        getClass().getResource(OPEN_XML)));
-  }
-  
-}
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.math.BigDecimal;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+
+public class DefineTypeTestCase extends TestCase 
+{
+  private static final String CUSTOMER1_XML = "/customer1.xml";
+  private static final String CUSTOMER2_XML = "/customer2.xml";
+  private static final String OPEN_XML = "/open2.xml";
+  private static final String MIXED_XML = "/mixed2.xml";
+  private static final String MIXEDOPEN_XML = "/mixedopen.xml";
+  
+  public void testDefineTypeRoundTrip() throws Exception {
+    TypeHelper types = SDOUtil.createTypeHelper();
+    DataFactory factory = SDOUtil.createDataFactory(types);
+    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
+
+    Type intType = types.getType("commonj.sdo", "Int");
+    Type stringType = types.getType("commonj.sdo", "String");
+    
+    // create a new Type for Customers
+    DataObject customerType = factory.create("commonj.sdo",
+    "Type");
+    customerType.set("uri", "http://example.com/customer");
+    customerType.set("name", "Customer");
+    
+    // create a customer number property
+    DataObject custNumProperty = customerType.createDataObject("property");
+    custNumProperty.set("name", "custNum");
+    custNumProperty.set("type", intType);
+     
+    // create a first name property
+    DataObject firstNameProperty =
+    customerType.createDataObject("property");
+    firstNameProperty.set("name", "firstName");
+    firstNameProperty.set("type", stringType);
+
+    // create a last name property
+    DataObject lastNameProperty = customerType.createDataObject("property");
+    lastNameProperty.set("name", "lastName");
+    lastNameProperty.set("type", stringType);
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    xmlHelper.save(customerType, "commonj.sdo", "type", baos);
+    
+    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+    XMLDocument xdoc = xmlHelper.load(bais);
+
+    customerType = xdoc.getRootObject();
+    
+    // now define the Customer type so that customers can be made
+    types.define(customerType);
+    
+    DataObject customer1 = factory.create("http://example.com/customer",
+    "Customer");
+    
+    customer1.setInt("custNum", 1);
+    customer1.set("firstName", "John");
+    customer1.set("lastName", "Adams");
+    DataObject customer2 = factory.create("http://example.com/customer",
+    "Customer");    
+    customer2.setInt("custNum", 2);
+    customer2.set("firstName", "Jeremy");
+    customer2.set("lastName", "Pavick");
+    
+    assertNotNull(customer1);
+    Type type = customer1.getType();
+    assertNotNull(type.getProperty("custNum"));
+    assertNotNull(type.getProperty("firstName"));
+    assertNotNull(type.getProperty("lastName"));
+    assertEquals(type.getProperty("custNum").getType(), intType);
+    assertEquals(type.getProperty("firstName").getType(), stringType);
+    assertEquals(type.getProperty("lastName").getType(), stringType);
+    
+    assertNotNull(customer2);
+    type = customer2.getType();
+    assertNotNull(type.getProperty("custNum"));
+    assertNotNull(type.getProperty("firstName"));
+    assertNotNull(type.getProperty("lastName"));
+    assertEquals(type.getProperty("custNum").getType(), intType);
+    assertEquals(type.getProperty("firstName").getType(), stringType);
+    assertEquals(type.getProperty("lastName").getType(), stringType);
+    
+    baos = new ByteArrayOutputStream();
+    xmlHelper.save(
+      customer1, 
+      "http://example.com/customer",
+      "Customer", baos);
+    assertTrue(
+      TestUtil.equalXmlFiles(
+        new ByteArrayInputStream(baos.toByteArray()), 
+        getClass().getResource(CUSTOMER1_XML)));
+    
+    baos = new ByteArrayOutputStream();
+    xmlHelper.save(
+      customer2, 
+      "http://example.com/customer",
+      "Customer", baos);
+    assertTrue(
+        TestUtil.equalXmlFiles(
+          new ByteArrayInputStream(baos.toByteArray()), 
+          getClass().getResource(CUSTOMER2_XML)));
+  }
+  
+  public void testDefineType() throws Exception 
+  {
+    TypeHelper types = SDOUtil.createTypeHelper();
+    DataFactory factory = SDOUtil.createDataFactory(types);
+    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
+
+    Type intType = types.getType("commonj.sdo", "Int");
+    Type stringType = types.getType("commonj.sdo", "String");
+    
+    // create a new Type for Customers
+    DataObject customerType = factory.create("commonj.sdo",
+    "Type");
+    customerType.set("uri", "http://example.com/customer");
+    customerType.set("name", "Customer");
+
+    // create a customer number property
+    DataObject custNumProperty = customerType.createDataObject("property");
+    custNumProperty.set("name", "custNum");
+    custNumProperty.set("type", intType);
+
+    // create a first name property
+    DataObject firstNameProperty =
+    customerType.createDataObject("property");
+    firstNameProperty.set("name", "firstName");
+    firstNameProperty.set("type", stringType);
+
+    // create a last name property
+    DataObject lastNameProperty = customerType.createDataObject("property");
+    lastNameProperty.set("name", "lastName");
+    lastNameProperty.set("type", stringType);
+
+    // now define the Customer type so that customers can be made
+    types.define(customerType);
+    
+    DataObject customer1 = factory.create("http://example.com/customer",
+    "Customer");
+    customer1.setInt("custNum", 1);
+    customer1.set("firstName", "John");
+    customer1.set("lastName", "Adams");
+    DataObject customer2 = factory.create("http://example.com/customer",
+    "Customer");    
+    customer2.setInt("custNum", 2);
+    customer2.set("firstName", "Jeremy");
+    customer2.set("lastName", "Pavick");
+
+    assertNotNull(customer1);
+    Type type = customer1.getType();
+    assertNotNull(type.getProperty("custNum"));
+    assertNotNull(type.getProperty("firstName"));
+    assertNotNull(type.getProperty("lastName"));
+    assertEquals(type.getProperty("custNum").getType(), intType);
+    assertEquals(type.getProperty("firstName").getType(), stringType);
+    assertEquals(type.getProperty("lastName").getType(), stringType);
+    
+    assertNotNull(customer2);
+    type = customer2.getType();
+    assertNotNull(type.getProperty("custNum"));
+    assertNotNull(type.getProperty("firstName"));
+    assertNotNull(type.getProperty("lastName"));
+    assertEquals(type.getProperty("custNum").getType(), intType);
+    assertEquals(type.getProperty("firstName").getType(), stringType);
+    assertEquals(type.getProperty("lastName").getType(), stringType);
+    
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    xmlHelper.save(
+      customer1, 
+      "http://example.com/customer",
+      "Customer", baos);
+    assertTrue(
+      TestUtil.equalXmlFiles(
+        new ByteArrayInputStream(baos.toByteArray()), 
+        getClass().getResource(CUSTOMER1_XML)));
+    
+    baos = new ByteArrayOutputStream();
+    xmlHelper.save(
+      customer2, 
+      "http://example.com/customer",
+      "Customer", baos);
+    assertTrue(
+        TestUtil.equalXmlFiles(
+          new ByteArrayInputStream(baos.toByteArray()), 
+          getClass().getResource(CUSTOMER2_XML)));
+  }
+  
+  public void testDefineDataType() throws Exception 
+  {
+    TypeHelper types = SDOUtil.createTypeHelper();
+    DataFactory factory = SDOUtil.createDataFactory(types);
+    XSDHelper xsdHelper = SDOUtil.createXSDHelper(types);
+    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
+
+    Property javaClassProperty = xsdHelper.getGlobalProperty("commonj.sdo/java", "javaClass", false);
+    
+    // create a data types
+    DataObject intType = factory.create("commonj.sdo", "Type");
+    intType.set("uri", "http://example.com/customer");
+    intType.set("name", "MyIntType");
+    intType.setBoolean("dataType", true);
+    intType.set(javaClassProperty, "int");
+    
+    DataObject stringType = factory.create("commonj.sdo", "Type");
+    stringType.set("uri", "http://example.com/customer");
+    stringType.set("name", "MyStringType");
+    stringType.setBoolean("dataType", true);
+    stringType.set(javaClassProperty, "java.lang.String");
+    
+    // create a new Type for Customers
+    DataObject customerType = factory.create("commonj.sdo",
+    "Type");
+    customerType.set("uri", "http://example.com/customer");
+    customerType.set("name", "Customer");
+    
+    // create a customer number property
+    DataObject custNumProperty = customerType.createDataObject("property");
+    custNumProperty.set("name", "custNum");
+    custNumProperty.set("type", intType);
+
+    // create a first name property
+    DataObject firstNameProperty =
+    customerType.createDataObject("property");
+    firstNameProperty.set("name", "firstName");
+    firstNameProperty.set("type", stringType);
+
+    // create a last name property
+    DataObject lastNameProperty = customerType.createDataObject("property");
+    lastNameProperty.set("name", "lastName");
+    lastNameProperty.set("type", stringType);
+
+    // now define the Customer type so that customers can be made
+    types.define(customerType);
+    
+    DataObject customer1 = factory.create("http://example.com/customer",
+    "Customer");
+    
+    customer1.setInt("custNum", 1);
+    customer1.set("firstName", "John");
+    customer1.set("lastName", "Adams");
+    DataObject customer2 = factory.create("http://example.com/customer",
+    "Customer");
+    customer2.setInt("custNum", 2);
+    customer2.set("firstName", "Jeremy");
+    customer2.set("lastName", "Pavick");
+    
+    assertNotNull(customer1);
+    Type type = customer1.getType();
+    assertNotNull(type.getProperty("custNum"));
+    assertNotNull(type.getProperty("firstName"));
+    assertNotNull(type.getProperty("lastName"));
+    assertNotNull(type.getProperty("custNum"));
+    assertNotNull(type.getProperty("firstName"));
+    assertNotNull(type.getProperty("lastName"));
+    
+    type = type.getProperty("custNum").getType();
+    assertEquals(type.getURI(), "http://example.com/customer");
+    assertEquals(type.getName(), "MyIntType");
+    assertTrue(type.isDataType());
+    
+    assertNotNull(customer2);
+    type = customer2.getType();
+    assertNotNull(type.getProperty("custNum"));
+    assertNotNull(type.getProperty("firstName"));
+    assertNotNull(type.getProperty("lastName"));
+    assertNotNull(type.getProperty("custNum"));
+    assertNotNull(type.getProperty("firstName"));
+    assertNotNull(type.getProperty("lastName"));
+    
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    xmlHelper.save(
+      customer1, 
+      "http://example.com/customer",
+      "Customer", baos);
+    assertTrue(
+      TestUtil.equalXmlFiles(
+        new ByteArrayInputStream(baos.toByteArray()), 
+        getClass().getResource(CUSTOMER1_XML)));
+    
+    baos = new ByteArrayOutputStream();
+    xmlHelper.save(
+      customer2, 
+      "http://example.com/customer",
+      "Customer", baos);
+    assertTrue(
+        TestUtil.equalXmlFiles(
+          new ByteArrayInputStream(baos.toByteArray()), 
+          getClass().getResource(CUSTOMER2_XML)));
+  }
+  
+  public void testFastDefineType() throws Exception 
+  {
+    TypeHelper types = SDOUtil.createTypeHelper();
+    DataFactory factory = SDOUtil.createDataFactory(types);
+    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
+
+    Type intType = types.getType("commonj.sdo", "Int");
+    Type stringType = types.getType("commonj.sdo", "String");
+    
+    // create a new Type for Customers
+    Type customerType = SDOUtil.createType(types, "http://example.com/customer", "Customer", false);
+
+    // create a customer number property
+    SDOUtil.createProperty(customerType, "custNum", intType);
+
+    // create a first name property
+    SDOUtil.createProperty(customerType, "firstName", stringType);
+
+    // create a last name property
+    SDOUtil.createProperty(customerType, "lastName", stringType);
+
+    DataObject customer1 = factory.create("http://example.com/customer",
+    "Customer");
+    customer1.setInt("custNum", 1);
+    customer1.set("firstName", "John");
+    customer1.set("lastName", "Adams");
+    DataObject customer2 = factory.create("http://example.com/customer",
+    "Customer");
+    customer2.setInt("custNum", 2);
+    customer2.set("firstName", "Jeremy");
+    customer2.set("lastName", "Pavick");
+    
+    assertNotNull(customer1);
+    Type type = customer1.getType();
+    assertNotNull(type.getProperty("custNum"));
+    assertNotNull(type.getProperty("firstName"));
+    assertNotNull(type.getProperty("lastName"));
+    assertEquals(type.getProperty("custNum").getType(), intType);
+    assertEquals(type.getProperty("firstName").getType(), stringType);
+    assertEquals(type.getProperty("lastName").getType(), stringType);
+    
+    assertNotNull(customer2);
+    type = customer2.getType();
+    assertNotNull(type.getProperty("custNum"));
+    assertNotNull(type.getProperty("firstName"));
+    assertNotNull(type.getProperty("lastName"));
+    assertEquals(type.getProperty("custNum").getType(), intType);
+    assertEquals(type.getProperty("firstName").getType(), stringType);
+    assertEquals(type.getProperty("lastName").getType(), stringType);  
+    
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    xmlHelper.save(
+      customer1, 
+      "http://example.com/customer",
+      "Customer", baos);
+    assertTrue(
+      TestUtil.equalXmlFiles(
+        new ByteArrayInputStream(baos.toByteArray()), 
+        getClass().getResource(CUSTOMER1_XML)));
+    
+    baos = new ByteArrayOutputStream();
+    xmlHelper.save(
+      customer2, 
+      "http://example.com/customer",
+      "Customer", baos);
+    assertTrue(
+        TestUtil.equalXmlFiles(
+          new ByteArrayInputStream(baos.toByteArray()), 
+          getClass().getResource(CUSTOMER2_XML)));
+  }
+  
+  public void testDefineSequencedType() throws Exception 
+  {
+    
+    TypeHelper types = SDOUtil.createTypeHelper();
+    DataFactory factory = SDOUtil.createDataFactory(types);
+    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
+    
+    Type stringType = types.getType("commonj.sdo", "String");
+    Type decimalType = types.getType("commonj.sdo", "Decimal");
+    
+    // Define a new mixed type - MixedQuote
+    DataObject mixedQuoteType = factory.create("commonj.sdo", "Type");
+    mixedQuoteType.set("uri", "http://www.example.com/mixed");
+    mixedQuoteType.set("name", "MixedQuote");
+    mixedQuoteType.set("sequenced", Boolean.TRUE);
+    
+    DataObject symbolProperty = mixedQuoteType.createDataObject("property");
+    symbolProperty.set("name", "symbol");
+    symbolProperty.set("type", stringType);
+    
+    DataObject companyNameProperty = mixedQuoteType.createDataObject("property");
+    companyNameProperty.set("name", "companyName");
+    companyNameProperty.set("type", stringType);
+    
+    DataObject priceProperty = mixedQuoteType.createDataObject("property");
+    priceProperty.set("name", "price");
+    priceProperty.set("type", decimalType);
+    
+    DataObject quotesProperty = mixedQuoteType.createDataObject("property");
+    quotesProperty.set("name", "quotes");
+    quotesProperty.set("type", mixedQuoteType);
+    quotesProperty.set("many", Boolean.TRUE);
+    quotesProperty.set("containment", Boolean.TRUE);
+    
+    types.define(mixedQuoteType);
+    
+    DataObject quote = factory.create("http://www.example.com/mixed", "MixedQuote");
+
+    assertTrue(quote.getType().isSequenced());
+    
+    Sequence sequence = quote.getSequence();
+
+    sequence.add("\n  ");
+
+    quote.setString("symbol", "fbnt");
+
+    sequence.add("\n  ");
+
+    quote.setString("companyName", "FlyByNightTechnology");
+
+    sequence.add("\n  some text\n  ");
+
+    DataObject child = quote.createDataObject("quotes");
+    child.setBigDecimal("price", new BigDecimal("2000.0"));
+
+    sequence.add("\n  more text\n  ");
+
+    // quote.setBigDecimal("price", new BigDecimal("1000.0"));
+    sequence.add("price", new BigDecimal("1000.0"));
+
+    sequence.add("\n");
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    xmlHelper.save(quote, "http://www.example.com/mixed", "mixedStockQuote", baos);
+    assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(MIXED_XML)));
+  }
+  
+  public void testDefineSequencedOpenType() throws Exception 
+  {
+    
+    TypeHelper types = SDOUtil.createTypeHelper();
+    DataFactory factory = SDOUtil.createDataFactory(types);
+    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
+    
+    Type stringType = types.getType("commonj.sdo", "String");
+    Type decimalType = types.getType("commonj.sdo", "Decimal");
+    
+    // Define a new mixed type - MixedQuote
+    DataObject mixedQuoteType = factory.create("commonj.sdo", "Type");
+    mixedQuoteType.set("uri", "http://www.example.com/mixed");
+    mixedQuoteType.set("name", "MixedOpenQuote");
+    mixedQuoteType.set("sequenced", Boolean.TRUE);
+    mixedQuoteType.set("open", Boolean.TRUE);
+    
+//    DataObject symbolProperty = mixedQuoteType.createDataObject("property");
+//    symbolProperty.set("name", "symbol");
+//    symbolProperty.set("type", stringType);
+    
+    DataObject companyNameProperty = mixedQuoteType.createDataObject("property");
+    companyNameProperty.set("name", "companyName");
+    companyNameProperty.set("type", stringType);
+    
+    DataObject priceProperty = mixedQuoteType.createDataObject("property");
+    priceProperty.set("name", "price");
+    priceProperty.set("type", decimalType);
+    
+    DataObject quotesProperty = mixedQuoteType.createDataObject("property");
+    quotesProperty.set("name", "quotes");
+    quotesProperty.set("type", mixedQuoteType);
+    quotesProperty.set("many", Boolean.TRUE);
+    quotesProperty.set("containment", Boolean.TRUE);
+    
+    types.define(mixedQuoteType);
+    
+    // Define a global type
+    DataObject globalType = factory.create("commonj.sdo", "Type");
+    globalType.set("uri", "http://www.example.com/open");
+    // Don't set the type's name - null is used for types containing global properties.
+    
+    DataObject symbolProperty = globalType.createDataObject("property");
+    symbolProperty.set("name", "symbol");
+    symbolProperty.set("type", stringType);
+    symbolProperty.set("containment", Boolean.TRUE);
+    
+    types.define(globalType);
+    
+    DataObject quote = factory.create("http://www.example.com/mixed", "MixedOpenQuote");
+
+    assertTrue(quote.getType().isSequenced());
+    
+    Sequence sequence = quote.getSequence();
+
+    sequence.add("\n  ");
+
+    Type definedGlobalType = types.getType("http://www.example.com/open", null);
+    
+    Property definedSymbolProperty = definedGlobalType.getProperty("symbol");
+    quote.setString(definedSymbolProperty, "fbnt");
+
+    sequence.add("\n  ");
+
+    quote.setString("companyName", "FlyByNightTechnology");
+
+    sequence.add("\n  some text\n  ");
+
+    DataObject child = quote.createDataObject("quotes");
+    child.setBigDecimal("price", new BigDecimal("2000.0"));
+
+    sequence.add("\n  more text\n  ");
+
+    // quote.setBigDecimal("price", new BigDecimal("1000.0"));
+    sequence.add("price", new BigDecimal("1000.0"));
+
+    sequence.add("\n");
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    xmlHelper.save(quote, "http://www.example.com/mixed", "mixedOpenStockQuote", baos);
+    assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(MIXEDOPEN_XML)));
+  }
+
+  
+  public void testDefineOpenType() throws Exception 
+  {
+    TypeHelper types = SDOUtil.createTypeHelper();
+    DataFactory factory = SDOUtil.createDataFactory(types);
+    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
+    
+    Type stringType = types.getType("commonj.sdo", "String");
+    Type decimalType = types.getType("commonj.sdo", "Decimal");
+    
+    // Define a new open type - OpenQuote
+    DataObject openQuoteType = factory.create("commonj.sdo", "Type");
+    openQuoteType.set("uri", "http://www.example.com/open");
+    openQuoteType.set("name", "OpenQuote");
+    openQuoteType.set("open", Boolean.TRUE);
+    openQuoteType.setBoolean("open", true);
+    
+    types.define(openQuoteType);
+    
+    // Define new type - CompanyType
+    DataObject companyType = factory.create("commonj.sdo", "Type");
+    companyType.set("uri", "http://www.example.com/open");
+    companyType.set("name", "CompanyType");
+    
+    // Create CompanyType property - "name"
+    DataObject nameProperty = companyType.createDataObject("property");
+    nameProperty.set("name", "name");
+    nameProperty.set("type", stringType);
+    nameProperty.set("containment", Boolean.TRUE);
+    
+    types.define(companyType);
+    
+    // Define a global type
+    DataObject globalType = factory.create("commonj.sdo", "Type");
+    globalType.set("uri", "http://www.example.com/open");
+    // Don't set the type's name - null is used for types containing global properties.
+    
+    DataObject symbolProperty = globalType.createDataObject("property");
+    symbolProperty.set("name", "symbol");
+    symbolProperty.set("type", stringType);
+    symbolProperty.set("containment", Boolean.TRUE);
+    
+    // Define a global property - company
+    DataObject companyProperty = globalType.createDataObject("property");
+    companyProperty.set("name", "company");
+    companyProperty.set("type", companyType);
+    companyProperty.set("containment", Boolean.TRUE);
+    
+    // Define a global property - price
+    DataObject priceProperty = globalType.createDataObject("property");
+    priceProperty.set("name", "price");
+    priceProperty.set("type", decimalType);
+    
+    types.define(globalType);
+    
+    // Create DataObject instances
+    DataObject openQuote = factory.create("http://www.example.com/open", "OpenQuote");
+    
+    assertTrue(openQuote.getType().isOpen());
+    
+    // Get global type
+    Type definedGlobalType = types.getType("http://www.example.com/open", null);
+    
+    Property definedSymbolProperty = definedGlobalType.getProperty("symbol");
+    openQuote.set(definedSymbolProperty, "s1");
+    
+    Property definedCompanyProperty = definedGlobalType.getProperty("company");
+    
+    DataObject company = openQuote.createDataObject(definedCompanyProperty);
+    company.setString("name", "FlyByNightTechnology");
+      
+    Property definedPriceProperty = definedGlobalType.getProperty("price");
+    openQuote.setBigDecimal(definedPriceProperty, new BigDecimal("1000.0"));
+    
+    assertEquals(definedPriceProperty.getType(), decimalType);
+    
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    xmlHelper.save(
+      openQuote, 
+      "http://www.example.com/open",
+      "openStockQuote", baos);
+    assertTrue(
+      TestUtil.equalXmlFiles(
+        new ByteArrayInputStream(baos.toByteArray()), 
+        getClass().getResource(OPEN_XML)));
+  }
+  
+}

Propchange: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/JiraTestCases.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Aug 28 11:53:49 2006
@@ -1 +1 @@
-Rev,Date
+Rev Date

Modified: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java?rev=437778&r1=437777&r2=437778&view=diff
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java (original)
+++ incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java Mon Aug 28 11:53:49 2006
@@ -1,28 +1,28 @@
-package org.apache.tuscany.sdo.test;
-
-import java.io.IOException;
-import java.net.URL;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sdo.util.SDOUtil;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.Type;
-import commonj.sdo.helper.DataFactory;
-import commonj.sdo.helper.XSDHelper;
-
-public final class SubstitutionValuesTestCase extends TestCase
-{
-  public void test() throws IOException
-  {
-    URL url = getClass().getResource("/SubstitutionValues.xsd");
-    XSDHelper.INSTANCE.define(url.openStream(), url.toString());
-
-    final DataObject  object = DataFactory.INSTANCE.create("http://www.apache.org/tuscany/SubstitutionValues", "TestObject");
-    final Type  type = object.getType();
-    
-    assertNotNull( SDOUtil.getSubstitutionValues(object, type.getProperty("groupHead")));
-    assertNull( SDOUtil.getSubstitutionValues(object, type.getProperty("nonGroupHead")));
-  }
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.XSDHelper;
+
+public final class SubstitutionValuesTestCase extends TestCase
+{
+  public void test() throws IOException
+  {
+    URL url = getClass().getResource("/SubstitutionValues.xsd");
+    XSDHelper.INSTANCE.define(url.openStream(), url.toString());
+
+    final DataObject  object = DataFactory.INSTANCE.create("http://www.apache.org/tuscany/SubstitutionValues", "TestObject");
+    final Type  type = object.getType();
+    
+    assertNotNull( SDOUtil.getSubstitutionValues(object, type.getProperty("groupHead")));
+    assertNull( SDOUtil.getSubstitutionValues(object, type.getProperty("nonGroupHead")));
+  }
 }

Propchange: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Mon Aug 28 11:53:49 2006
@@ -1 +1 @@
-Rev,Date
+Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org