You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ke...@apache.org on 2007/05/09 17:48:59 UTC
svn commit: r536574 -
/incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/util/CTSUtil.java
Author: kelvingoodson
Date: Wed May 9 08:48:59 2007
New Revision: 536574
URL: http://svn.apache.org/viewvc?view=rev&rev=536574
Log:
adding CTSUtil to begin moving convenience methods out of TestHelper
Added:
incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/util/CTSUtil.java (with props)
Added: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/util/CTSUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/util/CTSUtil.java?view=auto&rev=536574
==============================================================================
--- incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/util/CTSUtil.java (added)
+++ incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/util/CTSUtil.java Wed May 9 08:48:59 2007
@@ -0,0 +1,74 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 test.sdo21.tests.util;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+
+public class CTSUtil {
+ /**
+ * Convenience method for creating a unique name that can be used for a
+ * property or type.
+ *
+ * @return String containing a unique name
+ */
+ public static DataObject createTypeDef(String uri, String name, boolean open,
+ HelperContext helperContext) {
+ DataObject typeDef = helperContext.getDataFactory().create("commonj.sdo",
+ "Type");
+ typeDef.set("uri", uri);
+ typeDef.set("name", name);
+ typeDef.set("open", Boolean.valueOf(open));
+ return typeDef;
+ }
+
+ public static DataObject createPropertyDef(DataObject typeDef, String propertyName,
+ Type type, boolean isMany, boolean isContainment) {
+ DataObject propertyDef = typeDef.createDataObject("property");
+ propertyDef.set("name", propertyName);
+ propertyDef.set("type", type);
+ propertyDef.set("many", isMany);
+ propertyDef.set("containment", isContainment);
+ return propertyDef;
+ }
+
+ public static DataObject createPropertyDef(DataObject typeDef, String propertyName,
+ String typeName, boolean isMany, boolean isContainment,
+ HelperContext helperContext) {
+ int pos = typeName.indexOf('#');
+ String uri = "";
+ String name;
+ if (pos > 0) {
+ uri = typeName.substring(0, pos);
+ name = typeName.substring(pos + 1);
+ } else {
+ name = typeName;
+ }
+ Type propertyType = helperContext.getTypeHelper().getType(uri, name);
+ return createPropertyDef(typeDef, propertyName, propertyType, isMany,
+ isContainment);
+ }
+
+ public static String createUniqueName() {
+ return "name-" + System.currentTimeMillis() + "-"
+ + ((int) (1000 * Math.random()));
+ }
+}
Propchange: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/util/CTSUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/cts/sdo2.1/src/main/java/test/sdo21/tests/util/CTSUtil.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org