[Registry-dev] svn commit r14710 -
trunk/registry/modules/core/src/test/java/org/wso2/registry/app
svn at wso2.org
svn at wso2.org
Tue Mar 11 05:32:05 PDT 2008
Author: krishantha
Date: Tue Mar 11 05:32:02 2008
New Revision: 14710
Log:
modified to support single value properties
Modified:
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/ResourceHandling.java
Modified: trunk/registry/modules/core/src/test/java/org/wso2/registry/app/ResourceHandling.java
==============================================================================
--- trunk/registry/modules/core/src/test/java/org/wso2/registry/app/ResourceHandling.java (original)
+++ trunk/registry/modules/core/src/test/java/org/wso2/registry/app/ResourceHandling.java Tue Mar 11 05:32:02 2008
@@ -1,14 +1,27 @@
+/*
+ * 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 org.wso2.registry.app;
-
-import org.wso2.registry.Comment;
-import org.wso2.registry.RegistryException;
-import org.wso2.registry.Resource;
-import org.wso2.registry.Tag;
-
-import java.util.Properties;
-import java.util.List;
+import org.wso2.registry.*;
import java.util.ArrayList;
+import java.util.List;
+
public class ResourceHandling extends AbstractAPPTest {
@@ -17,17 +30,16 @@
public void testResourceCopy() {
try {
-
- String path="/f59/f2/r1";
+ String path="/f95/f2/r1";
String commentPath = path + ";comments";
- String new_path="/f60/f2/r2";
+ String new_path="/f96/f2/r1";
String commentPathNew = new_path + ";comments";
Resource r1 = registry.newResource();
r1.setDescription("This is a file to be renamed");
byte[] r1content = "R2 content".getBytes();
r1.setContent(r1content);
r1.setMediaType("txt");
-
+
Comment c1 = new Comment();
c1.setResourcePath(path);
c1.setText("This is a test comment1");
@@ -36,10 +48,8 @@
c2.setResourcePath(path);
c2.setText("This is a test comment2");
- Properties r1Pro = new Properties();
- r1Pro.setProperty("key1", "value1");
- r1Pro.setProperty("key2", "value2");
- r1.setProperties(r1Pro);
+ r1.setProperty("key1", "value1");
+ r1.setProperty("key2", "value2");
registry.put(path,r1);
registry.addComment(path,c1);
@@ -51,76 +61,56 @@
Resource r2 = registry.get(path);
- assertEquals("Properties are not equal",r1.getProperty("key1"),
- r2.getProperty("key1"));
-
- assertEquals("Properties are not equal",r1.getProperty("key2"),
- r2.getProperty("key2"));
-
+ assertEquals("Properties are not equal",r1.getProperty("key1"),r2.getProperty("key1"));
+ assertEquals("Properties are not equal",r1.getProperty("key2"),r2.getProperty("key2"));
assertEquals("File content is not matching", new String((byte[])r1.getContent()),
- new String((byte[])r2.getContent()));
-
+ new String((byte[])r2.getContent()));
assertTrue(c1.getText() + " is not associated for resource"+ path,
- containsComment(commentPath,c1.getText()));
-
+ containsComment(commentPath,c1.getText()));
assertTrue(c2.getText() + " is not associated for resource"+ path,
- containsComment(commentPath,c2.getText()));
-
+ containsComment(commentPath,c2.getText()));
assertTrue("Tag1 is not exist",containsTag(path,"tag1"));
assertTrue("Tag2 is not exist",containsTag(path,"tag2"));
assertTrue("Tag3 is not exist",containsTag(path,"tag3"));
float rating = registry.getAverageRating(path);
- assertEquals("Rating is not mathching", rating, (float)4.0,
- (float)0.01);
-
- assertEquals("Media type not exist",r1.getMediaType(),
- r2.getMediaType());
+ assertEquals("Rating is not mathching", rating, (float)4.0,(float)0.01);
+ assertEquals("Media type not exist",r1.getMediaType(),r2.getMediaType());
+ assertEquals("Authour name is not exist",r1.getAuthorUserName(),r2.getAuthorUserName());
+ assertEquals("Description is not exist",r1.getDescription(),r2.getDescription());
- assertEquals("Authour name is not exist",r1.getAuthorUserName(),
- r2.getAuthorUserName());
+ String new_path_returned;
+ new_path_returned = registry.rename(path,new_path);
- assertEquals("Description is not exist",r1.getDescription(),
- r2.getDescription());
+ assertEquals("New resource path is not equal",new_path,new_path_returned);
- registry.rename(path,new_path);
-
/*get renamed resource details*/
+
Resource r1Renamed = registry.get(new_path);
assertEquals("File content is not matching", new String((byte[])r2.getContent()),
new String((byte[])r1Renamed.getContent()));
-
assertEquals("Properties are not equal",r2.getProperty("key1"),
r1Renamed.getProperty("key1"));
-
assertEquals("Properties are not equal",r2.getProperty("key2"),
r1Renamed.getProperty("key2"));
-
assertTrue(c1.getText() + " is not associated for resource"+ new_path,
containsComment(commentPathNew,c1.getText()));
-
assertTrue(c2.getText() + " is not associated for resource"+ new_path,
containsComment(commentPathNew,c2.getText()));
-
assertTrue("Tag1 is not copied",containsTag(new_path,"tag1"));
assertTrue("Tag2 is not copied",containsTag(new_path,"tag2"));
assertTrue("Tag3 is not copied",containsTag(new_path,"tag3"));
float rating1 = registry.getAverageRating(new_path);
- assertEquals("Rating is not copied", rating1, (float)4.0,
- (float)0.01);
-
- assertEquals("Media type not copied",r2.getMediaType(),
- r1Renamed.getMediaType());
-
+ assertEquals("Rating is not copied", rating1, (float)4.0,(float)0.01);
+ assertEquals("Media type not copied",r2.getMediaType(),r1Renamed.getMediaType());
assertEquals("Authour Name is not copied",r2.getAuthorUserName(),
r1Renamed.getAuthorUserName());
-
assertEquals("Description is not exist",r2.getDescription(),r1Renamed.getDescription());
}catch (RegistryException e) {
- e.printStackTrace();
+ e.printStackTrace();
}
}
@@ -128,11 +118,11 @@
try {
- String path="/c901/c1/c2";
+ String path="/c9011/c1/c2";
String commentPath = path + ";comments";
- String new_path="/c911/c1/c3";
+ String new_path="/c9111/c1/c3";
String commentPathNew = new_path + ";comments";
- Resource r1 = registry.newResource();
+ Resource r1 = registry.newCollection();
r1.setDescription("This is a file to be renamed");
Comment c1 = new Comment();
@@ -143,10 +133,8 @@
c2.setResourcePath(path);
c2.setText("This is secound test comment");
- Properties r1Pro = new Properties();
- r1Pro.setProperty("key1", "value1");
- r1Pro.setProperty("key2", "value2");
- r1.setProperties(r1Pro);
+ r1.setProperty("key1", "value1");
+ r1.setProperty("key2", "value2");
registry.put(path,r1);
registry.addComment(path,c1);
@@ -160,26 +148,24 @@
assertEquals("Properties are not equal",r1.getProperty("key1"),
r2.getProperty("key1"));
-
assertEquals("Properties are not equal",r1.getProperty("key2"),
r2.getProperty("key2"));
-
assertTrue(c1.getText() + " is not associated for resource"+ path,
containsComment(commentPath,c1.getText()));
-
assertTrue(c2.getText() + " is not associated for resource"+ path,
containsComment(commentPath,c2.getText()));
-
assertTrue("Tag1 is not copied",containsTag(path,"tag1"));
assertTrue("Tag2 is not copied",containsTag(path,"tag2"));
assertTrue("Tag3 is not copied",containsTag(path,"tag3"));
float rating = registry.getAverageRating(path);
- assertEquals("Rating is not mathching", rating, (float)4.0,
- (float)0.01);
+ assertEquals("Rating is not mathching", rating, (float)4.0,(float)0.01);
assertEquals("Authour name is not exist",r1.getAuthorUserName(),r2.getAuthorUserName());
- registry.rename(path,new_path);
+ String new_path_returned;
+ new_path_returned = registry.rename(path,new_path);
+
+ assertEquals("New resource path is not equal",new_path,new_path_returned);
/*get renamed resource details*/
@@ -187,26 +173,20 @@
assertEquals("Properties are not equal",r2.getProperty("key1"),
r1Renamed.getProperty("key1"));
-
assertEquals("Properties are not equal",r2.getProperty("key2"),
r1Renamed.getProperty("key2"));
-
assertTrue(c1.getText() + " is not associated for resource"+ new_path,
containsComment(commentPathNew,c1.getText()));
-
assertTrue(c2.getText() + " is not associated for resource"+ new_path,
containsComment(commentPathNew,c2.getText()));
-
assertTrue("Tag1 is not copied",containsTag(new_path,"tag1"));
- //assertTrue("Tag2 is not copied",containsTag(new_path,"tag2"));
- //assertTrue("Tag3 is not copied",containsTag(new_path,"tag3"));
+ assertTrue("Tag2 is not copied",containsTag(new_path,"tag2"));
+ assertTrue("Tag3 is not copied",containsTag(new_path,"tag3"));
float rating1 = registry.getAverageRating(new_path);
- assertEquals("Rating is not copied", rating1, (float)4.0,
- (float)0.01);
+ assertEquals("Rating is not copied", rating1, (float)4.0,(float)0.01);
- assertEquals("Author Name is not copied",r1.getAuthorUserName(),
- r2.getAuthorUserName());
+ assertEquals("Author Name is not copied",r1.getAuthorUserName(),r2.getAuthorUserName());
}catch (RegistryException e) {
e.printStackTrace();
More information about the Registry-dev
mailing list