You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2013/05/13 20:01:31 UTC
[40/96] [abbrv] [partial] merge master
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/awsapi/pom.xml
----------------------------------------------------------------------
diff --git a/awsapi/pom.xml b/awsapi/pom.xml
index f19a713..d457349 100644
--- a/awsapi/pom.xml
+++ b/awsapi/pom.xml
@@ -286,12 +286,6 @@
</dependency>
</dependencies>
<build>
- <defaultGoal>install</defaultGoal>
- <sourceDirectory>src</sourceDirectory>
- <!-- Tests still depend on hibernate,
- so thats not going to work
- <testSourceDirectory>test</testSourceDirectory>
- -->
<resources>
<resource>
<directory>src</directory>
@@ -307,6 +301,17 @@
</resource>
</resources>
<plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>com/cloud/gate/util/UtilTestCase.java</exclude>
+ <exclude>com/cloud/gate/service/ServiceTestCase.java</exclude>
+ <exclude>com/cloud/gate/util/CloudStackClientTestCase.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
@@ -364,22 +369,6 @@
</executions>
</plugin>
</plugins>
- <!--
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.2</version>
- <executions>
- <execution>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- -->
<pluginManagement>
<plugins>
<plugin>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/awsapi/test/com/cloud/gate/model/ModelTestCase.java
----------------------------------------------------------------------
diff --git a/awsapi/test/com/cloud/gate/model/ModelTestCase.java b/awsapi/test/com/cloud/gate/model/ModelTestCase.java
deleted file mode 100644
index 91aeaa7..0000000
--- a/awsapi/test/com/cloud/gate/model/ModelTestCase.java
+++ /dev/null
@@ -1,368 +0,0 @@
-// 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 com.cloud.gate.model;
-
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.junit.Assert;
-
-import com.cloud.bridge.model.MHost;
-import com.cloud.bridge.model.MHostMount;
-import com.cloud.bridge.model.SBucket;
-import com.cloud.bridge.model.SHost;
-import com.cloud.bridge.model.SMeta;
-import com.cloud.bridge.model.SObject;
-import com.cloud.bridge.util.CloudSessionFactory;
-import com.cloud.bridge.util.QueryHelper;
-import com.cloud.gate.testcase.BaseTestCase;
-
-public class ModelTestCase extends BaseTestCase {
- protected final static Logger logger = Logger.getLogger(ModelTestCase.class);
-
- public void testSHost() {
- SHost host;
-
- // create the record
- Session session = CloudSessionFactory.getInstance().openSession();
- try {
- Transaction txn = session.beginTransaction();
- host = new SHost();
- host.setHost("localhost");
- host.setExportRoot("/");
- host.setUserOnHost("root");
- host.setUserPassword("password");
- session.saveOrUpdate(host);
- txn.commit();
- } finally {
- session.close();
- }
- Assert.assertTrue(host.getId() != 0);
-
- // retrive the record
- session = CloudSessionFactory.getInstance().openSession();
- try {
- Transaction txn = session.beginTransaction();
- host = (SHost)session.get(SHost.class, (long)host.getId());
- txn.commit();
-
- Assert.assertTrue(host.getHost().equals("localhost"));
- Assert.assertTrue(host.getUserOnHost().equals("root"));
- Assert.assertTrue(host.getUserPassword().equals("password"));
-
- logger.info("Retrived record, host:" + host.getHost()
- + ", user: " + host.getUserOnHost()
- + ", password: " + host.getUserPassword());
-
- } finally {
- session.close();
- }
-
- // delete the record
- session = CloudSessionFactory.getInstance().openSession();
- try {
- Transaction txn = session.beginTransaction();
- host = (SHost)session.get(SHost.class, (long)host.getId());
- session.delete(host);
- txn.commit();
- } finally {
- session.close();
- }
-
- session = CloudSessionFactory.getInstance().openSession();
- try {
- Transaction txn = session.beginTransaction();
- host = (SHost)session.get(SHost.class, (long)host.getId());
- txn.commit();
-
- Assert.assertTrue(host == null);
- } finally {
- session.close();
- }
- }
-
- public void testSBucket() {
- SHost host;
- SBucket bucket;
- Session session;
-
- session = CloudSessionFactory.getInstance().openSession();
- try {
- Transaction txn = session.beginTransaction();
- host = new SHost();
- host.setHost("localhost");
- host.setUserOnHost("root");
- host.setUserPassword("password");
- host.setExportRoot("/");
-
- bucket = new SBucket();
- bucket.setName("Bucket");
- bucket.setOwnerCanonicalId("OwnerId-dummy");
- bucket.setCreateTime(new Date());
-
- host.getBuckets().add(bucket);
- bucket.setShost(host);
-
- session.save(host);
- session.save(bucket);
- txn.commit();
- } finally {
- session.close();
- }
-
- long bucketId = bucket.getId();
-
- // load bucket
- session = CloudSessionFactory.getInstance().openSession();
- try {
- Transaction txn = session.beginTransaction();
- bucket = (SBucket)session.get(SBucket.class, bucketId);
- txn.commit();
-
- Assert.assertTrue(bucket.getShost().getHost().equals("localhost"));
- Assert.assertTrue(bucket.getName().equals("Bucket"));
- Assert.assertTrue(bucket.getOwnerCanonicalId().equals("OwnerId-dummy"));
- } finally {
- session.close();
- }
-
- // delete the bucket
- session = CloudSessionFactory.getInstance().openSession();
- try {
- Transaction txn = session.beginTransaction();
- bucket = (SBucket)session.get(SBucket.class, bucketId);
- session.delete(bucket);
-
- host = (SHost)session.get(SHost.class, host.getId());
- session.delete(host);
- txn.commit();
- } finally {
- session.close();
- }
-
- // verify the deletion
- session = CloudSessionFactory.getInstance().openSession();
- try {
- Transaction txn = session.beginTransaction();
- bucket = (SBucket)session.get(SBucket.class, bucketId);
- txn.commit();
-
- Assert.assertTrue(bucket == null);
- } finally {
- session.close();
- }
- }
-
- public void testSObject() {
- SHost host;
- SBucket bucket;
- Session session;
- SObject sobject;
-
- // setup
- session = CloudSessionFactory.getInstance().openSession();
- try {
- Transaction txn = session.beginTransaction();
- host = new SHost();
- host.setHost("localhost");
- host.setUserOnHost("root");
- host.setUserPassword("password");
- host.setExportRoot("/");
-
- bucket = new SBucket();
- bucket.setName("Bucket");
- bucket.setOwnerCanonicalId("OwnerId-dummy");
- bucket.setCreateTime(new Date());
- bucket.setShost(host);
- host.getBuckets().add(bucket);
-
- sobject = new SObject();
- sobject.setNameKey("ObjectNameKey");
- sobject.setOwnerCanonicalId("OwnerId-dummy");
- sobject.setCreateTime(new Date());
- sobject.setBucket(bucket);
- bucket.getObjectsInBucket().add(sobject);
-
- session.save(host);
- session.save(bucket);
- session.save(sobject);
- txn.commit();
-
- } finally {
- session.close();
- }
-
- session = CloudSessionFactory.getInstance().openSession();
- try {
- Transaction txn = session.beginTransaction();
- sobject = (SObject)session.get(SObject.class, sobject.getId());
- txn.commit();
- Assert.assertTrue(sobject.getBucket().getName().equals("Bucket"));
- Assert.assertTrue(sobject.getNameKey().equals("ObjectNameKey"));
- Assert.assertTrue(sobject.getOwnerCanonicalId().equals("OwnerId-dummy"));
- } finally {
- session.close();
- }
-
- // test delete cascade
- session = CloudSessionFactory.getInstance().openSession();
- try {
- Transaction txn = session.beginTransaction();
- bucket = (SBucket)session.get(SBucket.class, bucket.getId());
- session.delete(bucket);
-
- host = (SHost)session.get(SHost.class, host.getId());
- session.delete(host);
- txn.commit();
- } finally {
- session.close();
- }
- }
-
- public void testMeta() {
- Session session;
-
- session = CloudSessionFactory.getInstance().openSession();
- try {
- Transaction txn = session.beginTransaction();
- SMeta meta = new SMeta();
- meta.setTarget("SObject");
- meta.setTargetId(1);
- meta.setName("param1");
- meta.setValue("value1");
- session.save(meta);
-
- logger.info("Meta 1: " + meta.getId());
-
- meta = new SMeta();
- meta.setTarget("SObject");
- meta.setTargetId(1);
- meta.setName("param2");
- meta.setValue("value2");
- session.save(meta);
-
- logger.info("Meta 2: " + meta.getId());
-
- txn.commit();
- } finally {
- session.close();
- }
-
- session = CloudSessionFactory.getInstance().openSession();
- try {
- Transaction txn = session.beginTransaction();
- Query query = session.createQuery("from SMeta where target=? and targetId=?");
- QueryHelper.bindParameters(query, new Object[] {
- "SObject", new Long(1)
- });
- List<SMeta> l = QueryHelper.executeQuery(query);
- txn.commit();
-
- for(SMeta meta: l) {
- logger.info("" + meta.getName() + "=" + meta.getValue());
- }
- } finally {
- session.close();
- }
-
- session = CloudSessionFactory.getInstance().openSession();
- try {
- Transaction txn = session.beginTransaction();
- Query query = session.createQuery("delete from SMeta where target=?");
- QueryHelper.bindParameters(query, new Object[] {"SObject"});
- query.executeUpdate();
- txn.commit();
- } finally {
- session.close();
- }
- }
-
- public void testHosts() {
- Session session;
- SHost shost;
- MHost mhost;
- MHostMount hostMount;
-
- session = CloudSessionFactory.getInstance().openSession();
- try {
- Transaction txn = session.beginTransaction();
- shost = new SHost();
- shost.setHost("Storage host1");
- shost.setUserOnHost("root");
- shost.setUserPassword("password");
- shost.setExportRoot("/");
- session.save(shost);
-
- mhost = new MHost();
- mhost.setHostKey("1");
- mhost.setHost("management host1");
- mhost.setVersion("v1");
- session.save(mhost);
-
- hostMount = new MHostMount();
- hostMount.setMhost(mhost);
- hostMount.setShost(shost);
- hostMount.setMountPath("/mnt");
- session.save(hostMount);
- txn.commit();
- } finally {
- session.close();
- }
-
- session = CloudSessionFactory.getInstance().openSession();
- try {
- Transaction txn = session.beginTransaction();
- mhost = (MHost)session.createQuery("from MHost where hostKey=?").
- setLong(0, new Long(1)).uniqueResult();
-
- if(mhost != null) {
- Iterator it = mhost.getMounts().iterator();
- while(it.hasNext()) {
- MHostMount mount = (MHostMount)it.next();
- Assert.assertTrue(mount.getMountPath().equals("/mnt"));
-
- logger.info(mount.getMountPath());
- }
- }
- txn.commit();
- } finally {
- session.close();
- }
-
- session = CloudSessionFactory.getInstance().openSession();
- try {
- Transaction txn = session.beginTransaction();
- mhost = (MHost)session.createQuery("from MHost where hostKey=?").
- setLong(0, new Long(1)).uniqueResult();
- if(mhost != null)
- session.delete(mhost);
-
- shost = (SHost)session.createQuery("from SHost where host=?").
- setString(0, "Storage host1").uniqueResult();
- if(shost != null)
- session.delete(shost);
- txn.commit();
- } finally {
- session.close();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c11dbad9/awsapi/test/com/cloud/gate/persist/PersitTestCase.java
----------------------------------------------------------------------
diff --git a/awsapi/test/com/cloud/gate/persist/PersitTestCase.java b/awsapi/test/com/cloud/gate/persist/PersitTestCase.java
deleted file mode 100644
index 4961d93..0000000
--- a/awsapi/test/com/cloud/gate/persist/PersitTestCase.java
+++ /dev/null
@@ -1,73 +0,0 @@
-// 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 com.cloud.gate.persist;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.bridge.persist.PersistContext;
-import com.cloud.gate.testcase.BaseTestCase;
-
-public class PersitTestCase extends BaseTestCase {
- protected final static Logger logger = Logger.getLogger(PersitTestCase.class);
-
- public void testNamedLock() {
- Thread t1 = new Thread(new Runnable() {
- public void run() {
- for(int i = 0; i < 10; i++) {
- if(PersistContext.acquireNamedLock("TestLock", 3)) {
- logger.info("Thread 1 acquired lock");
- try {
- Thread.currentThread().sleep(BaseTestCase.getRandomMilliseconds(5000, 10000));
- } catch (InterruptedException e) {
- }
- logger.info("Thread 1 to release lock");
- PersistContext.releaseNamedLock("TestLock");
- } else {
- logger.info("Thread 1 is unable to acquire lock");
- }
- }
- }
- });
-
- Thread t2 = new Thread(new Runnable() {
- public void run() {
- for(int i = 0; i < 10; i++) {
- if(PersistContext.acquireNamedLock("TestLock", 3)) {
- logger.info("Thread 2 acquired lock");
- try {
- Thread.currentThread().sleep(BaseTestCase.getRandomMilliseconds(1000, 5000));
- } catch (InterruptedException e) {
- }
- logger.info("Thread 2 to release lock");
- PersistContext.releaseNamedLock("TestLock");
- } else {
- logger.info("Thread 2 is unable to acquire lock");
- }
- }
- }
- });
-
- t1.start();
- t2.start();
-
- try {
- t1.join();
- t2.join();
- } catch(InterruptedException e) {
- }
- }
-}