You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by re...@apache.org on 2015/12/03 10:13:07 UTC

[1/2] git commit: updated refs/heads/master to 6d558c0

Repository: cloudstack
Updated Branches:
  refs/heads/master 17d5bfa32 -> 6d558c020


created tests cases for method "citrixResourceBase.getPatchFiles"

we also changed the name of those test classes, the change was basically
remove the “Path” word from the name of classes.

change the private method
com.cloud.hypervisor.xenserver.resource.CitrixResourceBase.getPatchFiles
to protected

added new class in test cases


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d01cdb19
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d01cdb19
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d01cdb19

Branch: refs/heads/master
Commit: d01cdb19794f00cef8c97729daf25123335a7f44
Parents: 63203ce
Author: pedro-martins <ph...@gmail.com>
Authored: Sat Oct 17 17:33:41 2015 -0300
Committer: weingartner <ra...@gmail.com>
Committed: Sat Nov 28 19:06:04 2015 -0200

----------------------------------------------------------------------
 .../xenserver/resource/CitrixResourceBase.java  |  2 +-
 .../resource/CitrixResourceBaseTest.java        | 52 ++++++++++++++++++++
 .../resource/XcpOssResourcePathTest.java        | 32 ------------
 .../xenserver/resource/XcpOssResourceTest.java  | 50 +++++++++++++++++++
 .../resource/XcpServerResourcePathTest.java     | 32 ------------
 .../resource/XcpServerResourceTest.java         | 51 +++++++++++++++++++
 .../XenServer56FP1ResourcePathTest.java         | 32 ------------
 .../resource/XenServer56FP1ResourceTest.java    | 48 ++++++++++++++++++
 .../resource/XenServer56ResourcePathTest.java   | 32 ------------
 .../resource/XenServer56ResourceTest.java       | 49 ++++++++++++++++++
 .../XenServer56SP2ResourcePathTest.java         | 32 ------------
 .../resource/XenServer56SP2ResourceTest.java    | 48 ++++++++++++++++++
 .../resource/XenServer600ResourcePathTest.java  | 32 ------------
 .../resource/XenServer600ResourceTest.java      | 48 ++++++++++++++++++
 .../resource/XenServer625ResourcePathTest.java  | 32 ------------
 .../resource/XenServer625ResourceTest.java      | 48 ++++++++++++++++++
 .../resource/XenServer650ResourcePathTest.java  | 32 ------------
 .../resource/XenServer650ResourceTest.java      | 49 ++++++++++++++++++
 18 files changed, 444 insertions(+), 257 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
index 9a34cd2..e1f7d3d 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
@@ -2869,7 +2869,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
         }
     }
 
-    private List<File> getPatchFiles() {
+    protected List<File> getPatchFiles() {
         String patch = getPatchFilePath();
         String patchfilePath = Script.findScript("", patch);
         if (patchfilePath == null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/CitrixResourceBaseTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/CitrixResourceBaseTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/CitrixResourceBaseTest.java
new file mode 100644
index 0000000..353b106
--- /dev/null
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/CitrixResourceBaseTest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2015 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 com.cloud.hypervisor.xenserver.resource;
+
+import java.io.File;
+import java.util.List;
+
+import org.junit.Assert;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+
+import com.cloud.utils.script.Script;
+
+public abstract class CitrixResourceBaseTest {
+
+    public void testGetPathFilesExeption(CitrixResourceBase citrixResourceBase) {
+        String patch = citrixResourceBase.getPatchFilePath();
+
+        PowerMockito.mockStatic(Script.class);
+        Mockito.when(Script.findScript("", patch)).thenReturn(null);
+
+        citrixResourceBase.getPatchFiles();
+
+    }
+
+    public void testGetPathFilesListReturned(CitrixResourceBase citrixResourceBase) {
+        String patch = citrixResourceBase.getPatchFilePath();
+
+        PowerMockito.mockStatic(Script.class);
+        Mockito.when(Script.findScript("", patch)).thenReturn(patch);
+
+        File expected = new File(patch);
+        String pathExpected = expected.getAbsolutePath();
+
+        List<File> files = citrixResourceBase.getPatchFiles();
+        String receivedPath = files.get(0).getAbsolutePath();
+        Assert.assertEquals(receivedPath, pathExpected);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpOssResourcePathTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpOssResourcePathTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpOssResourcePathTest.java
deleted file mode 100644
index 1617432..0000000
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpOssResourcePathTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2015 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 com.cloud.hypervisor.xenserver.resource;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class XcpOssResourcePathTest {
-
-    private XcpOssResource xcpOssResource = new XcpOssResource();
-
-    @Test
-    public void testPatchFilePath() {
-        String patchFilePath = xcpOssResource.getPatchFilePath();
-        String patch = "scripts/vm/hypervisor/xenserver/xcposs/patch";
-
-        Assert.assertEquals(patch, patchFilePath);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpOssResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpOssResourceTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpOssResourceTest.java
new file mode 100644
index 0000000..b0c900c
--- /dev/null
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpOssResourceTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2015 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 com.cloud.hypervisor.xenserver.resource;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
+@RunWith(PowerMockRunner.class)
+public class XcpOssResourceTest extends CitrixResourceBaseTest{
+
+    private XcpOssResource xcpOssResource = new XcpOssResource();
+
+    @Test
+    public void testPatchFilePath() {
+        String patchFilePath = xcpOssResource.getPatchFilePath();
+        String patch = "scripts/vm/hypervisor/xenserver/xcposs/patch";
+
+        Assert.assertEquals(patch, patchFilePath);
+    }
+
+    @Test(expected = CloudRuntimeException.class)
+    @PrepareForTest(Script.class )
+    public void testGetFiles(){
+        testGetPathFilesExeption(xcpOssResource);
+    }
+
+    @Test
+    @PrepareForTest(Script.class )
+    public void testGetFilesListReturned(){
+        testGetPathFilesListReturned(xcpOssResource);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpServerResourcePathTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpServerResourcePathTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpServerResourcePathTest.java
deleted file mode 100644
index 17fa649..0000000
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpServerResourcePathTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2015 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 com.cloud.hypervisor.xenserver.resource;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class XcpServerResourcePathTest {
-
-    private XcpServerResource xcpServerResource = new XcpServerResource();
-
-    @Test
-    public void testPatchFilePath() {
-        String patchFilePath = xcpServerResource.getPatchFilePath();
-        String patch = "scripts/vm/hypervisor/xenserver/xcpserver/patch";
-
-        Assert.assertEquals(patch, patchFilePath);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpServerResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpServerResourceTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpServerResourceTest.java
new file mode 100644
index 0000000..ba3d91d
--- /dev/null
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpServerResourceTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2015 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 com.cloud.hypervisor.xenserver.resource;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
+
+@RunWith(PowerMockRunner.class)
+public class XcpServerResourceTest extends CitrixResourceBaseTest{
+
+    private XcpServerResource xcpServerResource = new XcpServerResource();
+
+    @Test
+    public void testPatchFilePath() {
+        String patchFilePath = xcpServerResource.getPatchFilePath();
+        String patch = "scripts/vm/hypervisor/xenserver/xcpserver/patch";
+
+        Assert.assertEquals(patch, patchFilePath);
+    }
+
+    @Test(expected = CloudRuntimeException.class)
+    @PrepareForTest(Script.class )
+    public void testGetFilesExeption(){
+        testGetPathFilesExeption(xcpServerResource);
+    }
+
+    @Test
+    @PrepareForTest(Script.class )
+    public void testGetFilesListReturned(){
+        testGetPathFilesListReturned(xcpServerResource);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56FP1ResourcePathTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56FP1ResourcePathTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56FP1ResourcePathTest.java
deleted file mode 100644
index 7b76816..0000000
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56FP1ResourcePathTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2015 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 com.cloud.hypervisor.xenserver.resource;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class XenServer56FP1ResourcePathTest {
-
-    private XenServer56FP1Resource xenServer56FP1Resource = new XenServer56FP1Resource();
-
-    @Test
-    public void testPatchFilePath() {
-        String patchFilePath = xenServer56FP1Resource.getPatchFilePath();
-        String patch = "scripts/vm/hypervisor/xenserver/xenserver56fp1/patch";
-
-        Assert.assertEquals(patch, patchFilePath);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56FP1ResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56FP1ResourceTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56FP1ResourceTest.java
new file mode 100644
index 0000000..def51cf
--- /dev/null
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56FP1ResourceTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2015 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 com.cloud.hypervisor.xenserver.resource;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
+@RunWith(PowerMockRunner.class)
+public class XenServer56FP1ResourceTest extends CitrixResourceBaseTest{
+
+    private XenServer56FP1Resource xenServer56FP1Resource = new XenServer56FP1Resource();
+
+    @Test
+    public void testPatchFilePath() {
+        String patchFilePath = xenServer56FP1Resource.getPatchFilePath();
+        String patch = "scripts/vm/hypervisor/xenserver/xenserver56fp1/patch";
+
+        Assert.assertEquals(patch, patchFilePath);
+    }
+    @Test(expected = CloudRuntimeException.class)
+    @PrepareForTest(Script.class )
+    public void testGetFiles(){
+        testGetPathFilesExeption(xenServer56FP1Resource);
+    }
+    @Test
+    @PrepareForTest(Script.class )
+    public void testGetFilesListReturned(){
+        testGetPathFilesListReturned(xenServer56FP1Resource);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56ResourcePathTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56ResourcePathTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56ResourcePathTest.java
deleted file mode 100644
index c92dd23..0000000
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56ResourcePathTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2015 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 com.cloud.hypervisor.xenserver.resource;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class XenServer56ResourcePathTest {
-
-    private XenServer56Resource xenServer56Resource = new XenServer56Resource();
-
-    @Test
-    public void testPatchFilePath() {
-        String patchFilePath = xenServer56Resource.getPatchFilePath();
-        String patch = "scripts/vm/hypervisor/xenserver/xenserver56/patch";
-
-        Assert.assertEquals(patch, patchFilePath);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56ResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56ResourceTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56ResourceTest.java
new file mode 100644
index 0000000..960dd7f
--- /dev/null
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56ResourceTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2015 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 com.cloud.hypervisor.xenserver.resource;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
+@RunWith(PowerMockRunner.class)
+public class XenServer56ResourceTest extends CitrixResourceBaseTest {
+
+    private XenServer56Resource xenServer56Resource = new XenServer56Resource();
+
+    @Test
+    public void testPatchFilePath() {
+        String patchFilePath = xenServer56Resource.getPatchFilePath();
+        String patch = "scripts/vm/hypervisor/xenserver/xenserver56/patch";
+
+        Assert.assertEquals(patch, patchFilePath);
+    }
+
+    @Test(expected = CloudRuntimeException.class)
+    @PrepareForTest(Script.class )
+    public void testGetFiles(){
+        testGetPathFilesExeption(xenServer56Resource);
+    }
+    @Test
+    @PrepareForTest(Script.class )
+    public void testGetFilesListReturned(){
+        testGetPathFilesListReturned(xenServer56Resource);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56SP2ResourcePathTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56SP2ResourcePathTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56SP2ResourcePathTest.java
deleted file mode 100644
index e301673..0000000
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56SP2ResourcePathTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2015 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 com.cloud.hypervisor.xenserver.resource;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class XenServer56SP2ResourcePathTest {
-
-    private XenServer56SP2Resource xenServer56SP2Resource = new XenServer56SP2Resource();
-
-    @Test
-    public void testPatchFilePath() {
-        String patchFilePath = xenServer56SP2Resource.getPatchFilePath();
-        String patch = "scripts/vm/hypervisor/xenserver/xenserver56fp1/patch";
-
-        Assert.assertEquals(patch, patchFilePath);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56SP2ResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56SP2ResourceTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56SP2ResourceTest.java
new file mode 100644
index 0000000..300f95d
--- /dev/null
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56SP2ResourceTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2015 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 com.cloud.hypervisor.xenserver.resource;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
+@RunWith(PowerMockRunner.class)
+public class XenServer56SP2ResourceTest extends CitrixResourceBaseTest{
+
+    private XenServer56SP2Resource xenServer56SP2Resource = new XenServer56SP2Resource();
+
+    @Test
+    public void testPatchFilePath() {
+        String patchFilePath = xenServer56SP2Resource.getPatchFilePath();
+        String patch = "scripts/vm/hypervisor/xenserver/xenserver56fp1/patch";
+
+        Assert.assertEquals(patch, patchFilePath);
+    }
+    @Test(expected = CloudRuntimeException.class)
+    @PrepareForTest(Script.class )
+    public void testGetFiles(){
+        testGetPathFilesExeption(xenServer56SP2Resource);
+    }
+    @Test
+    @PrepareForTest(Script.class )
+    public void testGetFilesListReturned(){
+        testGetPathFilesListReturned(xenServer56SP2Resource);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer600ResourcePathTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer600ResourcePathTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer600ResourcePathTest.java
deleted file mode 100644
index 27762e8..0000000
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer600ResourcePathTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2015 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 com.cloud.hypervisor.xenserver.resource;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class XenServer600ResourcePathTest {
-
-    private XenServer600Resource xenServer600Resource = new XenServer600Resource();
-
-    @Test
-    public void testPatchFilePath() {
-        String patchFilePath = xenServer600Resource.getPatchFilePath();
-        String patch = "scripts/vm/hypervisor/xenserver/xenserver60/patch";
-
-        Assert.assertEquals(patch, patchFilePath);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer600ResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer600ResourceTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer600ResourceTest.java
new file mode 100644
index 0000000..34deeb8
--- /dev/null
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer600ResourceTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2015 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 com.cloud.hypervisor.xenserver.resource;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
+@RunWith(PowerMockRunner.class)
+public class XenServer600ResourceTest extends CitrixResourceBaseTest{
+
+    private XenServer600Resource xenServer600Resource = new XenServer600Resource();
+
+    @Test
+    public void testPatchFilePath() {
+        String patchFilePath = xenServer600Resource.getPatchFilePath();
+        String patch = "scripts/vm/hypervisor/xenserver/xenserver60/patch";
+
+        Assert.assertEquals(patch, patchFilePath);
+    }
+    @Test(expected = CloudRuntimeException.class)
+    @PrepareForTest(Script.class )
+    public void testGetFiles(){
+        testGetPathFilesExeption(xenServer600Resource);
+    }
+    @Test
+    @PrepareForTest(Script.class )
+    public void testGetFilesListReturned(){
+        testGetPathFilesListReturned(xenServer600Resource);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer625ResourcePathTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer625ResourcePathTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer625ResourcePathTest.java
deleted file mode 100644
index 121ba0c..0000000
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer625ResourcePathTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2015 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 com.cloud.hypervisor.xenserver.resource;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class XenServer625ResourcePathTest {
-
-    private Xenserver625Resource xenServer625Resource = new Xenserver625Resource();
-
-    @Test
-    public void testPatchFilePath() {
-        String patchFilePath = xenServer625Resource.getPatchFilePath();
-        String patch = "scripts/vm/hypervisor/xenserver/xenserver62/patch";
-
-        Assert.assertEquals(patch, patchFilePath);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer625ResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer625ResourceTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer625ResourceTest.java
new file mode 100644
index 0000000..640ca06
--- /dev/null
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer625ResourceTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2015 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 com.cloud.hypervisor.xenserver.resource;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
+@RunWith(PowerMockRunner.class)
+public class XenServer625ResourceTest extends CitrixResourceBaseTest{
+
+    private Xenserver625Resource xenServer625Resource = new Xenserver625Resource();
+
+    @Test
+    public void testPatchFilePath() {
+        String patchFilePath = xenServer625Resource.getPatchFilePath();
+        String patch = "scripts/vm/hypervisor/xenserver/xenserver62/patch";
+
+        Assert.assertEquals(patch, patchFilePath);
+    }
+    @Test(expected = CloudRuntimeException.class)
+    @PrepareForTest(Script.class )
+    public void testGetFiles(){
+        testGetPathFilesExeption(xenServer625Resource);
+    }
+    @Test
+    @PrepareForTest(Script.class )
+    public void testGetFilesListReturned(){
+        testGetPathFilesListReturned(xenServer625Resource);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer650ResourcePathTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer650ResourcePathTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer650ResourcePathTest.java
deleted file mode 100644
index 18a4bbb..0000000
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer650ResourcePathTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2015 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 com.cloud.hypervisor.xenserver.resource;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class XenServer650ResourcePathTest {
-
-    private XenServer650Resource xenServer650Resource = new XenServer650Resource();
-
-    @Test
-    public void testPatchFilePath() {
-        String patchFilePath = xenServer650Resource.getPatchFilePath();
-        String patch = "scripts/vm/hypervisor/xenserver/xenserver65/patch";
-
-        Assert.assertEquals(patch, patchFilePath);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d01cdb19/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer650ResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer650ResourceTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer650ResourceTest.java
new file mode 100644
index 0000000..148b22d
--- /dev/null
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer650ResourceTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2015 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 com.cloud.hypervisor.xenserver.resource;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
+@RunWith(PowerMockRunner.class)
+public class XenServer650ResourceTest extends CitrixResourceBaseTest{
+
+    private XenServer650Resource xenServer650Resource = new XenServer650Resource();
+
+    @Test
+    public void testPatchFilePath() {
+        String patchFilePath = xenServer650Resource.getPatchFilePath();
+        String patch = "scripts/vm/hypervisor/xenserver/xenserver65/patch";
+
+        Assert.assertEquals(patch, patchFilePath);
+    }
+
+    @Test(expected = CloudRuntimeException.class)
+    @PrepareForTest(Script.class )
+    public void testGetFiles(){
+        testGetPathFilesExeption(xenServer650Resource);
+    }
+    @Test
+    @PrepareForTest(Script.class )
+    public void testGetFilesListReturned(){
+        testGetPathFilesListReturned(xenServer650Resource);
+    }
+}


[2/2] git commit: updated refs/heads/master to 6d558c0

Posted by re...@apache.org.
Merge pull request #944 from rafaelweingartner/lrg-cs-hackday-012

Create test cases to getPatchFilePath method and class names changed In this commit we created tests cases for the respective classes in package  com.cloud.hypervisor.xenserver.resource.

We added test cases to check the implementation of  com.cloud.hypervisor.xenserver.resource.CitrixResourceBase.getPatchFiles. Therefore, we test in a more comprehensive way the tests that already exist to check the code of com.cloud.hypervisor.xenserver.resource.CitrixResourceBase.getPatchFilePath.

We added a new abstract class, called com.cloud.hypervisor.xenserver.resource.CitrixResourceBaseTest.java

This class has two tests methods:

* com.cloud.hypervisor.xenserver.resource.CitrixResourceBaseTest.testGetPathFilesExeption(CitrixResourceBase), this method tests if the getPatchFilePath() method throws the com.cloud.utils.exception.CloudRuntimeException.CloudRuntimeException when the com.cloud.utils.script.Script.findScript(String, String) return a null value;
* com.cloud.hypervisor.xenserver.resource.CitrixResourceBaseTest.testGetPathFilesListReturned(CitrixResourceBase), this method tests the correct return value from getPatchFilePath() method, basically, verify if the returned list contain the file with the same absolute path that was retrieved from the findScript method.

We also changed the name of those test classes, the change was basically remove the Path word from the name of classes.

* pr/944:
  created tests cases for method "citrixResourceBase.getPatchFiles"

Signed-off-by: Remi Bergsma <gi...@remi.nl>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6d558c02
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6d558c02
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6d558c02

Branch: refs/heads/master
Commit: 6d558c0201980d6c04f8e7ad80e228556c293c93
Parents: 17d5bfa d01cdb1
Author: Remi Bergsma <gi...@remi.nl>
Authored: Thu Dec 3 10:12:07 2015 +0100
Committer: Remi Bergsma <gi...@remi.nl>
Committed: Thu Dec 3 10:12:07 2015 +0100

----------------------------------------------------------------------
 .../xenserver/resource/CitrixResourceBase.java  |  2 +-
 .../resource/CitrixResourceBaseTest.java        | 52 ++++++++++++++++++++
 .../resource/XcpOssResourcePathTest.java        | 32 ------------
 .../xenserver/resource/XcpOssResourceTest.java  | 50 +++++++++++++++++++
 .../resource/XcpServerResourcePathTest.java     | 32 ------------
 .../resource/XcpServerResourceTest.java         | 51 +++++++++++++++++++
 .../XenServer56FP1ResourcePathTest.java         | 32 ------------
 .../resource/XenServer56FP1ResourceTest.java    | 48 ++++++++++++++++++
 .../resource/XenServer56ResourcePathTest.java   | 32 ------------
 .../resource/XenServer56ResourceTest.java       | 49 ++++++++++++++++++
 .../XenServer56SP2ResourcePathTest.java         | 32 ------------
 .../resource/XenServer56SP2ResourceTest.java    | 48 ++++++++++++++++++
 .../resource/XenServer600ResourcePathTest.java  | 32 ------------
 .../resource/XenServer600ResourceTest.java      | 48 ++++++++++++++++++
 .../resource/XenServer625ResourcePathTest.java  | 32 ------------
 .../resource/XenServer625ResourceTest.java      | 48 ++++++++++++++++++
 .../resource/XenServer650ResourcePathTest.java  | 32 ------------
 .../resource/XenServer650ResourceTest.java      | 49 ++++++++++++++++++
 18 files changed, 444 insertions(+), 257 deletions(-)
----------------------------------------------------------------------