Added: 
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestResourceRefType.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestResourceRefType.java?rev=1366610&view=auto
==============================================================================
--- 
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestResourceRefType.java
 (added)
+++ 
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestResourceRefType.java
 Sat Jul 28 08:37:38 2012
@@ -0,0 +1,85 @@
+/*****************************************************************************
+ * 
+ * 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.apache.padaf.xmpbox.type;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class TestResourceRefType extends AbstractStructuredTypeTester{
+
+       protected ResourceRefType structured = null;
+       
+       @Before
+       public void before () throws Exception {
+               super.before();
+               structured = new ResourceRefType(xmp);
+       }
+       
+       public TestResourceRefType (Class<? extends AbstractStructuredType> 
clz, String field,String type) {
+               super(clz, field, type);
+       }
+
+       @Override
+       protected AbstractStructuredType getStructured() {
+               return structured;
+       }
+
+       
+    @Parameters
+    public static Collection<Object[]> initializeParameters() throws Exception 
{
+       Collection<Object[]> result = new ArrayList<Object[]>();
+
+       // TODO TEST test on arrays
+//     result.add(new Object [] {ResourceRefType.class,"alternatePaths","seq 
URI"});
+       result.add(new Object [] {ResourceRefType.class,"documentID","URI"});
+       result.add(new Object [] {ResourceRefType.class,"filePath","URI"});
+       result.add(new Object [] {ResourceRefType.class,"fromPart","Part"});
+       result.add(new Object [] {ResourceRefType.class,"instanceID","URI"});
+       result.add(new Object [] 
{ResourceRefType.class,"lastModifyDate","Date"});
+       result.add(new Object [] {ResourceRefType.class,"manager","AgentName"});
+       result.add(new Object [] 
{ResourceRefType.class,"managerVariant","Text"});
+       result.add(new Object [] {ResourceRefType.class,"manageTo","URI"});
+       result.add(new Object [] {ResourceRefType.class,"manageUI","URI"});
+       result.add(new Object [] 
{ResourceRefType.class,"maskMarkers","Choice"});
+       result.add(new Object [] {ResourceRefType.class,"partMapping","Text"});
+       result.add(new Object [] 
{ResourceRefType.class,"renditionClass","RenditionClass"});
+       result.add(new Object [] 
{ResourceRefType.class,"renditionParams","Text"});
+       result.add(new Object [] {ResourceRefType.class,"toPart","Part"});
+       result.add(new Object [] {ResourceRefType.class,"versionID","Text"});
+       
+       return result;
+       
+    }
+
+
+    
+       
+       
+    
+       
+}

Copied: 
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestSimpleMetadataProperties.java
 (from r1355678, 
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/SimpleMetadataPropertyTest.java)
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestSimpleMetadataProperties.java?p2=pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestSimpleMetadataProperties.java&p1=pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/SimpleMetadataPropertyTest.java&r1=1355678&r2=1366610&rev=1366610&view=diff
==============================================================================
--- 
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/SimpleMetadataPropertyTest.java
 (original)
+++ 
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestSimpleMetadataProperties.java
 Sat Jul 28 08:37:38 2012
@@ -43,7 +43,7 @@ import org.w3c.dom.Element;
  * @author a183132
  * 
  */
-public class SimpleMetadataPropertyTest {
+public class TestSimpleMetadataProperties {
 
        protected XMPMetadata parent;
 
@@ -59,7 +59,7 @@ public class SimpleMetadataPropertyTest 
         */
        @Test(expected = IllegalArgumentException.class)
        public void testBooleanBadTypeDetection() {
-               new BooleanType(parent, "test", "booleen", "Not a Boolean");
+               new BooleanType(parent, null, "test", "booleen", "Not a 
Boolean");
        }
 
        /**
@@ -69,7 +69,7 @@ public class SimpleMetadataPropertyTest 
         */
        @Test(expected = IllegalArgumentException.class)
        public void testDateBadTypeDetection() {
-               new DateType(parent, "test", "date", "Bad Date");
+               new DateType(parent, null, "test", "date", "Bad Date");
        }
 
        /**
@@ -79,7 +79,7 @@ public class SimpleMetadataPropertyTest 
         */
        @Test(expected = IllegalArgumentException.class)
        public void testIntegerBadTypeDetection() {
-               new IntegerType(parent, "test", "integer", "Not an int");
+               new IntegerType(parent, null,"test", "integer", "Not an int");
        }
 
        /**
@@ -89,7 +89,7 @@ public class SimpleMetadataPropertyTest 
         */
        @Test(expected = IllegalArgumentException.class)
        public void testRealBadTypeDetection() throws Exception {
-               new RealType(parent, "test", "real", "Not a real");
+               new RealType(parent, null,"test", "real", "Not a real");
        }
 
        /**
@@ -99,7 +99,7 @@ public class SimpleMetadataPropertyTest 
         */
        @Test(expected = IllegalArgumentException.class)
        public void testTextBadTypeDetection() throws Exception {
-               new TextType(parent, "test", "text", Calendar.getInstance());
+               new TextType(parent, null,"test", "text", 
Calendar.getInstance());
        }
 
        /**
@@ -114,12 +114,12 @@ public class SimpleMetadataPropertyTest 
                int integerv = 1;
                float realv = Float.parseFloat("1.69");
                String textv = "TEXTCONTENT";
-               BooleanType bool = new BooleanType(parent, "test", "booleen", 
boolv);
-               DateType date = new DateType(parent, "test", "date", datev);
-               IntegerType integer = new IntegerType(parent, "test", "integer",
+               BooleanType bool = new BooleanType(parent, null, "test", 
"booleen", boolv);
+               DateType date = new DateType(parent, null,"test", "date", 
datev);
+               IntegerType integer = new IntegerType(parent, null, "test", 
"integer",
                                integerv);
-               RealType real = new RealType(parent, "test", "real", realv);
-               TextType text = new TextType(parent, "test", "text", textv);
+               RealType real = new RealType(parent, null, "test", "real", 
realv);
+               TextType text = new TextType(parent, null,"test", "text", 
textv);
 
                Assert.assertEquals(bool.getNamespace(), bool.getElement()
                                .getNamespaceURI());
@@ -142,12 +142,12 @@ public class SimpleMetadataPropertyTest 
         */
        @Test
        public void testObjectCreationFromJavaType() throws Exception {
-               BooleanType bool = new BooleanType(parent, "test", "booleen", 
true);
-               DateType date = new DateType(parent, "test", "date", Calendar
+               BooleanType bool = new BooleanType(parent, null,"test", 
"booleen", true);
+               DateType date = new DateType(parent, null, "test", "date", 
Calendar
                                .getInstance());
-               IntegerType integer = new IntegerType(parent, "test", 
"integer", 1);
-               RealType real = new RealType(parent, "test", "real", (float) 
1.6);
-               TextType text = new TextType(parent, "test", "text", "TEST");
+               IntegerType integer = new IntegerType(parent,null, "test", 
"integer", 1);
+               RealType real = new RealType(parent, null,"test", "real", 
(float) 1.6);
+               TextType text = new TextType(parent, null,"test", "text", 
"TEST");
 
                Element e = parent.getFuturOwner().createElement("TEST");
                parent.getFuturOwner().appendChild(e);
@@ -174,12 +174,12 @@ public class SimpleMetadataPropertyTest 
                String realv = "1.92";
                String textv = "text";
 
-               BooleanType bool = new BooleanType(parent, "test", "booleen", 
boolv);
-               DateType date = new DateType(parent, "test", "date", datev);
-               IntegerType integer = new IntegerType(parent, "test", "integer",
+               BooleanType bool = new BooleanType(parent, null, "test", 
"booleen", boolv);
+               DateType date = new DateType(parent, null,"test", "date", 
datev);
+               IntegerType integer = new IntegerType(parent,null, "test", 
"integer",
                                integerv);
-               RealType real = new RealType(parent, "test", "real", realv);
-               TextType text = new TextType(parent, "test", "text", textv);
+               RealType real = new RealType(parent, null, "test", "real", 
realv);
+               TextType text = new TextType(parent, null,"test", "text", 
textv);
 
                Assert.assertEquals(boolv, bool.getStringValue());
                Assert.assertEquals(datev, date.getStringValue());
@@ -239,7 +239,7 @@ public class SimpleMetadataPropertyTest 
        @Test
        public void testAttribute() throws Exception {
 
-               IntegerType integer = new IntegerType(parent, "test", 
"integer", 1);
+               IntegerType integer = new IntegerType(parent,null, "test", 
"integer", 1);
                Attribute value = new Attribute("http://www.test.org/test/";, 
"test",
                                "value1", "StringValue1");
                Attribute value2 = new Attribute(null, "test", "value2", 
"StringValue2");

Added: 
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestThumbnailType.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestThumbnailType.java?rev=1366610&view=auto
==============================================================================
--- 
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestThumbnailType.java
 (added)
+++ 
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestThumbnailType.java
 Sat Jul 28 08:37:38 2012
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * 
+ * 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.apache.padaf.xmpbox.type;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class TestThumbnailType extends AbstractStructuredTypeTester{
+
+       protected ThumbnailType structured = null;
+       
+       @Before
+       public void before () throws Exception {
+               super.before();
+               structured = new ThumbnailType(xmp);
+       }
+       
+       public TestThumbnailType (Class<? extends AbstractStructuredType> clz, 
String field,String type) {
+               super(clz, field, type);
+       }
+
+       @Override
+       protected AbstractStructuredType getStructured() {
+               return structured;
+       }
+
+       
+    @Parameters
+    public static Collection<Object[]> initializeParameters() throws Exception 
{
+       Collection<Object[]> result = new ArrayList<Object[]>();
+
+       result.add(new Object [] {ThumbnailType.class,"format","Choice"});
+       result.add(new Object [] {ThumbnailType.class,"height","Integer"});
+       result.add(new Object [] {ThumbnailType.class,"width","Integer"});
+       result.add(new Object [] {ThumbnailType.class,"image","Text"});
+       
+       return result;
+       
+    }
+
+
+    
+       
+       
+    
+       
+}

Added: 
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestVersionType.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestVersionType.java?rev=1366610&view=auto
==============================================================================
--- 
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestVersionType.java
 (added)
+++ 
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestVersionType.java
 Sat Jul 28 08:37:38 2012
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * 
+ * 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.apache.padaf.xmpbox.type;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class TestVersionType extends AbstractStructuredTypeTester{
+
+       protected VersionType structured = null;
+       
+       @Before
+       public void before () throws Exception {
+               super.before();
+               structured = new VersionType(xmp);
+       }
+       
+       public TestVersionType (Class<? extends AbstractStructuredType> clz, 
String field,String type) {
+               super(clz, field, type);
+       }
+
+       @Override
+       protected AbstractStructuredType getStructured() {
+               return structured;
+       }
+
+       
+    @Parameters
+    public static Collection<Object[]> initializeParameters() throws Exception 
{
+       Collection<Object[]> result = new ArrayList<Object[]>();
+
+       result.add(new Object [] {VersionType.class,"version","Text"});
+       result.add(new Object [] {VersionType.class,"comments","Text"});
+       result.add(new Object [] {VersionType.class,"modifyDate","Date"});
+       result.add(new Object [] {VersionType.class,"modifier","ProperName"});
+       
+       return result;
+       
+    }
+
+
+    
+       
+       
+    
+       
+}

Added: 
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TypeTestingHelper.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TypeTestingHelper.java?rev=1366610&view=auto
==============================================================================
--- 
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TypeTestingHelper.java
 (added)
+++ 
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TypeTestingHelper.java
 Sat Jul 28 08:37:38 2012
@@ -0,0 +1,109 @@
+ /*****************************************************************************
+ * 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.apache.padaf.xmpbox.type;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+import java.util.Random;
+import java.util.UUID;
+
+import org.apache.padaf.xmpbox.schema.PropertyType;
+
+public final class TypeTestingHelper {
+
+       
+    public static String calculateSimpleGetter (String name) {
+       StringBuilder sb = new StringBuilder(3+name.length());
+       sb.append("get").append(calculateFieldNameForMethod(name));
+       return sb.toString();
+    }
+
+    public static String calculateArrayGetter (String name) {
+       StringBuilder sb = new StringBuilder(4+name.length());
+       String fn = calculateFieldNameForMethod(name);
+       sb.append("get").append(fn);
+       if (!fn.endsWith("s")) {
+               sb.append("s");
+       }
+       return sb.toString();
+    }
+
+    public static String calculateSimpleSetter (String name) {
+       StringBuilder sb = new StringBuilder(3+name.length());
+       sb.append("set").append(calculateFieldNameForMethod(name));
+       return sb.toString();
+    }
+    
+    public static String calculateFieldNameForMethod (String name) {
+       StringBuilder sb = new StringBuilder(name.length());
+       sb.append(name.substring(0, 1).toUpperCase()).append(name.substring(1));
+       return sb.toString();
+    }
+
+    
+    public static Class<?> getJavaType (TypeDescription td) {
+       if (td.getTypeClass()==TextType.class) {
+               return String.class;
+       } else if (td.getTypeClass()==DateType.class) {
+               return Calendar.class;
+       } else if (td.getTypeClass()==IntegerType.class) {
+               return Integer.class;
+       } else if (TextType.class.isAssignableFrom(td.getTypeClass())) {
+               return String.class;
+       } else {
+               throw new IllegalArgumentException("TODO : type not expected in 
test : "+td.getTypeClass());
+       }
+    }
+    
+    public static Object getJavaValue (TypeDescription td) {
+       if (td.getTypeClass()==TextType.class) {
+               return UUID.randomUUID().toString();
+       } else if (td.getTypeClass()==DateType.class) {
+               // use random because test are too fast (generate same calendar 
twice)
+               Calendar calendar = Calendar.getInstance();
+               Random rand = new Random();
+               calendar.setTimeInMillis(rand.nextLong());
+               return calendar;
+       } else if (td.getTypeClass()==IntegerType.class) {
+               return new Integer(14);
+       } else if (TextType.class.isAssignableFrom(td.getTypeClass())) {
+               // all derived from TextType
+               return UUID.randomUUID().toString();
+       } else {
+               throw new IllegalArgumentException("TODO : type not expected in 
test : "+td.getTypeClass());
+       }
+    }
+
+       public static List<Field> getXmpFields (Class<?> clz) {
+               Field [] fields = clz.getFields();
+               List<Field> result = new ArrayList<Field>(fields.length);
+               for (Field field : fields) {
+                       if (field.getAnnotation(PropertyType.class)!=null) {
+                               result.add(field);
+                       }
+               }
+               return result;
+       }
+
+    
+}


Reply via email to