geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r462546 - in /geronimo/xbean/sandbox/xbean-factory: ./ src/test/java/org/apache/xbean/factory/ src/test/java/org/apache/xbean/factory/model/
Date Tue, 10 Oct 2006 20:30:43 GMT
Author: dain
Date: Tue Oct 10 13:30:42 2006
New Revision: 462546

URL: http://svn.apache.org/viewvc?view=rev&rev=462546
Log:
Added simple datamodle for testing

Added:
    geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/StaticTest.java
    geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/
    geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Column.java
    geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Database.java
    geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Schema.java
    geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Table.java
    geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Vendor.java
Modified:
    geronimo/xbean/sandbox/xbean-factory/pom.xml

Modified: geronimo/xbean/sandbox/xbean-factory/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/sandbox/xbean-factory/pom.xml?view=diff&rev=462546&r1=462545&r2=462546
==============================================================================
--- geronimo/xbean/sandbox/xbean-factory/pom.xml (original)
+++ geronimo/xbean/sandbox/xbean-factory/pom.xml Tue Oct 10 13:30:42 2006
@@ -15,4 +15,21 @@
       <scope>test</scope>
     </dependency>
   </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <excludes/>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 </project>

Added: geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/StaticTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/StaticTest.java?view=auto&rev=462546
==============================================================================
--- geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/StaticTest.java
(added)
+++ geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/StaticTest.java
Tue Oct 10 13:30:42 2006
@@ -0,0 +1,69 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  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.xbean.factory;
+
+import junit.framework.TestCase;
+import org.apache.xbean.factory.model.Database;
+import org.apache.xbean.factory.model.Vendor;
+import org.apache.xbean.factory.model.Schema;
+import org.apache.xbean.factory.model.Table;
+import org.apache.xbean.factory.model.Column;
+
+import java.net.URI;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StaticTest extends TestCase {
+    private Database database;
+
+    public void test() {
+        assertNotNull(database);
+        assertTrue(database.equals(database));
+
+        Schema people = database.getSchema("people");
+        assertNotNull(people);
+        assertTrue(people.equals(people));
+
+        Table person = people.getTable("person");
+        assertNotNull(person);
+        assertTrue(person.equals(person));
+
+        Column name = person.getColumn("name");
+        assertNotNull(name);
+        assertTrue(name.equals(name));
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        database = new Database("Centeral", Vendor.PostgreSQL, new URI("foo:bar/baz"));
+        Schema schema = database.addSchema("people");
+        Table person = schema.addTable("person");
+        person.addColumn("name", "string");
+        person.addColumn("age", "int");
+        Table address = schema.addTable("address");
+        address.addColumn("line1", "string");
+        address.addColumn("line2", "string");
+        address.addColumn("city", "string");
+        address.addColumn("state", "char[2]");
+        address.addColumn("zip", "long");
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+}

Added: geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Column.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Column.java?view=auto&rev=462546
==============================================================================
--- geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Column.java
(added)
+++ geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Column.java
Tue Oct 10 13:30:42 2006
@@ -0,0 +1,68 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  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.xbean.factory.model;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Column {
+    private String name;
+    private String dataType;
+
+    public Column() {
+    }
+
+    public Column(String name, String dataType) {
+        this.name = name;
+        this.dataType = dataType;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDataType() {
+        return dataType;
+    }
+
+    public void setDataType(String dataType) {
+        this.dataType = dataType;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        final Column column = (Column) o;
+
+        if (dataType != null ? !dataType.equals(column.dataType) : column.dataType != null)
return false;
+        if (name != null ? !name.equals(column.name) : column.name != null) return false;
+
+        return true;
+    }
+
+    public int hashCode() {
+        int result;
+        result = (name != null ? name.hashCode() : 0);
+        result = 29 * result + (dataType != null ? dataType.hashCode() : 0);
+        return result;
+    }
+}

Added: geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Database.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Database.java?view=auto&rev=462546
==============================================================================
--- geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Database.java
(added)
+++ geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Database.java
Tue Oct 10 13:30:42 2006
@@ -0,0 +1,112 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  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.xbean.factory.model;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Database {
+    private String name;
+    private Vendor vendor;
+    private URI location;
+    private final Map<String, Schema> schemas = new HashMap<String, Schema>();
+
+    public Database() {
+    }
+
+    public Database(String name) {
+        this.name = name;
+    }
+
+    public Database(String name, Vendor vendor, URI location) {
+        this.name = name;
+        this.vendor = vendor;
+        this.location = location;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Vendor getVendor() {
+        return vendor;
+    }
+
+    public void setVendor(Vendor vendor) {
+        this.vendor = vendor;
+    }
+
+    public URI getLocation() {
+        return location;
+    }
+
+    public void setLocation(URI location) {
+        this.location = location;
+    }
+
+    public Set<Schema> getSchemas() {
+        return new HashSet<Schema>(schemas.values());
+    }
+
+    public Schema getSchema(String name) {
+        return schemas.get(name);
+    }
+
+    public void setSchemas(Set<Schema> schemas) {
+        this.schemas.clear();
+        for (Schema schema : schemas) {
+            this.schemas.put(schema.getName(), schema);
+        }
+    }
+
+    public Schema addSchema(String name) {
+        Schema schema = new Schema(name);
+        schemas.put(name, schema);
+        return schema;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        final Database database = (Database) o;
+
+        if (location != null ? !location.equals(database.location) : database.location !=
null) return false;
+        if (name != null ? !name.equals(database.name) : database.name != null) return false;
+        if (schemas != null ? !schemas.equals(database.schemas) : database.schemas != null)
return false;
+        return vendor == database.vendor;
+    }
+
+    public int hashCode() {
+        int result;
+        result = (name != null ? name.hashCode() : 0);
+        result = 29 * result + (vendor != null ? vendor.hashCode() : 0);
+        result = 29 * result + (location != null ? location.hashCode() : 0);
+        result = 29 * result + (schemas != null ? schemas.hashCode() : 0);
+        return result;
+    }
+}

Added: geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Schema.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Schema.java?view=auto&rev=462546
==============================================================================
--- geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Schema.java
(added)
+++ geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Schema.java
Tue Oct 10 13:30:42 2006
@@ -0,0 +1,85 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  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.xbean.factory.model;
+
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Schema {
+    private String name;
+    private final Map<String, Table> tables = new LinkedHashMap<String, Table>();
+
+    public Schema() {
+    }
+
+    public Schema(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Table getTable(String name) {
+        return tables.get(name);
+    }
+
+    public Set<Table> getTables() {
+        return new HashSet<Table>(tables.values());
+    }
+
+    public void setTables(Set<Table> tables) {
+        this.tables.clear();
+        for (Table table : tables) {
+            this.tables.put(table.getName(), table);
+        }
+    }
+
+    public Table addTable(String name) {
+        Table table = new Table(name);
+        tables.put(name, table);
+        return table;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        final Schema schema = (Schema) o;
+
+        if (name != null ? !name.equals(schema.name) : schema.name != null) return false;
+        if (tables != null ? !tables.equals(schema.tables) : schema.tables != null) return
false;
+
+        return true;
+    }
+
+    public int hashCode() {
+        int result;
+        result = (name != null ? name.hashCode() : 0);
+        result = 29 * result + (tables != null ? tables.hashCode() : 0);
+        return result;
+    }
+}

Added: geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Table.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Table.java?view=auto&rev=462546
==============================================================================
--- geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Table.java
(added)
+++ geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Table.java
Tue Oct 10 13:30:42 2006
@@ -0,0 +1,84 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  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.xbean.factory.model;
+
+import java.util.List;
+import java.util.Map;
+import java.util.LinkedHashMap;
+import java.util.ArrayList;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Table {
+    private String name;
+    private final Map<String, Column> columns = new LinkedHashMap<String, Column>();
+
+    public Table() {
+    }
+
+    public Table(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Column getColumn(String name) {
+        return columns.get(name);
+    }
+
+    public List<Column> getColumns() {
+        return new ArrayList<Column>(columns.values());
+    }
+
+    public void setColumns(List<Column> columns) {
+        this.columns.clear();
+        for (Column column : columns) {
+            this.columns.put(column.getName(), column);
+        }
+    }
+
+    public Column addColumn(String name, String dataType) {
+        Column column = new Column(name, dataType);
+        columns.put(name, column);
+        return column;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        final Table table = (Table) o;
+
+        if (columns != null ? !columns.equals(table.columns) : table.columns != null) return
false;
+        return !(name != null ? !name.equals(table.name) : table.name != null);
+
+    }
+
+    public int hashCode() {
+        int result;
+        result = (name != null ? name.hashCode() : 0);
+        result = 29 * result + (columns != null ? columns.hashCode() : 0);
+        return result;
+    }
+}

Added: geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Vendor.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Vendor.java?view=auto&rev=462546
==============================================================================
--- geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Vendor.java
(added)
+++ geronimo/xbean/sandbox/xbean-factory/src/test/java/org/apache/xbean/factory/model/Vendor.java
Tue Oct 10 13:30:42 2006
@@ -0,0 +1,13 @@
+package org.apache.xbean.factory.model;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public enum Vendor {
+    mySql,
+    PostgreSQL,
+    FireBird,
+    Oracle,
+    DB2,
+    SQLServer
+}



Mime
View raw message