You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by gb...@apache.org on 2012/07/28 10:37:39 UTC
svn commit: r1366610 [1/2] - in
/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox: ./ parser/
schema/ type/
Author: gbailleul
Date: Sat Jul 28 08:37:38 2012
New Revision: 1366610
URL: http://svn.apache.org/viewvc?rev=1366610&view=rev
Log:
PDFBOX-1343 : rework on unitary tests
Added:
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractSchemaTester.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/BasicJobTicketSchemaTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/PhotoshopSchemaTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/AbstractStructuredTypeTester.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestAbstractStructuredType.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestDerivedType.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestJobType.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestLayerType.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestResourceEventType.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestResourceRefType.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestSimpleMetadataProperties.java
- copied, changed from r1355678, pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/SimpleMetadataPropertyTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestThumbnailType.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestVersionType.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TypeTestingHelper.java
Removed:
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/ComplexMetadataPropertyTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/SimpleMetadataPropertyTest.java
Modified:
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/BirthCertificateSchemaWithXMLDescriptions.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/XMPMetaDataTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/DeserializationTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractXMPSchemaTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/DublinCoreTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPBasicTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPMediaManagementTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPSchemaTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XmpRightsSchemaTest.java
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/BirthCertificateSchemaWithXMLDescriptions.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/BirthCertificateSchemaWithXMLDescriptions.java?rev=1366610&r1=1366609&r2=1366610&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/BirthCertificateSchemaWithXMLDescriptions.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/BirthCertificateSchemaWithXMLDescriptions.java Sat Jul 28 08:37:38 2012
@@ -24,7 +24,6 @@ package org.apache.padaf.xmpbox;
import java.util.Calendar;
import java.util.Iterator;
-import org.apache.padaf.xmpbox.XMPMetadata;
import org.apache.padaf.xmpbox.schema.PropertyExtensionDefinition;
import org.apache.padaf.xmpbox.schema.PropertyType;
import org.apache.padaf.xmpbox.schema.SchemaExtensionDefinition;
@@ -78,7 +77,7 @@ public class BirthCertificateSchemaWithX
}
public void addLastname(String ln) {
- this.addSequenceValueAsSimple(LAST_NAME, ln);
+ this.addUnqualifiedSequenceValue(LAST_NAME, ln);
}
public void setBirthPlace(String city) {
@@ -94,21 +93,21 @@ public class BirthCertificateSchemaWithX
}
public String getFirstname() {
- return this.getTextProperty(localPrefixSep + FIRST_NAME)
+ return this.getUnqualifiedTextProperty(FIRST_NAME)
.getStringValue();
}
public String getLastname() {
- return this.getTextProperty(localPrefixSep + LAST_NAME)
+ return this.getUnqualifiedTextProperty(LAST_NAME)
.getStringValue();
}
public void setMailaddr(String name, String domain) {
- ComplexPropertyContainer field = new ComplexPropertyContainer(metadata,
- localPrefix, MAIL_ADR);
+ ComplexPropertyContainer field = new ComplexPropertyContainer(getMetadata(),null,
+ getLocalPrefix(), MAIL_ADR);
field.setAttribute(new Attribute(null, "rdf", "parseType", "Resource"));
- TextType namePart = new TextType(metadata, "madn", "name", name);
- TextType domainPart = new TextType(metadata, "madn", "domain", domain);
+ TextType namePart = new TextType(getMetadata(), null, "madn", "name", name);
+ TextType domainPart = new TextType(getMetadata(), null, "madn", "domain", domain);
field.addProperty(namePart);
field.addProperty(domainPart);
addProperty(field);
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/XMPMetaDataTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/XMPMetaDataTest.java?rev=1366610&r1=1366609&r2=1366610&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/XMPMetaDataTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/XMPMetaDataTest.java Sat Jul 28 08:37:38 2012
@@ -50,22 +50,22 @@ public class XMPMetaDataTest {
metadata = new XMPMetadata();
String tmpNsURI = "http://www.test.org/schem/";
tmp = new XMPSchema(metadata, "test", tmpNsURI);
- tmp.addBagValue("test:BagContainer", "Value1");
- tmp.addBagValue("test:BagContainer", "Value2");
- tmp.addBagValue("test:BagContainer", "Value3");
-
- tmp.addSequenceValue("test:SeqContainer", "Value1");
- tmp.addSequenceValue("test:SeqContainer", "Value2");
- tmp.addSequenceValue("test:SeqContainer", "Value3");
+ tmp.addQualifiedBagValue("BagContainer", "Value1");
+ tmp.addQualifiedBagValue("BagContainer", "Value2");
+ tmp.addQualifiedBagValue("BagContainer", "Value3");
+
+ tmp.addUnqualifiedSequenceValue("SeqContainer", "Value1");
+ tmp.addUnqualifiedSequenceValue("SeqContainer", "Value2");
+ tmp.addUnqualifiedSequenceValue("SeqContainer", "Value3");
tmp
- .addProperty(new TextType(metadata, "test", "simpleProperty",
+ .addProperty(new TextType(metadata, null,"test", "simpleProperty",
"YEP"));
tmp2 = new XMPSchema(metadata, "space", "http://www.space.org/schem/");
- tmp2.addSequenceValue("test:SeqSpContainer", "ValueSpace1");
- tmp2.addSequenceValue("test:SeqSpContainer", "ValueSpace2");
- tmp2.addSequenceValue("test:SeqSpContainer", "ValueSpace3");
+ tmp2.addUnqualifiedSequenceValue("SeqSpContainer", "ValueSpace1");
+ tmp2.addUnqualifiedSequenceValue("SeqSpContainer", "ValueSpace2");
+ tmp2.addUnqualifiedSequenceValue("SeqSpContainer", "ValueSpace3");
metadata.addSchema(tmp);
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/DeserializationTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/DeserializationTest.java?rev=1366610&r1=1366609&r2=1366610&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/DeserializationTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/parser/DeserializationTest.java Sat Jul 28 08:37:38 2012
@@ -206,7 +206,7 @@ public class DeserializationTest {
Assert.assertEquals(new Integer(162), thumb.getHeight());
Assert.assertEquals(new Integer(216), thumb.getWidth());
Assert.assertEquals("JPEG", thumb.getFormat());
- Assert.assertEquals("/9j/4AAQSkZJRgABAgEASABIAAD", thumb.getImg());
+ Assert.assertEquals("/9j/4AAQSkZJRgABAgEASABIAAD", thumb.getImage());
// PDFA Extension
// Check numbers of schema descriptions
Added: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractSchemaTester.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractSchemaTester.java?rev=1366610&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractSchemaTester.java (added)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractSchemaTester.java Sat Jul 28 08:37:38 2012
@@ -0,0 +1,207 @@
+ /*****************************************************************************
+ * 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.schema;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.padaf.xmpbox.XMPMetadata;
+import org.apache.padaf.xmpbox.type.AbstractSimpleProperty;
+import org.apache.padaf.xmpbox.type.ComplexProperty;
+import org.apache.padaf.xmpbox.type.TypeDescription;
+import org.apache.padaf.xmpbox.type.TypeMapping;
+import org.apache.padaf.xmpbox.type.TypeTestingHelper;
+import org.junit.Test;
+
+public abstract class AbstractSchemaTester {
+
+
+ protected XMPMetadata xmp;
+
+ protected String fieldName;
+
+ protected String type;
+
+ protected Cardinality cardinality;
+
+
+ protected enum Cardinality {Simple, Bag, Seq, Alt}
+
+ public void before () throws Exception {
+ xmp = new XMPMetadata();
+ }
+
+ protected abstract XMPSchema getSchema ();
+
+ protected Class<? extends XMPSchema> getSchemaClass () {
+ return getSchema().getClass();
+ }
+
+ public AbstractSchemaTester (String fieldName, String type, Cardinality card) {
+ this.fieldName = fieldName;
+ this.type = type;
+ this.cardinality = card;
+ }
+
+ @Test
+ public void testInitializedToNull() throws Exception {
+ // default method
+ Assert.assertNull(getSchema().getProperty(fieldName));
+ // accessor
+ if (cardinality==Cardinality.Simple) {
+ String getter = TypeTestingHelper.calculateSimpleGetter(fieldName);
+ Method get = getSchemaClass().getMethod(getter, new Class[0]);
+ Object result = get.invoke(getSchema(), new Object [0]);
+ Assert.assertNull(result);
+ } else {
+ // arrays
+ String getter = TypeTestingHelper.calculateArrayGetter(fieldName);
+ Method get = getSchemaClass().getMethod(getter, new Class[0]);
+ Object result = get.invoke(getSchema(), new Object [0]);
+ Assert.assertNull(result);
+ }
+
+ }
+
+ @Test
+ public void testSettingValue() throws Exception {
+ if (cardinality!=Cardinality.Simple) return;
+ // only test simple properties
+ TypeDescription td =TypeMapping.getTypeDescription(type);
+ Object value = TypeTestingHelper.getJavaValue(td);
+ AbstractSimpleProperty property = getSchema().instanciateSimple(fieldName, value);
+ getSchema().addProperty(property);
+ String qn = getPropertyQualifiedName(fieldName);
+ Assert.assertNotNull(getSchema().getProperty(qn));
+ // check other properties not modified
+ List<Field> fields = TypeTestingHelper.getXmpFields(getSchemaClass());
+ for (Field field : fields) {
+ // do not check the current name
+ String fqn = getPropertyQualifiedName(field.get(null).toString());
+ if (!fqn.equals(qn)) {
+ Assert.assertNull(getSchema().getProperty(fqn));
+ }
+ }
+ }
+
+ @Test
+ public void testSettingValueInArray() throws Exception {
+ if (cardinality==Cardinality.Simple) return;
+ // only test array properties
+ TypeDescription td =TypeMapping.getTypeDescription(type);
+ Object value = TypeTestingHelper.getJavaValue(td);
+ AbstractSimpleProperty property = getSchema().instanciateSimple(fieldName, value);
+ switch (cardinality) {
+ case Seq:
+ getSchema().addUnqualifiedSequenceValue(property.getPropertyName(), property);
+ break;
+ case Bag:
+ getSchema().addBagValue(property.getQualifiedName(), property);
+ break;
+ default :
+ throw new Exception ("Unexpected case in test : "+cardinality.name());
+ }
+ String qn = getPropertyQualifiedName(fieldName);
+ Assert.assertNotNull(getSchema().getProperty(qn));
+ // check other properties not modified
+ List<Field> fields = TypeTestingHelper.getXmpFields(getSchemaClass());
+ for (Field field : fields) {
+ // do not check the current name
+ String fqn = getPropertyQualifiedName(field.get(null).toString());
+ if (!fqn.equals(qn)) {
+ Assert.assertNull(getSchema().getProperty(fqn));
+ }
+ }
+ }
+
+
+ @Test
+ public void testPropertySetterSimple () throws Exception {
+ if (cardinality!=Cardinality.Simple) return;
+ String setter = TypeTestingHelper.calculateSimpleSetter(fieldName)+"Property";
+ TypeDescription td = TypeMapping.getTypeDescription(type);
+ Object value = TypeTestingHelper.getJavaValue(td);
+ AbstractSimpleProperty asp = TypeMapping.instanciateSimpleProperty(
+ xmp, getSchema().getNamespaceValue(),
+ getSchema().getLocalPrefix(), fieldName, value, type);
+ Method set = getSchemaClass().getMethod(setter, new Class<?>[] {td.getTypeClass()} );
+ set.invoke(getSchema(), new Object [] {asp});
+ // check property set
+ AbstractSimpleProperty stored = (AbstractSimpleProperty)getSchema().getProperty(getPropertyQualifiedName(fieldName));
+ Assert.assertEquals(value, stored.getObjectValue());
+ // check getter
+ String getter = TypeTestingHelper.calculateSimpleGetter(fieldName)+"Property";
+ Method get = getSchemaClass().getMethod(getter, new Class[0]);
+ Object result = get.invoke(getSchema(), new Object [0]);
+ Assert.assertTrue(td.getTypeClass().isAssignableFrom(result.getClass()));
+ Assert.assertEquals(asp, result);
+ }
+
+ @Test
+ public void testPropertySetterInArray () throws Exception {
+ if (cardinality==Cardinality.Simple) return;
+ // add value
+ String setter = "add"+TypeTestingHelper.calculateFieldNameForMethod(fieldName);
+ TypeDescription td = TypeMapping.getTypeDescription(type);
+ Object value1 = TypeTestingHelper.getJavaValue(td);
+ Method set = getSchemaClass().getMethod(setter, new Class<?>[] {TypeTestingHelper.getJavaType(td)} );
+ set.invoke(getSchema(), new Object [] {value1});
+ // retrieve complex property
+ String getter = TypeTestingHelper.calculateArrayGetter(fieldName)+"Property";
+ Method getcp = getSchemaClass().getMethod(getter, new Class[0]);
+ Object ocp = getcp.invoke(getSchema(), new Object[0]);
+ Assert.assertTrue(ocp instanceof ComplexProperty);
+ ComplexProperty cp = (ComplexProperty)ocp;
+ // check size is ok (1)
+ Assert.assertEquals(1,cp.getContainer().getAllProperties().size());
+ // add a new one
+ Object value2 = TypeTestingHelper.getJavaValue(td);
+ set.invoke(getSchema(), new Object [] {value2});
+ Assert.assertEquals(2,cp.getContainer().getAllProperties().size());
+ // remove the first
+ String remover = "remove"+TypeTestingHelper.calculateFieldNameForMethod(fieldName);
+ Method remove = getSchemaClass().getMethod(remover, new Class<?>[] {TypeTestingHelper.getJavaType(td)});
+ remove.invoke(getSchema(), value1);
+ Assert.assertEquals(1,cp.getContainer().getAllProperties().size());
+
+
+// // check property set
+// AbstractSimpleProperty stored = (AbstractSimpleProperty)getSchema().getProperty(getPropertyQualifiedName(fieldName));
+// Assert.assertEquals(value, stored.getObjectValue());
+// // check getter
+// String getter = TypeTestingHelper.calculateSimpleGetter(fieldName)+"Property";
+// Method get = getSchemaClass().getMethod(getter, new Class[0]);
+// Object result = get.invoke(getSchema(), new Object [0]);
+// Assert.assertTrue(td.getTypeClass().isAssignableFrom(result.getClass()));
+// Assert.assertEquals(asp, result);
+ }
+
+
+ protected String getPropertyQualifiedName (String name) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(getSchema().getLocalPrefix()).append(":").append(name);
+ return sb.toString();
+ }
+
+}
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractXMPSchemaTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractXMPSchemaTest.java?rev=1366610&r1=1366609&r2=1366610&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractXMPSchemaTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/AbstractXMPSchemaTest.java Sat Jul 28 08:37:38 2012
@@ -31,13 +31,12 @@ import java.util.Map;
import junit.framework.Assert;
import org.apache.padaf.xmpbox.XMPMetadata;
-import org.apache.padaf.xmpbox.schema.PropertyType;
-import org.apache.padaf.xmpbox.schema.XMPSchema;
import org.apache.padaf.xmpbox.type.BooleanType;
import org.apache.padaf.xmpbox.type.DateType;
import org.apache.padaf.xmpbox.type.IntegerType;
import org.apache.padaf.xmpbox.type.TextType;
import org.apache.padaf.xmpbox.type.ThumbnailType;
+import org.apache.padaf.xmpbox.type.URIType;
import org.junit.Test;
public abstract class AbstractXMPSchemaTest {
@@ -95,6 +94,8 @@ public abstract class AbstractXMPSchemaT
// do nothing
} else if (type.equals("seq Date")) {
// do nothing
+ } else if (type.equals("seq Versions")) {
+ // do nothing
} else if (type.equals("Lang Alt")) {
// do nothing
} else if (type.equals("Alt Thumbnail")) {
@@ -103,6 +104,8 @@ public abstract class AbstractXMPSchemaT
// do nothing
} else if (type.equals("URL")) {
testGetSetTextValue();
+ } else if (type.equals("URI")) {
+ testGetSetTextValue();
} else {
throw new Exception("Unknown type : " + type);
}
@@ -110,8 +113,10 @@ public abstract class AbstractXMPSchemaT
@Test
public void testGetSetProperty() throws Exception {
- if (value instanceof String) {
+ if (type.equals("Text")) {
testGetSetTextProperty();
+ } else if (type.equals("URI")) {
+ testGetSetURIProperty();
} else if (type.equals("Boolean")) {
testGetSetBooleanProperty();
} else if (type.equals("Integer")) {
@@ -133,7 +138,7 @@ public abstract class AbstractXMPSchemaT
} else if (type.equals("Alt Thumbnail")) {
testGetSetThumbnail();
} else {
- throw new Exception("Unknown type : " + value.getClass());
+ throw new Exception("Unknown type : " + type);
}
Field[] fields = schemaClass.getFields();
for (Field field : fields) {
@@ -146,9 +151,11 @@ public abstract class AbstractXMPSchemaT
// do not check method existence
} else if (pt.propertyType().equals("ResourceRef")) {
// do not check method existence
+ } else if (pt.propertyType().equals("seq Version")) {
+ // do not check method existence
} else {
// type test
- // TODO use getMethod()
+ // TODO TEST use getMethod()
String spt = retrievePropertyType(field.get(schema).toString());
// String getNameProperty = getMethod(field.get(schema).toString());
String getNameProperty = "get" + prepareName(
@@ -206,12 +213,11 @@ public abstract class AbstractXMPSchemaT
}
else if (type.startsWith("bag ")) sb.append("s");
else if (type.startsWith("seq ")) sb.append("s");
- // TODO others
+ else if (type.startsWith("alt ")) sb.append("s");
return sb.toString();
}
protected String setMethod(String prop) {
- String fu = firstUpper(prop);
StringBuilder sb = new StringBuilder(3 + prop.length());
sb.append("set").append(prepareName(prop, type)).append("Property");
return sb.toString();
@@ -239,7 +245,6 @@ public abstract class AbstractXMPSchemaT
}
protected String getValueMethod(String prop) {
- String fu = firstUpper(prop);
StringBuilder sb = new StringBuilder(8 + prop.length());
sb.append("get").append(prepareName(prop, type));
return sb.toString();
@@ -257,7 +262,7 @@ public abstract class AbstractXMPSchemaT
String setName = setMethod(property);
String getName = getMethod(property);
- BooleanType bt = new BooleanType(metadata, schema.getLocalPrefix(),
+ BooleanType bt = new BooleanType(metadata,null, schema.getLocalPrefix(),
property, value);
Method setMethod = schemaClass.getMethod(setName, BooleanType.class);
Method getMethod = schemaClass.getMethod(getName);
@@ -272,7 +277,7 @@ public abstract class AbstractXMPSchemaT
String setName = setMethod(property);
String getName = getMethod(property);
- DateType dt = new DateType(metadata, schema.getLocalPrefix(), property,
+ DateType dt = new DateType(metadata, null, schema.getLocalPrefix(), property,
value);
Method setMethod = schemaClass.getMethod(setName, DateType.class);
Method getMethod = schemaClass.getMethod(getName);
@@ -286,7 +291,7 @@ public abstract class AbstractXMPSchemaT
String setName = setMethod(property);
String getName = getMethod(property);
- IntegerType it = new IntegerType(metadata, schema.getLocalPrefix(),
+ IntegerType it = new IntegerType(metadata, null,schema.getLocalPrefix(),
property, value);
Method setMethod = schemaClass.getMethod(setName, IntegerType.class);
Method getMethod = schemaClass.getMethod(getName);
@@ -300,7 +305,7 @@ public abstract class AbstractXMPSchemaT
String setName = setMethod(property);
String getName = getMethod(property);
- TextType tt = new TextType(metadata, schema.getLocalPrefix(), property,
+ TextType tt = new TextType(metadata, null,schema.getLocalPrefix(), property,
(String)value);
Method setMethod = schemaClass.getMethod(setName, TextType.class);
Method getMethod = schemaClass.getMethod(getName);
@@ -311,6 +316,22 @@ public abstract class AbstractXMPSchemaT
}
+ protected void testGetSetURIProperty() throws Exception {
+ String setName = setMethod(property);
+ String getName = getMethod(property);
+
+ URIType tt = new URIType(metadata, null,schema.getLocalPrefix(), property,
+ (String)value);
+ Method setMethod = schemaClass.getMethod(setName, URIType.class);
+ Method getMethod = schemaClass.getMethod(getName);
+
+ setMethod.invoke(schema, tt);
+ String found = ((TextType) getMethod.invoke(schema)).getStringValue();
+ Assert.assertEquals(value, found);
+
+ }
+
+
protected void testGetSetTextListValue(String tp) throws Exception {
String setName = addToValueMethod(property);
String getName = getValueMethod(property);
@@ -373,7 +394,7 @@ public abstract class AbstractXMPSchemaT
Assert.assertEquals(height, t1.getHeight());
Assert.assertEquals(width, t1.getWidth());
Assert.assertEquals(format, t1.getFormat());
- Assert.assertEquals(img, t1.getImg());
+ Assert.assertEquals(img, t1.getImage());
}
Added: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/BasicJobTicketSchemaTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/BasicJobTicketSchemaTest.java?rev=1366610&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/BasicJobTicketSchemaTest.java (added)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/BasicJobTicketSchemaTest.java Sat Jul 28 08:37:38 2012
@@ -0,0 +1,143 @@
+ /*****************************************************************************
+ * 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.schema;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import junit.framework.Assert;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.padaf.xmpbox.SaveMetadataHelper;
+import org.apache.padaf.xmpbox.XMPMetadata;
+import org.apache.padaf.xmpbox.parser.XMPDocumentBuilder;
+import org.apache.padaf.xmpbox.parser.XmpExpectedRdfAboutAttribute;
+import org.apache.padaf.xmpbox.parser.XmpParsingException;
+import org.apache.padaf.xmpbox.parser.XmpSchemaException;
+import org.apache.padaf.xmpbox.parser.XmpUnknownValueTypeException;
+import org.apache.padaf.xmpbox.parser.XmpXpacketEndException;
+import org.apache.padaf.xmpbox.type.BadFieldValueException;
+import org.apache.padaf.xmpbox.type.JobType;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class BasicJobTicketSchemaTest {
+
+ protected static XMPDocumentBuilder builder;
+
+ @BeforeClass
+ public static void bc () throws Exception {
+ builder = new XMPDocumentBuilder();
+ }
+
+ private InputStream transfer(ByteArrayOutputStream out) {
+ IOUtils.closeQuietly(out);
+ ByteArrayInputStream bis = new ByteArrayInputStream(out.toByteArray());
+ return bis;
+ }
+
+ private XMPMetadata parse (InputStream is ) throws BadFieldValueException, XmpParsingException, XmpSchemaException, XmpUnknownValueTypeException, XmpExpectedRdfAboutAttribute, XmpXpacketEndException {
+ return builder.parse(is);
+ }
+
+ private XMPMetadata parse (ByteArrayOutputStream os ) throws Exception {
+ InputStream is = transfer(os);
+ return builder.parse(is);
+
+ }
+
+ @Test
+ public void testAddTwoJobs() throws Exception {
+
+ XMPMetadata xmpMetadata = new XMPMetadata();
+ XMPBasicJobTicketSchema basic = xmpMetadata.createAndAddBasicJobTicketSchema();
+
+ basic.addJob("zeid1", "zename1", "zeurl1","aaa");
+ basic.addJob("zeid2", "zename2", "zeurl2");
+
+// SaveMetadataHelper.serialize(xmpMetadata, System.out);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ SaveMetadataHelper.serialize(xmpMetadata, bos);
+ XMPMetadata rxmp = parse(bos);
+
+ XMPBasicJobTicketSchema jt = rxmp.getBasicJobTicketSchema();
+ Assert.assertNotNull(jt);
+ Assert.assertEquals(2, jt.getJobs().size());
+
+ }
+
+ @Test
+ public void testAddWithDefaultPrefix() throws Exception {
+
+ XMPMetadata xmpMetadata = new XMPMetadata();
+ XMPBasicJobTicketSchema basic = xmpMetadata.createAndAddBasicJobTicketSchema();
+
+ basic.addJob("zeid2", "zename2", "zeurl2");
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ SaveMetadataHelper.serialize(xmpMetadata, bos);
+ XMPMetadata rxmp = parse(bos);
+
+ XMPBasicJobTicketSchema jt = rxmp.getBasicJobTicketSchema();
+ Assert.assertNotNull(jt);
+ Assert.assertEquals(1, jt.getJobs().size());
+
+ JobType job = jt.getJobs().get(0);
+ Assert.assertEquals("zeid2", job.getId());
+ Assert.assertEquals("zename2", job.getName());
+ Assert.assertEquals("zeurl2", job.getUrl());
+ Assert.assertEquals(JobType.ELEMENT_NS, job.getFieldsNamespace());
+ Assert.assertEquals(JobType.PREFERED_PREFIX, job.getFieldPrefix());
+
+ }
+
+// @Test
+ public void testAddWithDefinedPrefix() throws Exception {
+
+ XMPMetadata xmpMetadata = new XMPMetadata();
+ XMPBasicJobTicketSchema basic = xmpMetadata.createAndAddBasicJobTicketSchema();
+
+ basic.addJob("zeid2", "zename2", "zeurl2","aaa");
+
+ SaveMetadataHelper.serialize(xmpMetadata, System.out);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ SaveMetadataHelper.serialize(xmpMetadata, bos);
+ XMPMetadata rxmp = parse(bos);
+
+ XMPBasicJobTicketSchema jt = rxmp.getBasicJobTicketSchema();
+ Assert.assertNotNull(jt);
+ Assert.assertEquals(1, jt.getJobs().size());
+
+ JobType job = jt.getJobs().get(0);
+// SaveMetadataHelper.serialize(rxmp, System.out);
+
+ Assert.assertEquals("zeid2", job.getId());
+ Assert.assertEquals("zename2", job.getName());
+ Assert.assertEquals("zeurl2", job.getUrl());
+ Assert.assertEquals(JobType.ELEMENT_NS, job.getFieldsNamespace());
+ Assert.assertEquals("aaa", job.getFieldPrefix());
+
+ }
+
+}
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/DublinCoreTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/DublinCoreTest.java?rev=1366610&r1=1366609&r2=1366610&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/DublinCoreTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/DublinCoreTest.java Sat Jul 28 08:37:38 2012
@@ -1,5 +1,4 @@
-/*****************************************************************************
- *
+ /*****************************************************************************
* 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
@@ -22,78 +21,101 @@
package org.apache.padaf.xmpbox.schema;
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.padaf.xmpbox.XMPMetadata;
-import org.apache.padaf.xmpbox.schema.DublinCoreSchema;
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 DublinCoreTest extends AbstractXMPSchemaTest {
+public class DublinCoreTest extends AbstractSchemaTester {
+ protected DublinCoreSchema schema = null;
+
+ public DublinCoreSchema getSchema () {
+ return schema;
+ }
+
@Before
- public void initTempMetaData() throws Exception {
- metadata = new XMPMetadata();
- schema = metadata.createAndAddDublinCoreSchema();
- schemaClass = DublinCoreSchema.class;
+ public void before() throws Exception {
+ super.before();
+ schema = xmp.createAndAddDublinCoreSchema();
+ }
+
+ public DublinCoreTest(String fieldName, String type, Cardinality card) {
+ super(fieldName, type, card);
}
@Parameters
public static Collection<Object[]> initializeParameters() throws Exception {
- List<Object[]> data = new ArrayList<Object[]>();
- data.add(wrapProperty("contributor", "bag Text", new String[] {
- "contri 1", "contri 2" }));
- data.add(wrapProperty("coverage", "Text", "scope of the resource"));
- data.add(wrapProperty("creator", "seq Text", new String[] {
- "creator 1", "creator 2", "creator 3" }));
- data.add(wrapProperty("date", "seq Date", new Calendar[] { Calendar
- .getInstance() }));
-
- Map<String, String> desc = new HashMap<String, String>(2);
- desc.put("fr", "en français");
- desc.put("en", "in english");
- data.add(wrapProperty("description", "Lang Alt", desc));
-
- data.add(wrapProperty("format", "Text", "text/html"));
- data.add(wrapProperty("identifier", "Text", "my id"));
- data.add(wrapProperty("language", "bag Text", new String[] { "fr",
- "en", "es" }));
- data.add(wrapProperty("publisher", "bag Text", new String[] { "pub1",
- "pub2" }));
- data.add(wrapProperty("relation", "bag Text", new String[] { "rel1",
- "relation 2" }));
-
- Map<String, String> rights = new HashMap<String, String>(2);
- rights.put("fr", "protégé");
- rights.put("en", "protected");
- data.add(wrapProperty("rights", "Lang Alt", rights));
-
- data.add(wrapProperty("source", "Text", "my source"));
- data.add(wrapProperty("subject", "bag Text", new String[] { "subj1",
- "subj2" }));
-
- Map<String, String> title = new HashMap<String, String>(2);
- title.put("fr", "essai");
- title.put("en", "test");
- title.put("es", "prueba");
- data.add(wrapProperty("title", "Lang Alt", title));
-
- data.add(wrapProperty("type", "bag Text", new String[] { "text",
- "test", "dummy" }));
-
- return data;
- }
+ Collection<Object[]> result = new ArrayList<Object[]>();
- public DublinCoreTest(String property, String type, Object value) {
- super(property, type, value);
+ result.add(new Object [] {"contributor","ProperName",Cardinality.Bag});
+ result.add(new Object [] {"coverage","Text",Cardinality.Simple});
+ result.add(new Object [] {"creator","ProperName",Cardinality.Seq});
+ result.add(new Object [] {"date","Date",Cardinality.Seq});
+ // description TODO TEST lang alt
+ result.add(new Object [] {"format","MIMEType",Cardinality.Simple});
+ result.add(new Object [] {"identifier","Text",Cardinality.Simple});
+ result.add(new Object [] {"language","Locale",Cardinality.Bag});
+ result.add(new Object [] {"publisher","ProperName",Cardinality.Bag});
+ result.add(new Object [] {"relation","Text",Cardinality.Bag});
+ // rights TODO TEST lang alt
+ result.add(new Object [] {"source","Text",Cardinality.Simple});
+ result.add(new Object [] {"subject","Text",Cardinality.Bag});
+ // title TODO TEST lang alt
+ result.add(new Object [] {"type","Text",Cardinality.Bag});
+
+
+// List<Object[]> data = new ArrayList<Object[]>();
+// data.add(wrapProperty("contributor", "bag Text", new String[] {
+// "contri 1", "contri 2" }));
+// data.add(wrapProperty("coverage", "Text", "scope of the resource"));
+// data.add(wrapProperty("creator", "seq Text", new String[] {
+// "creator 1", "creator 2", "creator 3" }));
+// data.add(wrapProperty("date", "seq Date", new Calendar[] { Calendar
+// .getInstance() }));
+//
+// Map<String, String> desc = new HashMap<String, String>(2);
+// desc.put("fr", "en français");
+// desc.put("en", "in english");
+// data.add(wrapProperty("description", "Lang Alt", desc));
+//
+// data.add(wrapProperty("format", "Text", "text/html"));
+// data.add(wrapProperty("identifier", "Text", "my id"));
+// data.add(wrapProperty("language", "bag Text", new String[] { "fr",
+// "en", "es" }));
+// data.add(wrapProperty("publisher", "bag Text", new String[] { "pub1",
+// "pub2" }));
+// data.add(wrapProperty("relation", "bag Text", new String[] { "rel1",
+// "relation 2" }));
+//
+// Map<String, String> rights = new HashMap<String, String>(2);
+// rights.put("fr", "protégé");
+// rights.put("en", "protected");
+// data.add(wrapProperty("rights", "Lang Alt", rights));
+//
+// data.add(wrapProperty("source", "Text", "my source"));
+// data.add(wrapProperty("subject", "bag Text", new String[] { "subj1",
+// "subj2" }));
+//
+// Map<String, String> title = new HashMap<String, String>(2);
+// title.put("fr", "essai");
+// title.put("en", "test");
+// title.put("es", "prueba");
+// data.add(wrapProperty("title", "Lang Alt", title));
+//
+// data.add(wrapProperty("type", "bag Text", new String[] { "text",
+// "test", "dummy" }));
+//
+// return data;
+
+ return result;
}
+//
+// public DublinCoreTest(String property, String type, Object value) {
+// super(property, type, value);
+// }
}
Added: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/PhotoshopSchemaTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/PhotoshopSchemaTest.java?rev=1366610&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/PhotoshopSchemaTest.java (added)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/PhotoshopSchemaTest.java Sat Jul 28 08:37:38 2012
@@ -0,0 +1,83 @@
+ /*****************************************************************************
+ * 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.schema;
+
+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 PhotoshopSchemaTest extends AbstractSchemaTester {
+
+ protected PhotoshopSchema schema = null;
+
+ public PhotoshopSchema getSchema () {
+ return schema;
+ }
+
+ @Before
+ public void before() throws Exception {
+ super.before();
+ schema = xmp.createAndAddPhotoshopSchema();
+ }
+
+ public PhotoshopSchemaTest(String fieldName, String type, Cardinality card) {
+ super(fieldName, type, card);
+ }
+
+ @Parameters
+ public static Collection<Object[]> initializeParameters() throws Exception {
+ Collection<Object[]> result = new ArrayList<Object[]>();
+
+ result.add(new Object [] {"AncestorID","URI",Cardinality.Simple});
+// result.add(new Object [] {"LayerName","Text",Cardinality.Simple}); TODO TEST missing in schema
+// result.add(new Object [] {"LayerText","Text",Cardinality.Simple}); TODO TEST missing in schema
+ result.add(new Object [] {"AuthorsPosition","Text",Cardinality.Simple});
+ result.add(new Object [] {"CaptionWriter","ProperName",Cardinality.Simple});
+ result.add(new Object [] {"Category","Text",Cardinality.Simple});
+ result.add(new Object [] {"City","Text",Cardinality.Simple});
+ result.add(new Object [] {"ColorMode","Integer",Cardinality.Simple});
+ result.add(new Object [] {"Country","Text",Cardinality.Simple});
+ result.add(new Object [] {"Credit","Text",Cardinality.Simple});
+ result.add(new Object [] {"DateCreated","Date",Cardinality.Simple});
+ // DocumentAncestors TODO TEST bag Ancestor
+ result.add(new Object [] {"Headline","Text",Cardinality.Simple});
+ result.add(new Object [] {"History","Text",Cardinality.Simple});
+ result.add(new Object [] {"ICCProfile","Text",Cardinality.Simple});
+ result.add(new Object [] {"Instructions","Text",Cardinality.Simple});
+ result.add(new Object [] {"Source","Text",Cardinality.Simple});
+ result.add(new Object [] {"State","Text",Cardinality.Simple});
+ result.add(new Object [] {"SupplementalCategories","Text",Cardinality.Bag});
+ // Layer TODO TEST structured type
+ result.add(new Object [] {"TransmissionReference","Text",Cardinality.Simple});
+ result.add(new Object [] {"Urgency","Integer",Cardinality.Simple});
+
+ // TODO TEST camera raw
+
+ return result;
+ }
+
+
+}
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPBasicTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPBasicTest.java?rev=1366610&r1=1366609&r2=1366610&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPBasicTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPBasicTest.java Sat Jul 28 08:37:38 2012
@@ -54,9 +54,9 @@ public class XMPBasicTest extends Abstra
data.add(wrapProperty("Advisory", "bag Xpath", new String[] { "xpath1",
"xpath2" }));
- data.add(wrapProperty("BaseURL", "URL", "URL"));
+// data.add(wrapProperty("BaseURL", "URL", "URL"));
data.add(wrapProperty("CreateDate", "Date", Calendar.getInstance()));
- data.add(wrapProperty("CreatorTool", "Text", "CreatorTool"));
+// data.add(wrapProperty("CreatorTool", "Text", "CreatorTool"));
data.add(wrapProperty("Identifier", "bag Text", new String[] { "id1",
"id2" }));
data.add(wrapProperty("Label", "Text", "label"));
@@ -65,89 +65,11 @@ public class XMPBasicTest extends Abstra
data.add(wrapProperty("Nickname", "Text", "nick name"));
data.add(wrapProperty("Rating", "Integer", 7));
- // TODO test Thumbnail when implemented in the XMPBasicSchema
+ // TODO TEST test Thumbnail when implemented in the XMPBasicSchema
data.add(wrapProperty("Thumbnails", "Alt Thumbnail", null));
return data;
}
- // @Test
- // public void testPDFExt() throws TransformException{
- // XMPBasicSchema schem=metadata.createAndAddXMPBasicSchema();
- //
- // String xpath1="xpath1";
- // String xpath2="xpath2";
- // String url="URL";
- // Calendar createDate=Calendar.getInstance();
- // String creatorTool="CreatorTool";
- // String identifier1="id1";
- // String identifier2="id2";
- // String label="label";
- // Calendar metaDataDate=Calendar.getInstance();
- // Calendar modifyDate=Calendar.getInstance();
- // String nickname="nickname";
- // int rate=7;
- //
- // schem.addAdvisoryValue(xpath1);
- // schem.addAdvisoryValue(xpath2);
- // schem.setBaseURLValue(url);
- // schem.setCreateDateValue(createDate);
- // schem.setCreatorToolValue(creatorTool);
- // schem.addIdentifierValue(identifier1);
- // schem.addIdentifierValue(identifier2);
- // schem.setLabelValue(label);
- // schem.setMetadataDateValue(metaDataDate);
- // schem.setModifyDateValue(modifyDate);
- // schem.setNicknameValue(nickname);
- // schem.setRatingValue(rate);
- //
- // //check retrieve this schema in metadata
- // Assert.assertEquals(schem, metadata.getXMPBasicSchema());
- //
- // //check values embedded in this schema
- // Assert.assertEquals("xmp:Advisory",
- // schem.getAdvisory().getQualifiedName());
- // Assert.assertTrue(schem.getAdvisoryValues().contains(xpath1));
- // Assert.assertTrue(schem.getAdvisoryValues().contains(xpath2));
- //
- // Assert.assertEquals("xmp:BaseURL",
- // schem.getBaseURL().getQualifiedName());
- // Assert.assertEquals(url, schem.getBaseURLValue());
- //
- // Assert.assertEquals("xmp:CreateDate",
- // schem.getCreateDate().getQualifiedName());
- // Assert.assertEquals(createDate, schem.getCreateDateValue());
- //
- // Assert.assertEquals("xmp:CreatorTool",
- // schem.getCreatorTool().getQualifiedName());
- // Assert.assertEquals(creatorTool, schem.getCreatorToolValue());
- //
- // Assert.assertEquals("xmp:Identifier",
- // schem.getIdentifier().getQualifiedName());
- // Assert.assertTrue(schem.getIdentifierValues().contains(identifier1));
- // Assert.assertTrue(schem.getIdentifierValues().contains(identifier2));
- //
- // Assert.assertEquals("xmp:Label", schem.getLabel().getQualifiedName());
- // Assert.assertEquals(label, schem.getLabelValue());
- //
- // Assert.assertEquals("xmp:MetadataDate",
- // schem.getMetadataDate().getQualifiedName());
- // Assert.assertEquals(metaDataDate, schem.getMetadataDateValue());
- //
- // Assert.assertEquals("xmp:ModifyDate",
- // schem.getModifyDate().getQualifiedName());
- // Assert.assertEquals(modifyDate, schem.getModifyDateValue());
- //
- // Assert.assertEquals("xmp:Nickname",
- // schem.getNickname().getQualifiedName());
- // Assert.assertEquals(nickname, schem.getNicknameValue());
- //
- // Assert.assertEquals("xmp:Rating", schem.getRating().getQualifiedName());
- // Assert.assertEquals(rate, schem.getRatingValue());
- //
- // //SaveMetadataHelper.serialize(metadata, true, System.out);
- //
- // //TODO test Thumbnail when implemented in the XMPBasicSchema
- // }
}
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPMediaManagementTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPMediaManagementTest.java?rev=1366610&r1=1366609&r2=1366610&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPMediaManagementTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPMediaManagementTest.java Sat Jul 28 08:37:38 2012
@@ -46,20 +46,20 @@ public class XMPMediaManagementTest exte
@Parameters
public static Collection<Object[]> initializeParameters() throws Exception {
List<Object[]> data = new ArrayList<Object[]>();
- data.add(wrapProperty("DocumentID", "Text",
- "uuid:FB031973-5E75-11B2-8F06-E7F5C101C07A"));
+// data.add(wrapProperty("DocumentID", "URI",
+// "uuid:FB031973-5E75-11B2-8F06-E7F5C101C07A"));
// data.add(wrapProperty("ResourceRef", "Text", "uuid:14"));
- data.add(wrapProperty("Manager", "Text", "Raoul"));
- data.add(wrapProperty("ManageTo", "Text", "uuid:36"));
- data.add(wrapProperty("ManageUI", "Text", "uuid:3635"));
+// data.add(wrapProperty("Manager", "Text", "Raoul"));
+// data.add(wrapProperty("ManageTo", "Text", "uuid:36"));
+// data.add(wrapProperty("ManageUI", "Text", "uuid:3635"));
// data.add(wrapProperty("ManageFrom", "Text", "uuid:36"));
- data.add(wrapProperty("InstanceID", "Text", "uuid:42"));
- data.add(wrapProperty("OriginalDocumentID", "Text", "uuid:142"));
- data.add(wrapProperty("RenditionClass", "Text", "myclass"));
- data.add(wrapProperty("RenditionParams", "Text", "my params"));
- data.add(wrapProperty("VersionID", "Text", "14"));
- data.add(wrapProperty("Versions", "seq Text", new String[] { "1", "2",
- "3" }));
+// data.add(wrapProperty("InstanceID", "Text", "uuid:42"));
+// data.add(wrapProperty("OriginalDocumentID", "Text", "uuid:142"));
+// data.add(wrapProperty("RenditionClass", "Text", "myclass"));
+// data.add(wrapProperty("RenditionParams", "Text", "my params"));
+// data.add(wrapProperty("VersionID", "Text", "14"));
+// data.add(wrapProperty("Versions", "seq Text", new String[] { "1", "2",
+// "3" }));
data.add(wrapProperty("History", "seq Text", new String[] { "action 1",
"action 2", "action 3" }));
data.add(wrapProperty("Ingredients", "bag Text", new String[] {
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPSchemaTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPSchemaTest.java?rev=1366610&r1=1366609&r2=1366610&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPSchemaTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XMPSchemaTest.java Sat Jul 28 08:37:38 2012
@@ -60,18 +60,18 @@ public class XMPSchemaTest {
*/
@Test
public void testBagManagement() throws Exception {
- String bagName = "nsSchem:BAGTEST";
+ String bagName = "BAGTEST";
String value1 = "valueOne";
String value2 = "valueTwo";
- schem.addBagValue(bagName, new TextType(parent, "rdf", "li", value1));
- schem.addBagValue(bagName, value2);
+ schem.addBagValue("nsSchem:"+bagName, new TextType(parent, null,"rdf", "li", value1));
+ schem.addQualifiedBagValue(bagName, value2);
- List<String> values = schem.getBagValueList(bagName);
+ List<String> values = schem.getUnqualifiedBagValueList(bagName);
Assert.assertEquals(value1, values.get(0));
Assert.assertEquals(value2, values.get(1));
- schem.removeBagValue(bagName, value1);
- List<String> values2 = schem.getBagValueList(bagName);
+ schem.removeUnqualifiedBagValue(bagName, value1);
+ List<String> values2 = schem.getUnqualifiedBagValueList(bagName);
Assert.assertEquals(1, values2.size());
Assert.assertEquals(value2, values2.get(0));
@@ -88,14 +88,14 @@ public class XMPSchemaTest {
@Test
public void testArrayList() throws Exception {
- ComplexProperty newSeq = new ComplexProperty(parent, "nsSchem",
+ ComplexProperty newSeq = new ComplexProperty(parent, null, "nsSchem",
"seqType", ComplexProperty.ORDERED_ARRAY);
- TextType li1 = new TextType(parent, "rdf", "li", "valeur1");
- TextType li2 = new TextType(parent, "rdf", "li", "valeur2");
+ TextType li1 = new TextType(parent,null, "rdf", "li", "valeur1");
+ TextType li2 = new TextType(parent,null, "rdf", "li", "valeur2");
newSeq.getContainer().addProperty(li1);
newSeq.getContainer().addProperty(li2);
schem.addProperty(newSeq);
- List<AbstractField> list = schem.getArrayList("nsSchem:seqType");
+ List<AbstractField> list = schem.getUnqualifiedArrayList("seqType");
Assert.assertTrue(list.contains(li1));
Assert.assertTrue(list.contains(li2));
@@ -110,19 +110,19 @@ public class XMPSchemaTest {
@Test
public void testSeqManagement() throws Exception {
Calendar date = Calendar.getInstance();
- BooleanType bool = new BooleanType(parent, "rdf", "li", "True");
+ BooleanType bool = new BooleanType(parent, null, "rdf", "li", "True");
String textVal = "seqValue";
- String seqName = "nsSchem:SEQNAME";
+ String seqName = "SEQNAME";
- schem.addSequenceDateValue(seqName, date);
- schem.addSequenceValue(seqName, bool);
- schem.addSequenceValue(seqName, textVal);
+ schem.addUnqualifiedSequenceDateValue(seqName, date);
+ schem.addUnqualifiedSequenceValue(seqName, bool);
+ schem.addUnqualifiedSequenceValue(seqName, textVal);
- List<Calendar> dates = schem.getSequenceDateValueList(seqName);
+ List<Calendar> dates = schem.getUnqualifiedSequenceDateValueList(seqName);
Assert.assertEquals(1, dates.size());
Assert.assertEquals(date, dates.get(0));
- List<String> values = schem.getSequenceValueList(seqName);
+ List<String> values = schem.getUnqualifiedSequenceValueList(seqName);
Assert.assertEquals(3, values.size());
Assert.assertEquals(DateConverter.toISO8601(date), values.get(0));
Assert.assertEquals(bool.getStringValue(), values.get(1));
@@ -137,13 +137,13 @@ public class XMPSchemaTest {
* e.printStackTrace(); } System.out.println("------------------");
*/
- schem.removeSequenceDateValue(seqName, date);
- Assert.assertEquals(0, schem.getSequenceDateValueList(seqName).size());
+ schem.removeUnqualifiedSequenceDateValue(seqName, date);
+ Assert.assertEquals(0, schem.getUnqualifiedSequenceDateValueList(seqName).size());
- schem.removeSequenceValue(seqName, bool);
- schem.removeSequenceValue(seqName, textVal);
+ schem.removeUnqualifiedSequenceValue(seqName, bool);
+ schem.removeUnqualifiedSequenceValue(seqName, textVal);
- Assert.assertEquals(0, schem.getSequenceValueList(seqName).size());
+ Assert.assertEquals(0, schem.getUnqualifiedSequenceValueList(seqName).size());
}
@Test
@@ -167,11 +167,11 @@ public class XMPSchemaTest {
String val = "value";
String val2 = "value2";
schem.setTextPropertyValueAsSimple(prop, val);
- Assert.assertEquals(val, schem.getTextPropertyValueAsSimple(prop));
+ Assert.assertEquals(val, schem.getUnqualifiedTextPropertyValue(prop));
schem.setTextPropertyValueAsSimple(prop, val2);
- Assert.assertEquals(val2, schem.getTextPropertyValueAsSimple(prop));
+ Assert.assertEquals(val2, schem.getUnqualifiedTextPropertyValue(prop));
schem.setTextPropertyValueAsSimple(prop, null);
- Assert.assertNull(schem.getTextPropertyValueAsSimple(prop));
+ Assert.assertNull(schem.getUnqualifiedTextProperty(prop));
}
@Test
@@ -180,11 +180,10 @@ public class XMPSchemaTest {
String val = "value";
String val2 = "value2";
schem.setTextPropertyValueAsSimple(prop, val);
- TextType text = new TextType(parent, schem.getPrefix(), prop, "value2");
+ TextType text = new TextType(parent,null, schem.getPrefix(), prop, "value2");
schem.setTextProperty(text);
- Assert.assertEquals(val2, schem.getTextPropertyValueAsSimple(prop));
- Assert.assertEquals(text, schem.getTextProperty(schem.getPrefix() + ":"
- + prop));
+ Assert.assertEquals(val2, schem.getUnqualifiedTextPropertyValue(prop));
+ Assert.assertEquals(text, schem.getUnqualifiedTextProperty(prop));
}
@Test
@@ -215,9 +214,9 @@ public class XMPSchemaTest {
schem.setBooleanPropertyValueAsSimple(bool, boolVal);
schem.setDatePropertyValueAsSimple(date, dateVal);
schem.setIntegerPropertyValueAsSimple(integ, i);
- schem.setLanguagePropertyValueAsSimple(langprop, lang, langVal);
+ schem.setUnqualifiedLanguagePropertyValue(langprop, lang, langVal);
schem.addBagValueAsSimple(bagprop, bagVal);
- schem.addSequenceValueAsSimple(seqprop, seqPropVal);
+ schem.addUnqualifiedSequenceValue(seqprop, seqPropVal);
schem.addSequenceDateValueAsSimple(seqdate, dateVal);
Assert.assertEquals(boolVal, schem.getBooleanProperty(prefSchem + bool)
@@ -226,30 +225,28 @@ public class XMPSchemaTest {
.getValue());
Assert.assertEquals("" + i, schem.getIntegerProperty(prefSchem + integ)
.getStringValue());
- Assert.assertEquals(langVal, schem.getLanguagePropertyValue(prefSchem
- + langprop, lang));
- Assert.assertTrue(schem.getBagValueList(prefSchem + bagprop).contains(
+ Assert.assertEquals(langVal, schem.getUnqualifiedLanguagePropertyValue(langprop, lang));
+ Assert.assertTrue(schem.getUnqualifiedBagValueList(bagprop).contains(
bagVal));
- Assert.assertTrue(schem.getSequenceValueList(prefSchem + seqprop)
+ Assert.assertTrue(schem.getUnqualifiedSequenceValueList(seqprop)
.contains(seqPropVal));
- Assert.assertTrue(schem.getSequenceDateValueList(prefSchem + seqdate)
+ Assert.assertTrue(schem.getUnqualifiedSequenceDateValueList(seqdate)
.contains(dateVal));
- Assert.assertTrue(schem.getLanguagePropertyLanguagesValue(
- prefSchem + langprop).contains(lang));
+ Assert.assertTrue(schem.getUnqualifiedLanguagePropertyLanguagesValue(langprop).contains(lang));
Assert.assertEquals(boolVal, schem
.getBooleanPropertyValueAsSimple(bool).booleanValue());
Assert.assertEquals(dateVal, schem.getDatePropertyValueAsSimple(date));
Assert.assertEquals(i, schem.getIntegerPropertyValueAsSimple(integ));
- Assert.assertEquals(langVal, schem.getLanguagePropertyValueAsSimple(
+ Assert.assertEquals(langVal, schem.getUnqualifiedLanguagePropertyValue(
langprop, lang));
- Assert.assertTrue(schem.getBagValueListAsSimple(bagprop).contains(
+ Assert.assertTrue(schem.getUnqualifiedBagValueList(bagprop).contains(
bagVal));
- Assert.assertTrue(schem.getSequenceValueListAsSimple(seqprop).contains(
+ Assert.assertTrue(schem.getUnqualifiedSequenceValueList(seqprop).contains(
seqPropVal));
- Assert.assertTrue(schem.getSequenceDateValueListAsSimple(seqdate)
+ Assert.assertTrue(schem.getUnqualifiedSequenceDateValueList(seqdate)
.contains(dateVal));
- Assert.assertTrue(schem.getLanguagePropertyLanguagesValueAsSimple(
+ Assert.assertTrue(schem.getUnqualifiedLanguagePropertyLanguagesValue(
langprop).contains(lang));
}
@@ -276,21 +273,21 @@ public class XMPSchemaTest {
schem.setAbout(about);
Assert.assertEquals(about, schem.getAboutAttribute());
- String textProp = "nsSchem:textProp";
+ String textProp = "textProp";
String textPropVal = "TextPropTest";
- schem.setTextPropertyValue(textProp, textPropVal);
- Assert.assertEquals(textPropVal, schem.getTextPropertyValue(textProp));
+ schem.setTextPropertyValue("nsSchem:"+textProp, textPropVal);
+ Assert.assertEquals(textPropVal, schem.getUnqualifiedTextPropertyValue(textProp));
- TextType text = new TextType(parent, "nsSchem", "textType", "GRINGO");
+ TextType text = new TextType(parent,null, "nsSchem", "textType", "GRINGO");
schem.setTextProperty(text);
- Assert.assertEquals(text, schem.getTextProperty("nsSchem:textType"));
+ Assert.assertEquals(text, schem.getUnqualifiedTextProperty("textType"));
Calendar dateVal = Calendar.getInstance();
String date = "nsSchem:dateProp";
schem.setDatePropertyValue(date, dateVal);
Assert.assertEquals(dateVal, schem.getDatePropertyValue(date));
- DateType dateType = new DateType(parent, "nsSchem", "dateType",
+ DateType dateType = new DateType(parent, null, "nsSchem", "dateType",
Calendar.getInstance());
schem.setDateProperty(dateType);
Assert
@@ -302,7 +299,7 @@ public class XMPSchemaTest {
schem.setBooleanPropertyValue(bool, boolVal);
Assert.assertEquals(boolVal, schem.getBooleanPropertyValue(bool));
- BooleanType boolType = new BooleanType(parent, "nsSchem", "boolType",
+ BooleanType boolType = new BooleanType(parent, null,"nsSchem", "boolType",
false);
schem.setBooleanProperty(boolType);
Assert.assertEquals(boolType, schem
@@ -313,7 +310,7 @@ public class XMPSchemaTest {
schem.setIntegerPropertyValue(intProp, intPropVal);
Assert.assertEquals(intPropVal, schem.getIntegerPropertyValue(intProp));
- IntegerType intType = new IntegerType(parent, "nsSchem", "intType", 5);
+ IntegerType intType = new IntegerType(parent, null, "nsSchem", "intType", 5);
schem.setIntegerProperty(intType);
Assert.assertEquals(intType, schem
.getIntegerProperty("nsSchem:intType"));
@@ -328,7 +325,7 @@ public class XMPSchemaTest {
Assert.assertEquals(true, ok);
ok = false;
try {
- schem.getTextProperty("nsSchem:intType");
+ schem.getUnqualifiedTextProperty("intType");
} catch (IllegalArgumentException e) {
ok = true;
}
@@ -360,7 +357,8 @@ public class XMPSchemaTest {
@Test
public void testAltProperties() throws Exception {
- String altProp = "nsSchem:AltProp";
+ String altProp = "AltProp";
+ String qaltProp = "nsSchem:"+altProp;
String defaultLang = "x-default";
String defaultVal = "Default Language";
@@ -371,19 +369,19 @@ public class XMPSchemaTest {
String frLang = "fr-fr";
String frVal = "Lang française";
- schem.setLanguagePropertyValue(altProp, usLang, usVal);
- schem.setLanguagePropertyValue(altProp, defaultLang, defaultVal);
- schem.setLanguagePropertyValue(altProp, frLang, frVal);
+ schem.setUnqualifiedLanguagePropertyValue(altProp, usLang, usVal);
+ schem.setUnqualifiedLanguagePropertyValue(altProp, defaultLang, defaultVal);
+ schem.setUnqualifiedLanguagePropertyValue(altProp, frLang, frVal);
- Assert.assertEquals(defaultVal, schem.getLanguagePropertyValue(altProp,
+ Assert.assertEquals(defaultVal, schem.getUnqualifiedLanguagePropertyValue(altProp,
defaultLang));
- Assert.assertEquals(frVal, schem.getLanguagePropertyValue(altProp,
+ Assert.assertEquals(frVal, schem.getUnqualifiedLanguagePropertyValue(altProp,
frLang));
- Assert.assertEquals(usVal, schem.getLanguagePropertyValue(altProp,
+ Assert.assertEquals(usVal, schem.getUnqualifiedLanguagePropertyValue(altProp,
usLang));
List<String> languages = schem
- .getLanguagePropertyLanguagesValue(altProp);
+ .getUnqualifiedLanguagePropertyLanguagesValue(altProp);
// default language must be in first place
Assert.assertEquals(defaultLang, languages.get(0));
@@ -394,14 +392,14 @@ public class XMPSchemaTest {
frVal = "Langue française";
- schem.setLanguagePropertyValue(altProp, frLang, frVal);
- Assert.assertEquals(frVal, schem.getLanguagePropertyValue(altProp,
+ schem.setUnqualifiedLanguagePropertyValue(altProp, frLang, frVal);
+ Assert.assertEquals(frVal, schem.getUnqualifiedLanguagePropertyValue(altProp,
frLang));
- schem.setLanguagePropertyValue(altProp, frLang, null);
- languages = schem.getLanguagePropertyLanguagesValue(altProp);
+ schem.setUnqualifiedLanguagePropertyValue(altProp, frLang, null);
+ languages = schem.getUnqualifiedLanguagePropertyLanguagesValue(altProp);
Assert.assertFalse(languages.contains(frLang));
- schem.setLanguagePropertyValue(altProp, frLang, frVal);
+ schem.setUnqualifiedLanguagePropertyValue(altProp, frLang, frVal);
/*
* System.out.println("Alternatives lang Management :");
@@ -422,9 +420,11 @@ public class XMPSchemaTest {
*/
@Test
public void testMergeSchema() throws Exception {
- String bagName = "test:bagName";
- String seqName = "test:seqName";
- String altName = "test:AltProp";
+ String bagName = "bagName";
+ String seqName = "seqName";
+ String qseqName = "test:"+seqName;
+ String altName = "AltProp";
+ String qaltName = "test:"+altName;
String valBagSchem1 = "BagvalSchem1";
String valBagSchem2 = "BagvalSchem2";
@@ -440,30 +440,30 @@ public class XMPSchemaTest {
XMPSchema schem1 = new XMPSchema(parent, "test",
"http://www.test.org/schem/");
- schem1.addBagValue(bagName, valBagSchem1);
- schem1.addSequenceValue(seqName, valSeqSchem1);
- schem1.setLanguagePropertyValue(altName, langAltSchem1, valAltSchem1);
+ schem1.addQualifiedBagValue(bagName, valBagSchem1);
+ schem1.addUnqualifiedSequenceValue(seqName, valSeqSchem1);
+ schem1.setUnqualifiedLanguagePropertyValue(altName, langAltSchem1, valAltSchem1);
XMPSchema schem2 = new XMPSchema(parent, "test",
"http://www.test.org/schem/");
- schem2.addBagValue(bagName, valBagSchem2);
- schem2.addSequenceValue(seqName, valSeqSchem2);
- schem2.setLanguagePropertyValue(altName, langAltSchem2, valAltSchem2);
+ schem2.addQualifiedBagValue(bagName, valBagSchem2);
+ schem2.addUnqualifiedSequenceValue(seqName, valSeqSchem2);
+ schem2.setUnqualifiedLanguagePropertyValue(altName, langAltSchem2, valAltSchem2);
schem1.merge(schem2);
// Check if all values are present
- Assert.assertEquals(valAltSchem2, schem1.getLanguagePropertyValue(
+ Assert.assertEquals(valAltSchem2, schem1.getUnqualifiedLanguagePropertyValue(
altName, langAltSchem2));
- Assert.assertEquals(valAltSchem1, schem1.getLanguagePropertyValue(
+ Assert.assertEquals(valAltSchem1, schem1.getUnqualifiedLanguagePropertyValue(
altName, langAltSchem1));
- List<String> bag = schem1.getBagValueList(bagName);
+ List<String> bag = schem1.getUnqualifiedBagValueList(bagName);
Assert.assertTrue(bag.contains(valBagSchem1));
Assert.assertTrue(bag.contains(valBagSchem2));
- List<String> seq = schem1.getSequenceValueList(seqName);
+ List<String> seq = schem1.getUnqualifiedSequenceValueList(seqName);
Assert.assertTrue(seq.contains(valSeqSchem1));
Assert.assertTrue(seq.contains(valSeqSchem1));
@@ -473,7 +473,7 @@ public class XMPSchemaTest {
public void testListAndContainerAccessor() throws Exception {
String boolname = "bool";
boolean boolVal = true;
- BooleanType bool = new BooleanType(parent, schem.getLocalPrefix(),
+ BooleanType bool = new BooleanType(parent, null, schem.getLocalPrefix(),
boolname, boolVal);
Attribute att = new Attribute(null, "rdf", "test", "vgh");
schem.setAttribute(att);
@@ -485,9 +485,7 @@ public class XMPSchemaTest {
Assert.assertTrue(schem.getAllAttributes().contains(att));
Assert.assertEquals(bool, schem.getPropertyAsSimple(boolname));
- Assert.assertEquals(bool, schem.getProperty(schem
- .getLocalPrefixWithSeparator()
- + boolname));
+ Assert.assertEquals(bool, schem.getUnqualifiedProperty(boolname));
}
}
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XmpRightsSchemaTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XmpRightsSchemaTest.java?rev=1366610&r1=1366609&r2=1366610&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XmpRightsSchemaTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/schema/XmpRightsSchemaTest.java Sat Jul 28 08:37:38 2012
@@ -52,8 +52,8 @@ public class XmpRightsSchemaTest extends
@Parameters
public static Collection<Object[]> initializeParameters() throws Exception {
List<Object[]> data = new ArrayList<Object[]>();
- data.add(wrapProperty("Certificate", "URL",
- "http://une.url.vers.un.certificat/moncert.cer"));
+// data.add(wrapProperty("Certificate", "URL",
+// "http://une.url.vers.un.certificat/moncert.cer"));
data.add(wrapProperty("Marked", "Boolean", true));
data.add(wrapProperty("Owner", "bag ProperName",
new String[] { "OwnerName" }));
@@ -62,8 +62,8 @@ public class XmpRightsSchemaTest extends
desc.put("fr", "Termes d'utilisation");
desc.put("en", "Usage Terms");
data.add(wrapProperty("UsageTerms", "Lang Alt", desc));
- data.add(wrapProperty("WebStatement", "URL",
- "http://une.url.vers.une.page.fr/"));
+// data.add(wrapProperty("WebStatement", "URL",
+// "http://une.url.vers.une.page.fr/"));
return data;
}
Added: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/AbstractStructuredTypeTester.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/AbstractStructuredTypeTester.java?rev=1366610&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/AbstractStructuredTypeTester.java (added)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/AbstractStructuredTypeTester.java Sat Jul 28 08:37:38 2012
@@ -0,0 +1,132 @@
+/*****************************************************************************
+ *
+ * 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.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+import java.util.UUID;
+
+import junit.framework.Assert;
+
+import org.apache.padaf.xmpbox.XMPMetadata;
+import org.junit.Test;
+
+public abstract class AbstractStructuredTypeTester {
+
+ protected XMPMetadata xmp;
+
+ protected String fieldName;
+
+ protected String type;
+
+ protected Class<? extends AbstractStructuredType> clz;
+
+
+ public void before () throws Exception {
+ xmp = new XMPMetadata();
+ }
+
+ public AbstractStructuredTypeTester (Class<? extends AbstractStructuredType> clz, String fieldName, String type) {
+ this.clz = clz;
+ this.fieldName = fieldName;
+ this.type = type;
+ }
+
+ protected abstract AbstractStructuredType getStructured ();
+
+ @Test
+ public void testInitializedToNull() throws Exception {
+ // default method
+ Assert.assertNull(getStructured().getProperty(fieldName));
+ // accessor
+ Method get = clz.getMethod(TypeTestingHelper.calculateSimpleGetter(fieldName), new Class[0]);
+ Object result = get.invoke(getStructured(), new Object [0]);
+ Assert.assertNull(result);
+
+ }
+
+ @Test
+ public void testSettingValue() throws Exception {
+ TypeDescription td =TypeMapping.getTypeDescription(type);
+ Object value = TypeTestingHelper.getJavaValue(td);
+ getStructured().addSimpleProperty(fieldName, value);
+ Assert.assertNotNull(getStructured().getProperty(fieldName));
+ // check other properties not modified
+ List<Field> fields = TypeTestingHelper.getXmpFields(clz);
+ for (Field field : fields) {
+ // do not check the current name
+ String name = field.get(null).toString();
+ if (!name.equals(fieldName)) {
+ Assert.assertNull(getStructured().getProperty(name));
+ }
+ }
+ }
+
+ @Test
+ public void testPropertyType() throws Exception {
+ TypeDescription td =TypeMapping.getTypeDescription(type);
+ Object value = TypeTestingHelper.getJavaValue(td);
+ getStructured().addSimpleProperty(fieldName, value);
+ Assert.assertNotNull(getStructured().getProperty(fieldName));
+ // check property type
+ AbstractSimpleProperty asp = getStructured().getProperty(fieldName);
+ Assert.assertEquals(td.getTypeClass(),asp.getClass());
+ }
+
+
+// protected List<Field> getXmpFields () {
+// 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;
+// }
+
+ @Test
+ public void testSetter () throws Exception {
+ String setter = TypeTestingHelper.calculateSimpleSetter(fieldName);
+ TypeDescription td = TypeMapping.getTypeDescription(type);
+ Object value = TypeTestingHelper.getJavaValue(td);
+ Method set = clz.getMethod(setter, new Class<?>[] {TypeTestingHelper.getJavaType(td)} );
+ set.invoke(getStructured(), new Object [] {value});
+ // check property set
+ Assert.assertEquals(value, getStructured().getProperty(fieldName).getObjectValue());
+ // check getter
+ Method get = clz.getMethod(TypeTestingHelper.calculateSimpleGetter(fieldName), new Class[0]);
+ Object result = get.invoke(getStructured(), new Object [0]);
+// Assert.assertEquals(getJavaType(td),result.getClass());
+ Assert.assertTrue(TypeTestingHelper.getJavaType(td).isAssignableFrom(result.getClass()));
+ Assert.assertEquals(value, result);
+
+ }
+
+
+
+
+
+}
Added: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestAbstractStructuredType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestAbstractStructuredType.java?rev=1366610&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestAbstractStructuredType.java (added)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestAbstractStructuredType.java Sat Jul 28 08:37:38 2012
@@ -0,0 +1,106 @@
+/*****************************************************************************
+ *
+ * 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.Calendar;
+
+import junit.framework.Assert;
+
+import org.apache.padaf.xmpbox.XMPMetadata;
+import org.apache.padaf.xmpbox.schema.PropertyType;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestAbstractStructuredType {
+
+ private static class MyStructuredType extends AbstractStructuredType {
+
+ @PropertyType(propertyType="Text")
+ public static final String MYTEXT ="my-text";
+
+ @PropertyType(propertyType="Date")
+ public static final String MYDATE ="my-date";
+
+ public MyStructuredType(XMPMetadata metadata, String namespaceURI,
+ String fieldPrefix) {
+ super(metadata, namespaceURI, fieldPrefix);
+ }
+
+ @Override
+ public String getFieldsNamespace() {
+ return "test";
+ }
+
+
+ }
+
+
+ protected MyStructuredType st;
+
+ public static final String MY_NS = "http://www.apache.org/test#";
+
+ public static final String MY_PREFIX = "test";
+
+ @Before
+ public void before () throws Exception {
+ XMPMetadata xmp = new XMPMetadata();
+ st = new MyStructuredType(xmp, MY_NS, MY_PREFIX);
+ }
+
+ @Test
+ public void validate () throws Exception {
+ Assert.assertEquals(MY_NS, st.getNamespace());
+ Assert.assertEquals(AbstractStructuredType.STRUCTURE_ARRAY_PREFIX, st.getPrefix());
+ Assert.assertEquals(MY_PREFIX, st.getFieldPrefix());
+ }
+
+ @Test
+ public void testNonExistingProperty () throws Exception {
+ Assert.assertNull(st.getProperty("NOT_EXISTING"));
+ }
+
+ @Test
+ public void testNotValuatedPropertyProperty () throws Exception {
+ Assert.assertNull(st.getProperty(MyStructuredType.MYTEXT));
+ }
+
+ @Test
+ public void testValuatedTextProperty () throws Exception {
+ String s = "my value";
+ st.addSimpleProperty(MyStructuredType.MYTEXT, s);
+ Assert.assertEquals(s, st.getPropertyValueAsString(MyStructuredType.MYTEXT));
+ Assert.assertNull(st.getPropertyValueAsString(MyStructuredType.MYDATE));
+ Assert.assertNotNull(st.getProperty(MyStructuredType.MYTEXT));
+ }
+
+ @Test
+ public void testValuatedDateProperty () throws Exception {
+ Calendar c = Calendar.getInstance();
+ st.addSimpleProperty(MyStructuredType.MYDATE, c);
+ Assert.assertEquals(c, st.getDatePropertyAsCalendar(MyStructuredType.MYDATE));
+ Assert.assertNull(st.getDatePropertyAsCalendar(MyStructuredType.MYTEXT));
+ Assert.assertNotNull(st.getProperty(MyStructuredType.MYDATE));
+ }
+
+
+
+}
Added: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestDerivedType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestDerivedType.java?rev=1366610&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestDerivedType.java (added)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestDerivedType.java Sat Jul 28 08:37:38 2012
@@ -0,0 +1,116 @@
+ /*****************************************************************************
+ * 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.Constructor;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.padaf.xmpbox.XMPMetadata;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class TestDerivedType {
+
+ public static final String PREFIX = "myprefix";
+
+ public static final String NAME = "myname";
+
+ public static final String VALUE = "myvalue";
+
+ protected XMPMetadata xmp;
+
+ protected String type = null;
+
+ protected Class<? extends TextType> clz = null;
+
+ protected Constructor<? extends TextType> constructor = null;
+
+
+
+ public TestDerivedType(Class<? extends TextType> clz,
+ String type) {
+ super();
+ this.clz = clz;
+ this.type = type;
+ }
+
+ @Parameters
+ public static Collection<Object[]> initializeParameters() throws Exception {
+ Collection<Object[]> result = new ArrayList<Object[]>();
+
+ result.add(new Object [] {AgentNameType.class,"AgentName"});
+ result.add(new Object [] {ChoiceType.class,"Choice"});
+ result.add(new Object [] {GUIDType.class,"GUID"});
+ result.add(new Object [] {LocaleType.class,"Locale"});
+ result.add(new Object [] {MIMEType.class,"MIME"});
+ result.add(new Object [] {PartType.class,"Part"});
+ result.add(new Object [] {ProperNameType.class,"ProperName"});
+ result.add(new Object [] {RenditionClassType.class,"RenditionClass"});
+ result.add(new Object [] {URIType.class,"URI"});
+ result.add(new Object [] {URLType.class,"URL"});
+ result.add(new Object [] {XPathType.class,"XPath"});
+
+ return result;
+
+ }
+
+ @Before
+ public void before () throws Exception {
+ xmp = new XMPMetadata();
+ constructor = clz.getConstructor(new Class [] {
+ XMPMetadata.class,
+ String.class,
+ String.class,
+ String.class,
+ Object.class
+ });
+ }
+
+ protected TextType instanciate (XMPMetadata metadata, String namespaceURI, String prefix,
+ String propertyName, Object value) throws Exception {
+ Object [] initargs = new Object [] {
+ metadata,
+ namespaceURI,
+ prefix,
+ propertyName,
+ value
+ };
+ return constructor.newInstance(initargs);
+ }
+
+
+ @Test
+ public void test1 () throws Exception {
+ TextType element = instanciate(xmp, null, PREFIX, NAME, VALUE);
+ Assert.assertNull(element.getNamespace());
+ Assert.assertTrue(element.getObjectValue() instanceof String);
+ Assert.assertEquals(VALUE, element.getObjectValue());
+
+ }
+
+
+}
Added: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestJobType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestJobType.java?rev=1366610&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestJobType.java (added)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestJobType.java Sat Jul 28 08:37:38 2012
@@ -0,0 +1,71 @@
+/*****************************************************************************
+ *
+ * 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 TestJobType extends AbstractStructuredTypeTester{
+
+ protected JobType structured = null;
+
+ @Before
+ public void before () throws Exception {
+ super.before();
+ structured = new JobType(xmp);
+ }
+
+ public TestJobType (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 [] {JobType.class,"id","Text"});
+ result.add(new Object [] {JobType.class,"name","Text"});
+ result.add(new Object [] {JobType.class,"url","URL"});
+
+ return result;
+
+ }
+
+
+
+
+
+
+
+}
Added: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestLayerType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestLayerType.java?rev=1366610&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestLayerType.java (added)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestLayerType.java Sat Jul 28 08:37:38 2012
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ *
+ * 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 TestLayerType extends AbstractStructuredTypeTester{
+
+ protected LayerType structured = null;
+
+ @Before
+ public void before () throws Exception {
+ super.before();
+ structured = new LayerType(xmp);
+ }
+
+ public TestLayerType (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 [] {LayerType.class,"LayerName","Text"});
+ result.add(new Object [] {LayerType.class,"LayerText","Text"});
+
+ return result;
+
+ }
+
+
+
+
+
+
+
+}
Added: pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestResourceEventType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestResourceEventType.java?rev=1366610&view=auto
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestResourceEventType.java (added)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/padaf/xmpbox/type/TestResourceEventType.java Sat Jul 28 08:37:38 2012
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ *
+ * 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 TestResourceEventType extends AbstractStructuredTypeTester{
+
+ protected ResourceEventType structured = null;
+
+ @Before
+ public void before () throws Exception {
+ super.before();
+ structured = new ResourceEventType(xmp);
+ }
+
+ public TestResourceEventType (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 [] {ResourceEventType.class,"action","Choice"});
+ result.add(new Object [] {ResourceEventType.class,"changed","Text"});
+ result.add(new Object [] {ResourceEventType.class,"instanceID","GUID"});
+ result.add(new Object [] {ResourceEventType.class,"parameters","Text"});
+ result.add(new Object [] {ResourceEventType.class,"softwareAgent","AgentName"});
+ result.add(new Object [] {ResourceEventType.class,"when","Date"});
+
+ return result;
+
+ }
+
+
+
+
+
+
+
+}