You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ms...@apache.org on 2020/11/15 23:22:35 UTC
svn commit: r1883462 [1/2] - in /pdfbox/trunk/xmpbox: ./
src/test/java/org/apache/xmpbox/ src/test/java/org/apache/xmpbox/parser/
src/test/java/org/apache/xmpbox/schema/ src/test/java/org/apache/xmpbox/type/
Author: msahyoun
Date: Sun Nov 15 23:22:35 2020
New Revision: 1883462
URL: http://svn.apache.org/viewvc?rev=1883462&view=rev
Log:
PDFBOX-5017: switch test to junit5; use parameterized test for Structured Type
Added:
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestStructuredType.java
Removed:
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/AbstractStructuredTypeTester.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestJobType.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestLayerType.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestResourceEventType.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestResourceRefType.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestThumbnailType.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestVersionType.java
Modified:
pdfbox/trunk/xmpbox/pom.xml
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/DateConverterTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/DoubleSameTypeSchemaTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/SaveMetadataHelperTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/XMPMetaDataTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/parser/DeserializationTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/parser/PropMappingTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AbstractSchemaTester.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AbstractXMPSchemaTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AdobePDFErrorsTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/BasicJobTicketSchemaTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/PDFAIdentificationOthersTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/TestExifXmp.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/AttributeTest.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestAbstractStructuredType.java
pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestSimpleMetadataProperties.java
Modified: pdfbox/trunk/xmpbox/pom.xml
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/pom.xml?rev=1883462&r1=1883461&r2=1883462&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/pom.xml (original)
+++ pdfbox/trunk/xmpbox/pom.xml Sun Nov 15 23:22:35 2020
@@ -50,7 +50,10 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
- </dependency>
+ </dependency> <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-params</artifactId>
+ </dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/DateConverterTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/DateConverterTest.java?rev=1883462&r1=1883461&r2=1883462&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/DateConverterTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/DateConverterTest.java Sun Nov 15 23:22:35 2020
@@ -21,12 +21,12 @@
package org.apache.xmpbox;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.text.SimpleDateFormat;
import java.util.Calendar;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the date conversion utility.
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/DoubleSameTypeSchemaTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/DoubleSameTypeSchemaTest.java?rev=1883462&r1=1883461&r2=1883462&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/DoubleSameTypeSchemaTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/DoubleSameTypeSchemaTest.java Sun Nov 15 23:22:35 2020
@@ -21,14 +21,16 @@
package org.apache.xmpbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.ArrayList;
import java.util.List;
import org.apache.xmpbox.schema.DublinCoreSchema;
import org.apache.xmpbox.schema.XMPSchema;
import org.apache.xmpbox.type.StructuredType;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Test with 2 dublinCore with different prefix (Test comportment of XMPMetadata)
@@ -41,7 +43,7 @@ public class DoubleSameTypeSchemaTest
protected XMPMetadata metadata;
- @Before
+ @BeforeEach
public void testInit() throws Exception
{
metadata = XMPMetadata.createXMPMetadata();
@@ -73,9 +75,9 @@ public class DoubleSameTypeSchemaTest
// We can't use metadata.getDublinCoreSchema() due to specification of
// XMPBox (see Javadoc of XMPMetadata)
- Assert.assertEquals(format,
+ assertEquals(format,
((DublinCoreSchema) metadata.getSchema(stDub.preferedPrefix(), stDub.namespace())).getFormat());
- Assert.assertEquals(coverage,
+ assertEquals(coverage,
((DublinCoreSchema) metadata.getSchema(ownPrefix, stDub.namespace())).getCoverage());
List<XMPSchema> schems = metadata.getAllSchemas();
@@ -83,7 +85,7 @@ public class DoubleSameTypeSchemaTest
for (XMPSchema xmpSchema : schems)
{
dc = (DublinCoreSchema) xmpSchema;
- Assert.assertTrue(dc.getCreators().containsAll(creators));
+ assertTrue(dc.getCreators().containsAll(creators));
}
}
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/SaveMetadataHelperTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/SaveMetadataHelperTest.java?rev=1883462&r1=1883461&r2=1883462&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/SaveMetadataHelperTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/SaveMetadataHelperTest.java Sun Nov 15 23:22:35 2020
@@ -23,7 +23,7 @@ package org.apache.xmpbox;
import org.apache.xmpbox.schema.AdobePDFSchema;
import org.apache.xmpbox.schema.DublinCoreSchema;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class SaveMetadataHelperTest
{
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/XMPMetaDataTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/XMPMetaDataTest.java?rev=1883462&r1=1883461&r2=1883462&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/XMPMetaDataTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/XMPMetaDataTest.java Sun Nov 15 23:22:35 2020
@@ -21,6 +21,12 @@
package org.apache.xmpbox;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.IOException;
import java.util.Calendar;
import java.util.GregorianCalendar;
@@ -31,9 +37,8 @@ import org.apache.xmpbox.schema.XMPSchem
import org.apache.xmpbox.xml.DomXmpParser;
import org.apache.xmpbox.xml.XmpParsingException;
import org.apache.xmpbox.xml.XmpSerializationException;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
/**
@@ -42,14 +47,13 @@ import org.w3c.dom.Document;
* @author a183132
*
*/
-public class XMPMetaDataTest
-{
+public class XMPMetaDataTest {
protected XMPMetadata metadata;
protected Document parent;
protected XMPSchema tmp, tmp2;
- @Before
+ @BeforeAll
public void init() throws Exception
{
metadata = XMPMetadata.createXMPMetadata();
@@ -75,8 +79,8 @@ public class XMPMetaDataTest
metadata.addSchema(tmp2);
// Check schema getting
- Assert.assertEquals(tmp, metadata.getSchema(tmpNsURI));
- Assert.assertNull(metadata.getSchema("THIS URI NOT EXISTS !"));
+ assertEquals(tmp, metadata.getSchema(tmpNsURI));
+ assertNull(metadata.getSchema("THIS URI NOT EXISTS !"));
}
@Test
@@ -84,8 +88,8 @@ public class XMPMetaDataTest
{
List<XMPSchema> vals = metadata.getAllSchemas();
- Assert.assertTrue(vals.contains(tmp));
- Assert.assertTrue(vals.contains(tmp2));
+ assertTrue(vals.contains(tmp));
+ assertTrue(vals.contains(tmp2));
}
/*
@@ -96,16 +100,20 @@ public class XMPMetaDataTest
* }
*/
- @Test(expected = org.apache.xmpbox.xml.XmpSerializationException.class)
+ @Test
public void testTransformerExceptionMessage() throws XmpSerializationException
{
- throw new XmpSerializationException("TEST");
+ assertThrows(org.apache.xmpbox.xml.XmpSerializationException.class, () -> {
+ throw new XmpSerializationException("TEST");
+ });
}
- @Test(expected = org.apache.xmpbox.xml.XmpSerializationException.class)
+ @Test
public void testTransformerExceptionWithCause() throws XmpSerializationException
{
- throw new XmpSerializationException("TEST", new Throwable());
+ assertThrows(org.apache.xmpbox.xml.XmpSerializationException.class, () -> {
+ throw new XmpSerializationException("TEST", new Throwable());
+ });
}
@Test
@@ -113,10 +121,10 @@ public class XMPMetaDataTest
{
String xpacketBegin = "TESTBEG", xpacketId = "TESTID", xpacketBytes = "TESTBYTES", xpacketEncoding = "TESTENCOD";
metadata = XMPMetadata.createXMPMetadata(xpacketBegin, xpacketId, xpacketBytes, xpacketEncoding);
- Assert.assertEquals(xpacketBegin, metadata.getXpacketBegin());
- Assert.assertEquals(xpacketId, metadata.getXpacketId());
- Assert.assertEquals(xpacketBytes, metadata.getXpacketBytes());
- Assert.assertEquals(xpacketEncoding, metadata.getXpacketEncoding());
+ assertEquals(xpacketBegin, metadata.getXpacketBegin());
+ assertEquals(xpacketId, metadata.getXpacketId());
+ assertEquals(xpacketBytes, metadata.getXpacketBytes());
+ assertEquals(xpacketEncoding, metadata.getXpacketEncoding());
}
/**
@@ -183,12 +191,12 @@ public class XMPMetaDataTest
Calendar createDate1 = basicSchema.getCreateDate();
basicSchema.setCreateDate(new GregorianCalendar());
Calendar createDate2 = basicSchema.getCreateDate();
- Assert.assertNotEquals("CreateDate has not been set", createDate1, createDate2);
+ assertNotEquals(createDate1, createDate2, "CreateDate has not been set");
// check that bugfix does not interfere with lists of properties with same name
DublinCoreSchema dublinCoreSchema = xmp.getDublinCoreSchema();
List<String> subjects = dublinCoreSchema.getSubjects();
- Assert.assertEquals(4, subjects.size());
+ assertEquals(4, subjects.size());
}
}
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/parser/DeserializationTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/parser/DeserializationTest.java?rev=1883462&r1=1883461&r2=1883462&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/parser/DeserializationTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/parser/DeserializationTest.java Sun Nov 15 23:22:35 2020
@@ -21,6 +21,10 @@
package org.apache.xmpbox.parser;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.List;
@@ -35,19 +39,17 @@ import org.apache.xmpbox.type.ThumbnailT
import org.apache.xmpbox.xml.DomXmpParser;
import org.apache.xmpbox.xml.XmpParsingException;
import org.apache.xmpbox.xml.XmpParsingException.ErrorType;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.apache.xmpbox.xml.XmpSerializer;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-public class DeserializationTest
-{
+public class DeserializationTest {
protected ByteArrayOutputStream bos;
protected XmpSerializer serializer;
- @Before
+ @BeforeEach
public void init() throws Exception
{
bos = new ByteArrayOutputStream();
@@ -98,7 +100,7 @@ public class DeserializationTest
XMPMetadata meta = xdb.parse(fis);
DublinCoreSchema dc = meta.getDublinCoreSchema();
String s = dc.getTitle(null);
- Assert.assertEquals("title value", s);
+ assertEquals("title value", s);
}
@Test
@@ -124,35 +126,35 @@ public class DeserializationTest
XMPMetadata metadata = xdb.parse(fis);
// <xmpMM:DocumentID>
- Assert.assertEquals("uuid:09C78666-2F91-3A9C-92AF-3691A6D594F7", metadata.getXMPMediaManagementSchema()
+ assertEquals("uuid:09C78666-2F91-3A9C-92AF-3691A6D594F7", metadata.getXMPMediaManagementSchema()
.getDocumentID());
// <xmp:CreateDate>
// <xmp:ModifyDate>
// <xmp:MetadataDate>
- Assert.assertEquals(DateConverter.toCalendar("2008-01-18T16:59:54+01:00"), metadata.getXMPBasicSchema()
+ assertEquals(DateConverter.toCalendar("2008-01-18T16:59:54+01:00"), metadata.getXMPBasicSchema()
.getCreateDate());
- Assert.assertEquals(DateConverter.toCalendar("2008-01-18T16:59:54+01:00"), metadata.getXMPBasicSchema()
+ assertEquals(DateConverter.toCalendar("2008-01-18T16:59:54+01:00"), metadata.getXMPBasicSchema()
.getModifyDate());
- Assert.assertEquals(DateConverter.toCalendar("2008-01-18T16:59:54+01:00"), metadata.getXMPBasicSchema()
+ assertEquals(DateConverter.toCalendar("2008-01-18T16:59:54+01:00"), metadata.getXMPBasicSchema()
.getMetadataDate());
// THUMBNAILS TEST
List<ThumbnailType> thumbs = metadata.getXMPBasicSchema().getThumbnailsProperty();
- Assert.assertNotNull(thumbs);
- Assert.assertEquals(2, thumbs.size());
+ assertNotNull(thumbs);
+ assertEquals(2, thumbs.size());
ThumbnailType thumb = thumbs.get(0);
- Assert.assertEquals(Integer.valueOf(162), thumb.getHeight());
- Assert.assertEquals(Integer.valueOf(216), thumb.getWidth());
- Assert.assertEquals("JPEG", thumb.getFormat());
- Assert.assertEquals("/9j/4AAQSkZJRgABAgEASABIAAD", thumb.getImage());
+ assertEquals(Integer.valueOf(162), thumb.getHeight());
+ assertEquals(Integer.valueOf(216), thumb.getWidth());
+ assertEquals("JPEG", thumb.getFormat());
+ assertEquals("/9j/4AAQSkZJRgABAgEASABIAAD", thumb.getImage());
thumb = thumbs.get(1);
- Assert.assertEquals(Integer.valueOf(162), thumb.getHeight());
- Assert.assertEquals(Integer.valueOf(216), thumb.getWidth());
- Assert.assertEquals("JPEG", thumb.getFormat());
- Assert.assertEquals("/9j/4AAQSkZJRgABAgEASABIAAD", thumb.getImage());
+ assertEquals(Integer.valueOf(162), thumb.getHeight());
+ assertEquals(Integer.valueOf(216), thumb.getWidth());
+ assertEquals("JPEG", thumb.getFormat());
+ assertEquals("/9j/4AAQSkZJRgABAgEASABIAAD", thumb.getImage());
}
@@ -165,11 +167,11 @@ public class DeserializationTest
try
{
xdb.parse(fis);
- Assert.fail("Should fail during parse");
+ fail("Should fail during parse");
}
catch (XmpParsingException e)
{
- Assert.assertEquals(ErrorType.XpacketBadStart, e.getErrorType());
+ assertEquals(ErrorType.XpacketBadStart, e.getErrorType());
}
}
@@ -182,11 +184,11 @@ public class DeserializationTest
try
{
xdb.parse(fis);
- Assert.fail("Should fail during parse");
+ fail("Should fail during parse");
}
catch (XmpParsingException e)
{
- Assert.assertEquals(ErrorType.XpacketBadEnd, e.getErrorType());
+ assertEquals(ErrorType.XpacketBadEnd, e.getErrorType());
}
}
@@ -199,11 +201,11 @@ public class DeserializationTest
try
{
xdb.parse(fis);
- Assert.fail("Should fail during parse");
+ fail("Should fail during parse");
}
catch (XmpParsingException e)
{
- Assert.assertEquals(ErrorType.Format, e.getErrorType());
+ assertEquals(ErrorType.Format, e.getErrorType());
}
}
@@ -216,11 +218,11 @@ public class DeserializationTest
try
{
xdb.parse(fis);
- Assert.fail("Should fail during parse");
+ fail("Should fail during parse");
}
catch (XmpParsingException e)
{
- Assert.assertEquals(ErrorType.Format, e.getErrorType());
+ assertEquals(ErrorType.Format, e.getErrorType());
}
}
@@ -233,11 +235,11 @@ public class DeserializationTest
try
{
xdb.parse(fis);
- Assert.fail("Should fail during parse");
+ fail("Should fail during parse");
}
catch (XmpParsingException e)
{
- Assert.assertEquals(ErrorType.Format, e.getErrorType());
+ assertEquals(ErrorType.Format, e.getErrorType());
}
}
@@ -250,11 +252,11 @@ public class DeserializationTest
try
{
xdb.parse(fis);
- Assert.fail("Should fail during parse");
+ fail("Should fail during parse");
}
catch (XmpParsingException e)
{
- Assert.assertEquals(ErrorType.Format, e.getErrorType());
+ assertEquals(ErrorType.Format, e.getErrorType());
}
}
@@ -267,11 +269,11 @@ public class DeserializationTest
try
{
xdb.parse(fis);
- Assert.fail("Should fail during parse");
+ fail("Should fail during parse");
}
catch (XmpParsingException e)
{
- Assert.assertEquals(ErrorType.NoSchema, e.getErrorType());
+ assertEquals(ErrorType.NoSchema, e.getErrorType());
}
}
@@ -284,11 +286,11 @@ public class DeserializationTest
try
{
xdb.parse(fis);
- Assert.fail("Should fail during parse");
+ fail("Should fail during parse");
}
catch (XmpParsingException e)
{
- Assert.assertEquals(ErrorType.NoType, e.getErrorType());
+ assertEquals(ErrorType.NoType, e.getErrorType());
}
}
@@ -301,11 +303,11 @@ public class DeserializationTest
try
{
xdb.parse(fis);
- Assert.fail("Should fail during parse");
+ fail("Should fail during parse");
}
catch (XmpParsingException e)
{
- Assert.assertEquals(ErrorType.NoValueType, e.getErrorType());
+ assertEquals(ErrorType.NoValueType, e.getErrorType());
}
}
@@ -318,7 +320,7 @@ public class DeserializationTest
List<XMPSchema> schemas = meta.getAllSchemas();
for (XMPSchema xmpSchema : schemas)
{
- Assert.assertNotNull(xmpSchema.getAboutAttribute());
+ assertNotNull(xmpSchema.getAboutAttribute());
}
}
@@ -330,13 +332,13 @@ public class DeserializationTest
XMPMetadata meta = xdb.parse(fis);
AdobePDFSchema pdf = meta.getAdobePDFSchema();
- Assert.assertEquals("GPL Ghostscript 8.64", pdf.getProducer());
+ assertEquals("GPL Ghostscript 8.64", pdf.getProducer());
DublinCoreSchema dc = meta.getDublinCoreSchema();
- Assert.assertEquals("application/pdf", dc.getFormat());
+ assertEquals("application/pdf", dc.getFormat());
XMPBasicSchema basic = meta.getXMPBasicSchema();
- Assert.assertNotNull(basic.getCreateDate());
+ assertNotNull(basic.getCreateDate());
}
@@ -349,9 +351,9 @@ public class DeserializationTest
DomXmpParser xdb = new DomXmpParser();
XMPMetadata meta = xdb.parse(is);
// check producer
- Assert.assertEquals(" ", meta.getAdobePDFSchema().getProducer());
+ assertEquals(" ", meta.getAdobePDFSchema().getProducer());
// check creator tool
- Assert.assertEquals("Canon ",meta.getXMPBasicSchema().getCreatorTool());
+ assertEquals("Canon ",meta.getXMPBasicSchema().getCreatorTool());
}
}
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/parser/PropMappingTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/parser/PropMappingTest.java?rev=1883462&r1=1883461&r2=1883462&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/parser/PropMappingTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/parser/PropMappingTest.java Sun Nov 15 23:22:35 2020
@@ -22,7 +22,7 @@
package org.apache.xmpbox.parser;
import org.apache.xmpbox.type.PropertiesDescription;
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
public class PropMappingTest
{
@@ -30,7 +30,7 @@ public class PropMappingTest
protected PropertiesDescription propMap;
protected String nsURI = "http://www.test.org/PropMap#";
- @Before
+ @BeforeEach
public void init()
{
propMap = new PropertiesDescription();
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AbstractSchemaTester.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AbstractSchemaTester.java?rev=1883462&r1=1883461&r2=1883462&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AbstractSchemaTester.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AbstractSchemaTester.java Sun Nov 15 23:22:35 2020
@@ -20,6 +20,11 @@
package org.apache.xmpbox.schema;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;
@@ -33,8 +38,7 @@ import org.apache.xmpbox.type.TypeMappin
import org.apache.xmpbox.type.AbstractTypeTester;
import org.apache.xmpbox.type.Types;
import org.apache.xmpbox.xml.DomXmpParser;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public abstract class AbstractSchemaTester extends AbstractTypeTester
{
@@ -77,14 +81,14 @@ public abstract class AbstractSchemaTest
{
XMPSchema schema = getSchema();
// default method
- Assert.assertNull(schema.getProperty(fieldName));
+ assertNull(schema.getProperty(fieldName));
// accessor
if (cardinality == Cardinality.Simple)
{
String getter = calculateSimpleGetter(fieldName);
Method get = getSchemaClass().getMethod(getter);
Object result = get.invoke(schema);
- Assert.assertNull(result);
+ assertNull(result);
}
else
{
@@ -92,7 +96,7 @@ public abstract class AbstractSchemaTest
String getter = calculateArrayGetter(fieldName);
Method get = getSchemaClass().getMethod(getter);
Object result = get.invoke(schema);
- Assert.assertNull(result);
+ assertNull(result);
}
}
@@ -125,7 +129,7 @@ public abstract class AbstractSchemaTest
AbstractSimpleProperty property = schema.instanciateSimple(fieldName, value);
schema.addProperty(property);
String qn = getPropertyQualifiedName(fieldName);
- Assert.assertNotNull(schema.getProperty(fieldName));
+ assertNotNull(schema.getProperty(fieldName));
// check other properties not modified
List<Field> fields = getXmpFields(getSchemaClass());
for (Field field : fields)
@@ -134,7 +138,7 @@ public abstract class AbstractSchemaTest
String fqn = getPropertyQualifiedName(field.get(null).toString());
if (!fqn.equals(qn))
{
- Assert.assertNull(schema.getProperty(fqn));
+ assertNull(schema.getProperty(fqn));
}
}
}
@@ -177,7 +181,7 @@ public abstract class AbstractSchemaTest
throw new Exception("Unexpected case in test : " + cardinality.name());
}
String qn = getPropertyQualifiedName(fieldName);
- Assert.assertNotNull(schema.getProperty(fieldName));
+ assertNotNull(schema.getProperty(fieldName));
// check other properties not modified
List<Field> fields = getXmpFields(getSchemaClass());
for (Field field : fields)
@@ -186,7 +190,7 @@ public abstract class AbstractSchemaTest
String fqn = getPropertyQualifiedName(field.get(null).toString());
if (!fqn.equals(qn))
{
- Assert.assertNull(schema.getProperty(fqn));
+ assertNull(schema.getProperty(fqn));
}
}
}
@@ -222,13 +226,13 @@ public abstract class AbstractSchemaTest
set.invoke(schema, asp);
// check property set
AbstractSimpleProperty stored = (AbstractSimpleProperty) schema.getProperty(fieldName);
- Assert.assertEquals(value, stored.getValue());
+ assertEquals(value, stored.getValue());
// check getter
String getter = calculateSimpleGetter(fieldName) + "Property";
Method get = getSchemaClass().getMethod(getter);
Object result = get.invoke(schema);
- Assert.assertTrue(type.getImplementingClass().isAssignableFrom(result.getClass()));
- Assert.assertEquals(asp, result);
+ assertTrue(type.getImplementingClass().isAssignableFrom(result.getClass()));
+ assertEquals(asp, result);
}
@Test
@@ -265,19 +269,19 @@ public abstract class AbstractSchemaTest
String getter = calculateArrayGetter(fieldName) + "Property";
Method getcp = getSchemaClass().getMethod(getter);
Object ocp = getcp.invoke(schema);
- Assert.assertTrue(ocp instanceof ArrayProperty);
+ assertTrue(ocp instanceof ArrayProperty);
ArrayProperty cp = (ArrayProperty) ocp;
// check size is ok (1)
- Assert.assertEquals(1, cp.getContainer().getAllProperties().size());
+ assertEquals(1, cp.getContainer().getAllProperties().size());
// add a new one
Object value2 = getJavaValue(type);
set.invoke(schema, value2);
- Assert.assertEquals(2, cp.getContainer().getAllProperties().size());
+ assertEquals(2, cp.getContainer().getAllProperties().size());
// remove the first
String remover = "remove" + calculateFieldNameForMethod(fieldName);
Method remove = getSchemaClass().getMethod(remover, getJavaType(type));
remove.invoke(schema, value1);
- Assert.assertEquals(1, cp.getContainer().getAllProperties().size());
+ assertEquals(1, cp.getContainer().getAllProperties().size());
}
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AbstractXMPSchemaTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AbstractXMPSchemaTest.java?rev=1883462&r1=1883461&r2=1883462&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AbstractXMPSchemaTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AbstractXMPSchemaTest.java Sun Nov 15 23:22:35 2020
@@ -21,6 +21,11 @@
package org.apache.xmpbox.schema;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
@@ -40,8 +45,7 @@ import org.apache.xmpbox.type.TypeMappin
import org.apache.xmpbox.type.Types;
import org.apache.xmpbox.type.URIType;
import org.apache.xmpbox.type.URLType;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public abstract class AbstractXMPSchemaTest
{
@@ -73,15 +77,15 @@ public abstract class AbstractXMPSchemaT
public static Object[] wrapProperty(String name, Types type, Cardinality card, Object value)
{
// if (type==Types.Boolean) {
- // Assert.assertTrue(value instanceof Boolean);
+ // assertTrue(value instanceof Boolean);
// } else if (type==Types.Text) {
- // Assert.assertTrue(value instanceof String);
+ // assertTrue(value instanceof String);
// } else if (type==Types.Integer) {
- // Assert.assertTrue(value instanceof Integer);
+ // assertTrue(value instanceof Integer);
// } else if (type==Types.Date) {
- // Assert.assertTrue(value instanceof Calendar);
+ // assertTrue(value instanceof Calendar);
// } else if (type==Types.URL) {
- // Assert.assertTrue(value instanceof String);
+ // assertTrue(value instanceof String);
// }
return new Object[] { name, TypeMapping.createPropertyType(type, card), value };
}
@@ -232,14 +236,12 @@ public abstract class AbstractXMPSchemaT
PropertyType spt = retrievePropertyType(field.get(schema).toString());
String getNameProperty = "get" + prepareName(field.get(schema).toString(), spt) + "Property";
Method getMethod = schemaClass.getMethod(getNameProperty);
- Assert.assertNull(getNameProperty + " should return null when testing " + property,
- getMethod.invoke(schema));
+ assertNull(getMethod.invoke(schema), getNameProperty + " should return null when testing " + property);
// value test
String getNameValue = "get" + prepareName(field.get(schema).toString(), spt);
getMethod = schemaClass.getMethod(getNameValue);
- Assert.assertNotNull(getNameValue + " method should exist", getMethod);
- Assert.assertNull(getNameValue + " should return null when testing " + property,
- getMethod.invoke(schema));
+ assertNotNull(getMethod, getNameValue + " method should exist");
+ assertNull(getMethod.invoke(schema), getNameValue + " should return null when testing " + property);
}
}
}
@@ -349,7 +351,7 @@ public abstract class AbstractXMPSchemaT
setMethod.invoke(schema, bt);
Boolean found = ((BooleanType) getMethod.invoke(schema)).getValue();
- Assert.assertEquals(value, found);
+ assertEquals(value, found);
}
@@ -364,7 +366,7 @@ public abstract class AbstractXMPSchemaT
setMethod.invoke(schema, dt);
Calendar found = ((DateType) getMethod.invoke(schema)).getValue();
- Assert.assertEquals(value, found);
+ assertEquals(value, found);
}
protected void testGetSetIntegerProperty() throws Exception
@@ -378,7 +380,7 @@ public abstract class AbstractXMPSchemaT
setMethod.invoke(schema, it);
Integer found = ((IntegerType) getMethod.invoke(schema)).getValue();
- Assert.assertEquals(value, found);
+ assertEquals(value, found);
}
protected void testGetSetTextProperty() throws Exception
@@ -392,7 +394,7 @@ public abstract class AbstractXMPSchemaT
setMethod.invoke(schema, tt);
String found = ((TextType) getMethod.invoke(schema)).getStringValue();
- Assert.assertEquals(value, found);
+ assertEquals(value, found);
}
@@ -407,7 +409,7 @@ public abstract class AbstractXMPSchemaT
setMethod.invoke(schema, tt);
String found = ((TextType) getMethod.invoke(schema)).getStringValue();
- Assert.assertEquals(value, found);
+ assertEquals(value, found);
}
@@ -422,7 +424,7 @@ public abstract class AbstractXMPSchemaT
setMethod.invoke(schema, tt);
String found = ((TextType) getMethod.invoke(schema)).getStringValue();
- Assert.assertEquals(value, found);
+ assertEquals(value, found);
}
@@ -438,7 +440,7 @@ public abstract class AbstractXMPSchemaT
setMethod.invoke(schema, tt);
String found = ((AgentNameType) getMethod.invoke(schema)).getStringValue();
- Assert.assertEquals(value, found);
+ assertEquals(value, found);
}
@@ -459,7 +461,7 @@ public abstract class AbstractXMPSchemaT
List<String> fields = (List<String>) getMethod.invoke(schema);
for (String field : fields)
{
- Assert.assertTrue(field + " should be found in list", Arrays.binarySearch(svalue, field) >= 0);
+ assertTrue(Arrays.binarySearch(svalue, field) >= 0, field + " should be found in list");
}
}
@@ -480,7 +482,7 @@ public abstract class AbstractXMPSchemaT
List<Calendar> fields = (List<Calendar>) getMethod.invoke(schema);
for (Calendar field : fields)
{
- Assert.assertTrue(field + " should be found in list", Arrays.binarySearch(svalue, field) >= 0);
+ assertTrue(Arrays.binarySearch(svalue, field) >= 0, field + " should be found in list");
}
}
@@ -496,12 +498,12 @@ public abstract class AbstractXMPSchemaT
String img = "/9j/4AAQSkZJRgABAgEASABIAAD";
setMethod.invoke(schema, height, width, format, img);
List<ThumbnailType> found = ((List<ThumbnailType>) getMethod.invoke(schema));
- Assert.assertEquals(1, found.size());
+ assertEquals(1, found.size());
ThumbnailType t1 = found.get(0);
- Assert.assertEquals(height, t1.getHeight());
- Assert.assertEquals(width, t1.getWidth());
- Assert.assertEquals(format, t1.getFormat());
- Assert.assertEquals(img, t1.getImage());
+ assertEquals(height, t1.getHeight());
+ assertEquals(width, t1.getWidth());
+ assertEquals(format, t1.getFormat());
+ assertEquals(img, t1.getImage());
}
protected void testGetSetLangAltValue() throws Exception
@@ -524,7 +526,7 @@ public abstract class AbstractXMPSchemaT
{
Method getMethod = schemaClass.getMethod(getName, String.class);
String res = (String) getMethod.invoke(schema, string);
- Assert.assertEquals(res, svalue.get(string));
+ assertEquals(res, svalue.get(string));
}
}
@@ -545,7 +547,7 @@ public abstract class AbstractXMPSchemaT
{
Method getMethod = schemaClass.getMethod(getName, String.class);
String res = (String) getMethod.invoke(schema, string);
- Assert.assertEquals(res, svalue);
+ assertEquals(res, svalue);
}
}
@@ -560,7 +562,7 @@ public abstract class AbstractXMPSchemaT
setMethod.invoke(schema, value);
String found = (String) getMethod.invoke(schema);
- Assert.assertEquals(value, found);
+ assertEquals(value, found);
}
protected void testGetSetBooleanValue() throws Exception
@@ -574,7 +576,7 @@ public abstract class AbstractXMPSchemaT
setMethod.invoke(schema, value);
Boolean found = (Boolean) getMethod.invoke(schema);
- Assert.assertEquals(value, found);
+ assertEquals(value, found);
}
protected void testGetSetDateValue() throws Exception
@@ -588,7 +590,7 @@ public abstract class AbstractXMPSchemaT
setMethod.invoke(schema, value);
Calendar found = (Calendar) getMethod.invoke(schema);
- Assert.assertEquals(value, found);
+ assertEquals(value, found);
}
protected void testGetSetIntegerValue() throws Exception
@@ -602,6 +604,6 @@ public abstract class AbstractXMPSchemaT
setMethod.invoke(schema, value);
Integer found = (Integer) getMethod.invoke(schema);
- Assert.assertEquals(value, found);
+ assertEquals(value, found);
}
}
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AdobePDFErrorsTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AdobePDFErrorsTest.java?rev=1883462&r1=1883461&r2=1883462&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AdobePDFErrorsTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/AdobePDFErrorsTest.java Sun Nov 15 23:22:35 2020
@@ -21,12 +21,15 @@
package org.apache.xmpbox.schema;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import org.apache.xmpbox.XMPMetadata;
import org.apache.xmpbox.type.BadFieldValueException;
import org.apache.xmpbox.xml.DomXmpParser;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class AdobePDFErrorsTest
{
@@ -35,7 +38,7 @@ public class AdobePDFErrorsTest
protected DomXmpParser builder;
- @Before
+ @BeforeEach
public void initTempMetaData() throws Exception
{
builder = new DomXmpParser();
@@ -55,39 +58,43 @@ public class AdobePDFErrorsTest
schem.setPDFVersion(pdfVersion);
// Check get null if property not defined
- Assert.assertNull(schem.getProducer());
+ assertNull(schem.getProducer());
schem.setProducer(producer);
- Assert.assertEquals("Keywords", schem.getKeywordsProperty().getPropertyName());
- Assert.assertEquals(keywords, schem.getKeywords());
+ assertEquals("Keywords", schem.getKeywordsProperty().getPropertyName());
+ assertEquals(keywords, schem.getKeywords());
- Assert.assertEquals("PDFVersion", schem.getPDFVersionProperty().getPropertyName());
- Assert.assertEquals(pdfVersion, schem.getPDFVersion());
+ assertEquals("PDFVersion", schem.getPDFVersionProperty().getPropertyName());
+ assertEquals(pdfVersion, schem.getPDFVersion());
- Assert.assertEquals("Producer", schem.getProducerProperty().getPropertyName());
- Assert.assertEquals(producer, schem.getProducer());
+ assertEquals("Producer", schem.getProducerProperty().getPropertyName());
+ assertEquals(producer, schem.getProducer());
// check retrieve this schema in metadata
- Assert.assertEquals(schem, metadata.getAdobePDFSchema());
+ assertEquals(schem, metadata.getAdobePDFSchema());
// SaveMetadataHelper.serialize(metadata, true, System.out);
}
- @Test(expected = BadFieldValueException.class)
+ @Test
public void testBadPDFAConformanceId() throws Exception
{
PDFAIdentificationSchema pdfaid = metadata.createAndAddPFAIdentificationSchema();
String conformance = "kiohiohiohiohio";
- pdfaid.setConformance(conformance);
+ assertThrows(BadFieldValueException.class, () -> {
+ pdfaid.setConformance(conformance);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testBadVersionIdValueType() throws Exception
{
PDFAIdentificationSchema pdfaid = metadata.createAndAddPFAIdentificationSchema();
- pdfaid.setPartValueWithString("1");
- pdfaid.setPartValueWithString("ojoj");
+ assertThrows(BadFieldValueException.class, () -> {
+ pdfaid.setPartValueWithString("1");
+ pdfaid.setPartValueWithString("ojoj");
+ });
}
}
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/BasicJobTicketSchemaTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/BasicJobTicketSchemaTest.java?rev=1883462&r1=1883461&r2=1883462&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/BasicJobTicketSchemaTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/BasicJobTicketSchemaTest.java Sun Nov 15 23:22:35 2020
@@ -20,6 +20,9 @@
package org.apache.xmpbox.schema;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
import java.io.ByteArrayOutputStream;
import org.apache.xmpbox.XMPMetadata;
@@ -27,10 +30,9 @@ import org.apache.xmpbox.type.JobType;
import org.apache.xmpbox.type.StructuredType;
import org.apache.xmpbox.xml.DomXmpParser;
import org.apache.xmpbox.xml.XmpSerializer;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class BasicJobTicketSchemaTest
{
@@ -41,13 +43,13 @@ public class BasicJobTicketSchemaTest
protected XmpSerializer serializer;
- @BeforeClass
+ @BeforeAll
public static void bc() throws Exception
{
builder = new DomXmpParser();
}
- @Before
+ @BeforeEach
public void initTempMetaData() throws Exception
{
metadata = XMPMetadata.createXMPMetadata();
@@ -70,8 +72,8 @@ public class BasicJobTicketSchemaTest
XMPMetadata rxmp = builder.parse(bos.toByteArray());
XMPBasicJobTicketSchema jt = rxmp.getBasicJobTicketSchema();
- Assert.assertNotNull(jt);
- Assert.assertEquals(2, jt.getJobs().size());
+ assertNotNull(jt);
+ assertEquals(2, jt.getJobs().size());
}
@@ -91,17 +93,17 @@ public class BasicJobTicketSchemaTest
XMPMetadata rxmp = builder.parse(bos.toByteArray());
XMPBasicJobTicketSchema jt = rxmp.getBasicJobTicketSchema();
- Assert.assertNotNull(jt);
- Assert.assertEquals(1, jt.getJobs().size());
+ assertNotNull(jt);
+ assertEquals(1, jt.getJobs().size());
StructuredType stjob = JobType.class.getAnnotation(StructuredType.class);
JobType job = jt.getJobs().get(0);
- Assert.assertEquals("zeid2", job.getId());
- Assert.assertEquals("zename2", job.getName());
- Assert.assertEquals("zeurl2", job.getUrl());
- // Assert.assertEquals("Invalid namespace",stjob.namespace(),
+ assertEquals("zeid2", job.getId());
+ assertEquals("zename2", job.getName());
+ assertEquals("zeurl2", job.getUrl());
+ // assertEquals("Invalid namespace",stjob.namespace(),
// job.getNamespace());
- // Assert.assertEquals(stjob.preferedPrefix(), job.getPrefix());
+ // assertEquals(stjob.preferedPrefix(), job.getPrefix());
}
@@ -122,8 +124,8 @@ public class BasicJobTicketSchemaTest
XMPMetadata rxmp = builder.parse(bos.toByteArray());
XMPBasicJobTicketSchema jt = rxmp.getBasicJobTicketSchema();
- Assert.assertNotNull(jt);
- Assert.assertEquals(1, jt.getJobs().size());
+ assertNotNull(jt);
+ assertEquals(1, jt.getJobs().size());
JobType job = jt.getJobs().get(0);
// SaveMetadataHelper.serialize(rxmp, System.out);
@@ -131,11 +133,11 @@ public class BasicJobTicketSchemaTest
// StructuredType stjob =
// JobType.class.getAnnotation(StructuredType.class);
- Assert.assertEquals("zeid2", job.getId());
- Assert.assertEquals("zename2", job.getName());
- Assert.assertEquals("zeurl2", job.getUrl());
- // Assert.assertEquals(stjob.namespace(), job.getNamespace());
- // Assert.assertEquals("aaa", job.getPrefix());
+ assertEquals("zeid2", job.getId());
+ assertEquals("zename2", job.getName());
+ assertEquals("zeurl2", job.getUrl());
+ // assertEquals(stjob.namespace(), job.getNamespace());
+ // assertEquals("aaa", job.getPrefix());
}
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/PDFAIdentificationOthersTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/PDFAIdentificationOthersTest.java?rev=1883462&r1=1883461&r2=1883462&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/PDFAIdentificationOthersTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/PDFAIdentificationOthersTest.java Sun Nov 15 23:22:35 2020
@@ -21,18 +21,20 @@
package org.apache.xmpbox.schema;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import org.apache.xmpbox.XMPMetadata;
import org.apache.xmpbox.type.BadFieldValueException;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class PDFAIdentificationOthersTest
{
protected XMPMetadata metadata;
- @Before
+ @BeforeEach
public void initTempMetaData() throws Exception
{
metadata = XMPMetadata.createXMPMetadata();
@@ -51,34 +53,38 @@ public class PDFAIdentificationOthersTes
pdfaid.setAmd(amdId);
pdfaid.setConformance(conformance);
- Assert.assertEquals(versionId, pdfaid.getPart());
- Assert.assertEquals(amdId, pdfaid.getAmendment());
- Assert.assertEquals(conformance, pdfaid.getConformance());
-
- Assert.assertEquals("" + versionId, pdfaid.getPartProperty().getStringValue());
- Assert.assertEquals(amdId, pdfaid.getAmdProperty().getStringValue());
- Assert.assertEquals(conformance, pdfaid.getConformanceProperty().getStringValue());
+ assertEquals(versionId, pdfaid.getPart());
+ assertEquals(amdId, pdfaid.getAmendment());
+ assertEquals(conformance, pdfaid.getConformance());
+
+ assertEquals("" + versionId, pdfaid.getPartProperty().getStringValue());
+ assertEquals(amdId, pdfaid.getAmdProperty().getStringValue());
+ assertEquals(conformance, pdfaid.getConformanceProperty().getStringValue());
// check retrieve this schema in metadata
- Assert.assertEquals(pdfaid, metadata.getPDFIdentificationSchema());
+ assertEquals(pdfaid, metadata.getPDFIdentificationSchema());
// SaveMetadataHelper.serialize(metadata, true, System.out);
}
- @Test(expected = BadFieldValueException.class)
+ @Test
public void testBadPDFAConformanceId() throws BadFieldValueException
{
PDFAIdentificationSchema pdfaid = metadata.createAndAddPFAIdentificationSchema();
String conformance = "kiohiohiohiohio";
- pdfaid.setConformance(conformance);
+ assertThrows(BadFieldValueException.class, () -> {
+ pdfaid.setConformance(conformance);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testBadVersionIdValueType() throws Exception
{
PDFAIdentificationSchema pdfaid = metadata.createAndAddPFAIdentificationSchema();
- pdfaid.setPartValueWithString("1");
- pdfaid.setPartValueWithString("ojoj");
+ assertThrows(IllegalArgumentException.class, () -> {
+ pdfaid.setPartValueWithString("1");
+ pdfaid.setPartValueWithString("ojoj");
+ });
}
}
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/TestExifXmp.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/TestExifXmp.java?rev=1883462&r1=1883461&r2=1883462&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/TestExifXmp.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/TestExifXmp.java Sun Nov 15 23:22:35 2020
@@ -21,6 +21,9 @@
package org.apache.xmpbox.schema;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
import java.io.ByteArrayOutputStream;
import org.apache.xmpbox.XMPMetadata;
import org.apache.xmpbox.type.OECFType;
@@ -28,8 +31,7 @@ import org.apache.xmpbox.type.TextType;
import org.apache.xmpbox.type.TypeMapping;
import org.apache.xmpbox.xml.DomXmpParser;
import org.apache.xmpbox.xml.XmpSerializer;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.InputStream;
@@ -45,8 +47,8 @@ public class TestExifXmp
XMPMetadata rxmp = builder.parse(is);
ExifSchema schema = (ExifSchema)rxmp.getSchema(ExifSchema.class);
TextType ss = (TextType)schema.getProperty(ExifSchema.SPECTRAL_SENSITIVITY);
- Assert.assertNotNull(ss);
- Assert.assertEquals("spectral sens value",ss.getValue());
+ assertNotNull(ss);
+ assertEquals("spectral sens value",ss.getValue());
}
@Test
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTest.java?rev=1883462&r1=1883461&r2=1883462&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTest.java Sun Nov 15 23:22:35 2020
@@ -21,6 +21,12 @@
package org.apache.xmpbox.schema;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.Calendar;
import java.util.List;
import org.apache.xmpbox.DateConverter;
@@ -36,9 +42,8 @@ import org.apache.xmpbox.type.DateType;
import org.apache.xmpbox.type.IntegerType;
import org.apache.xmpbox.type.TextType;
import org.apache.xmpbox.type.TypeMapping;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class XMPSchemaTest
{
@@ -46,7 +51,7 @@ public class XMPSchemaTest
protected XMPMetadata parent;
protected XMPSchema schem;
- @Before
+ @BeforeEach
public void resetDocument() throws Exception
{
parent = XMPMetadata.createXMPMetadata();
@@ -69,13 +74,13 @@ public class XMPSchemaTest
schem.addQualifiedBagValue(bagName, value2);
List<String> values = schem.getUnqualifiedBagValueList(bagName);
- Assert.assertEquals(value1, values.get(0));
- Assert.assertEquals(value2, values.get(1));
+ assertEquals(value1, values.get(0));
+ assertEquals(value2, values.get(1));
schem.removeUnqualifiedBagValue(bagName, value1);
List<String> values2 = schem.getUnqualifiedBagValueList(bagName);
- Assert.assertEquals(1, values2.size());
- Assert.assertEquals(value2, values2.get(0));
+ assertEquals(1, values2.size());
+ assertEquals(value2, values2.get(0));
}
@@ -91,8 +96,8 @@ public class XMPSchemaTest
newSeq.getContainer().addProperty(li2);
schem.addProperty(newSeq);
List<AbstractField> list = schem.getUnqualifiedArrayList("seqType");
- Assert.assertTrue(list.contains(li1));
- Assert.assertTrue(list.contains(li2));
+ assertTrue(list.contains(li1));
+ assertTrue(list.contains(li2));
}
@@ -115,41 +120,43 @@ public class XMPSchemaTest
schem.addUnqualifiedSequenceValue(seqName, textVal);
List<Calendar> dates = schem.getUnqualifiedSequenceDateValueList(seqName);
- Assert.assertEquals(1, dates.size());
- Assert.assertEquals(date, dates.get(0));
+ assertEquals(1, dates.size());
+ assertEquals(date, dates.get(0));
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));
- Assert.assertEquals(textVal, values.get(2));
+ assertEquals(3, values.size());
+ assertEquals(DateConverter.toISO8601(date), values.get(0));
+ assertEquals(bool.getStringValue(), values.get(1));
+ assertEquals(textVal, values.get(2));
schem.removeUnqualifiedSequenceDateValue(seqName, date);
- Assert.assertEquals(0, schem.getUnqualifiedSequenceDateValueList(seqName).size());
+ assertEquals(0, schem.getUnqualifiedSequenceDateValueList(seqName).size());
schem.removeUnqualifiedSequenceValue(seqName, bool);
schem.removeUnqualifiedSequenceValue(seqName, textVal);
- Assert.assertEquals(0, schem.getUnqualifiedSequenceValueList(seqName).size());
+ assertEquals(0, schem.getUnqualifiedSequenceValueList(seqName).size());
}
@Test
public void rdfAboutTest()
{
- Assert.assertEquals("",schem.getAboutValue());
+ assertEquals("",schem.getAboutValue());
String about = "about";
schem.setAboutAsSimple(about);
- Assert.assertEquals(about, schem.getAboutValue());
+ assertEquals(about, schem.getAboutValue());
schem.setAboutAsSimple("");
- Assert.assertEquals("",schem.getAboutValue());
+ assertEquals("",schem.getAboutValue());
schem.setAboutAsSimple(null);
- Assert.assertEquals("",schem.getAboutValue());
+ assertEquals("",schem.getAboutValue());
}
- @Test(expected = BadFieldValueException.class)
+ @Test
public void testBadRdfAbout() throws Exception
{
- schem.setAbout(new Attribute(null, "about", ""));
+ assertThrows(BadFieldValueException.class, () -> {
+ schem.setAbout(new Attribute(null, "about", ""));
+ });
}
@Test
@@ -159,11 +166,11 @@ public class XMPSchemaTest
String val = "value";
String val2 = "value2";
schem.setTextPropertyValueAsSimple(prop, val);
- Assert.assertEquals(val, schem.getUnqualifiedTextPropertyValue(prop));
+ assertEquals(val, schem.getUnqualifiedTextPropertyValue(prop));
schem.setTextPropertyValueAsSimple(prop, val2);
- Assert.assertEquals(val2, schem.getUnqualifiedTextPropertyValue(prop));
+ assertEquals(val2, schem.getUnqualifiedTextPropertyValue(prop));
schem.setTextPropertyValueAsSimple(prop, null);
- Assert.assertNull(schem.getUnqualifiedTextProperty(prop));
+ assertNull(schem.getUnqualifiedTextProperty(prop));
}
@Test
@@ -175,8 +182,8 @@ public class XMPSchemaTest
schem.setTextPropertyValueAsSimple(prop, val);
TextType text = schem.getMetadata().getTypeMapping().createText(null, schem.getPrefix(), prop, "value2");
schem.setTextProperty(text);
- Assert.assertEquals(val2, schem.getUnqualifiedTextPropertyValue(prop));
- Assert.assertEquals(text, schem.getUnqualifiedTextProperty(prop));
+ assertEquals(val2, schem.getUnqualifiedTextPropertyValue(prop));
+ assertEquals(text, schem.getUnqualifiedTextProperty(prop));
}
@Test
@@ -213,23 +220,23 @@ public class XMPSchemaTest
schem.addUnqualifiedSequenceValue(seqprop, seqPropVal);
schem.addSequenceDateValueAsSimple(seqdate, dateVal);
- Assert.assertEquals(Boolean.valueOf(boolVal), schem.getBooleanProperty(prefSchem + bool).getValue());
- Assert.assertEquals(dateVal, schem.getDateProperty(prefSchem + date).getValue());
- Assert.assertEquals("" + i, schem.getIntegerProperty(prefSchem + integ).getStringValue());
- Assert.assertEquals(langVal, schem.getUnqualifiedLanguagePropertyValue(langprop, lang));
- Assert.assertTrue(schem.getUnqualifiedBagValueList(bagprop).contains(bagVal));
- Assert.assertTrue(schem.getUnqualifiedSequenceValueList(seqprop).contains(seqPropVal));
- Assert.assertTrue(schem.getUnqualifiedSequenceDateValueList(seqdate).contains(dateVal));
- 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.getUnqualifiedLanguagePropertyValue(langprop, lang));
- Assert.assertTrue(schem.getUnqualifiedBagValueList(bagprop).contains(bagVal));
- Assert.assertTrue(schem.getUnqualifiedSequenceValueList(seqprop).contains(seqPropVal));
- Assert.assertTrue(schem.getUnqualifiedSequenceDateValueList(seqdate).contains(dateVal));
- Assert.assertTrue(schem.getUnqualifiedLanguagePropertyLanguagesValue(langprop).contains(lang));
+ assertEquals(Boolean.valueOf(boolVal), schem.getBooleanProperty(prefSchem + bool).getValue());
+ assertEquals(dateVal, schem.getDateProperty(prefSchem + date).getValue());
+ assertEquals("" + i, schem.getIntegerProperty(prefSchem + integ).getStringValue());
+ assertEquals(langVal, schem.getUnqualifiedLanguagePropertyValue(langprop, lang));
+ assertTrue(schem.getUnqualifiedBagValueList(bagprop).contains(bagVal));
+ assertTrue(schem.getUnqualifiedSequenceValueList(seqprop).contains(seqPropVal));
+ assertTrue(schem.getUnqualifiedSequenceDateValueList(seqdate).contains(dateVal));
+ assertTrue(schem.getUnqualifiedLanguagePropertyLanguagesValue(langprop).contains(lang));
+
+ assertEquals(boolVal, schem.getBooleanPropertyValueAsSimple(bool).booleanValue());
+ assertEquals(dateVal, schem.getDatePropertyValueAsSimple(date));
+ assertEquals(i, schem.getIntegerPropertyValueAsSimple(integ));
+ assertEquals(langVal, schem.getUnqualifiedLanguagePropertyValue(langprop, lang));
+ assertTrue(schem.getUnqualifiedBagValueList(bagprop).contains(bagVal));
+ assertTrue(schem.getUnqualifiedSequenceValueList(seqprop).contains(seqPropVal));
+ assertTrue(schem.getUnqualifiedSequenceDateValueList(seqdate).contains(dateVal));
+ assertTrue(schem.getUnqualifiedLanguagePropertyLanguagesValue(langprop).contains(lang));
}
/**
@@ -242,54 +249,54 @@ public class XMPSchemaTest
public void testProperties() throws Exception
{
- Assert.assertEquals("nsURI", schem.getNamespace());
+ assertEquals("nsURI", schem.getNamespace());
// In real cases, rdf ns will be declared before !
schem.addNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf");
String aboutVal = "aboutTest";
schem.setAboutAsSimple(aboutVal);
- Assert.assertEquals(aboutVal, schem.getAboutValue());
+ assertEquals(aboutVal, schem.getAboutValue());
Attribute about = new Attribute(XmpConstants.RDF_NAMESPACE, "about", "YEP");
schem.setAbout(about);
- Assert.assertEquals(about, schem.getAboutAttribute());
+ assertEquals(about, schem.getAboutAttribute());
String textProp = "textProp";
String textPropVal = "TextPropTest";
schem.setTextPropertyValue(textProp, textPropVal);
- Assert.assertEquals(textPropVal, schem.getUnqualifiedTextPropertyValue(textProp));
+ assertEquals(textPropVal, schem.getUnqualifiedTextPropertyValue(textProp));
TextType text = parent.getTypeMapping().createText(null, "nsSchem", "textType", "GRINGO");
schem.setTextProperty(text);
- Assert.assertEquals(text, schem.getUnqualifiedTextProperty("textType"));
+ assertEquals(text, schem.getUnqualifiedTextProperty("textType"));
Calendar dateVal = Calendar.getInstance();
String date = "nsSchem:dateProp";
schem.setDatePropertyValue(date, dateVal);
- Assert.assertEquals(dateVal, schem.getDatePropertyValue(date));
+ assertEquals(dateVal, schem.getDatePropertyValue(date));
DateType dateType = parent.getTypeMapping().createDate(null, "nsSchem", "dateType", Calendar.getInstance());
schem.setDateProperty(dateType);
- Assert.assertEquals(dateType, schem.getDateProperty("dateType"));
+ assertEquals(dateType, schem.getDateProperty("dateType"));
String bool = "nsSchem:booleanTestProp";
Boolean boolVal = false;
schem.setBooleanPropertyValue(bool, boolVal);
- Assert.assertEquals(boolVal, schem.getBooleanPropertyValue(bool));
+ assertEquals(boolVal, schem.getBooleanPropertyValue(bool));
BooleanType boolType = parent.getTypeMapping().createBoolean(null, "nsSchem", "boolType", false);
schem.setBooleanProperty(boolType);
- Assert.assertEquals(boolType, schem.getBooleanProperty("boolType"));
+ assertEquals(boolType, schem.getBooleanProperty("boolType"));
String intProp = "nsSchem:IntegerTestProp";
Integer intPropVal = 5;
schem.setIntegerPropertyValue(intProp, intPropVal);
- Assert.assertEquals(intPropVal, schem.getIntegerPropertyValue(intProp));
+ assertEquals(intPropVal, schem.getIntegerPropertyValue(intProp));
IntegerType intType = parent.getTypeMapping().createInteger(null, "nsSchem", "intType", 5);
schem.setIntegerProperty(intType);
- Assert.assertEquals(intType, schem.getIntegerProperty("intType"));
+ assertEquals(intType, schem.getIntegerProperty("intType"));
// Check bad type verification
boolean ok = false;
@@ -301,7 +308,7 @@ public class XMPSchemaTest
{
ok = true;
}
- Assert.assertTrue(ok);
+ assertTrue(ok);
ok = false;
try
{
@@ -311,7 +318,7 @@ public class XMPSchemaTest
{
ok = true;
}
- Assert.assertTrue(ok);
+ assertTrue(ok);
ok = false;
try
{
@@ -321,7 +328,7 @@ public class XMPSchemaTest
{
ok = true;
}
- Assert.assertTrue(ok);
+ assertTrue(ok);
ok = false;
try
{
@@ -352,27 +359,27 @@ public class XMPSchemaTest
schem.setUnqualifiedLanguagePropertyValue(altProp, defaultLang, defaultVal);
schem.setUnqualifiedLanguagePropertyValue(altProp, frLang, frVal);
- Assert.assertEquals(defaultVal, schem.getUnqualifiedLanguagePropertyValue(altProp, defaultLang));
- Assert.assertEquals(frVal, schem.getUnqualifiedLanguagePropertyValue(altProp, frLang));
- Assert.assertEquals(usVal, schem.getUnqualifiedLanguagePropertyValue(altProp, usLang));
+ assertEquals(defaultVal, schem.getUnqualifiedLanguagePropertyValue(altProp, defaultLang));
+ assertEquals(frVal, schem.getUnqualifiedLanguagePropertyValue(altProp, frLang));
+ assertEquals(usVal, schem.getUnqualifiedLanguagePropertyValue(altProp, usLang));
List<String> languages = schem.getUnqualifiedLanguagePropertyLanguagesValue(altProp);
// default language must be in first place
- Assert.assertEquals(defaultLang, languages.get(0));
+ assertEquals(defaultLang, languages.get(0));
- Assert.assertTrue(languages.contains(usLang));
- Assert.assertTrue(languages.contains(frLang));
+ assertTrue(languages.contains(usLang));
+ assertTrue(languages.contains(frLang));
// Test replacement/removal
frVal = "Langue française";
schem.setUnqualifiedLanguagePropertyValue(altProp, frLang, frVal);
- Assert.assertEquals(frVal, schem.getUnqualifiedLanguagePropertyValue(altProp, frLang));
+ assertEquals(frVal, schem.getUnqualifiedLanguagePropertyValue(altProp, frLang));
schem.setUnqualifiedLanguagePropertyValue(altProp, frLang, null);
languages = schem.getUnqualifiedLanguagePropertyLanguagesValue(altProp);
- Assert.assertFalse(languages.contains(frLang));
+ assertFalse(languages.contains(frLang));
schem.setUnqualifiedLanguagePropertyValue(altProp, frLang, frVal);
}
@@ -417,17 +424,17 @@ public class XMPSchemaTest
schem1.merge(schem2);
// Check if all values are present
- Assert.assertEquals(valAltSchem2, schem1.getUnqualifiedLanguagePropertyValue(altName, langAltSchem2));
- Assert.assertEquals(valAltSchem1, schem1.getUnqualifiedLanguagePropertyValue(altName, langAltSchem1));
+ assertEquals(valAltSchem2, schem1.getUnqualifiedLanguagePropertyValue(altName, langAltSchem2));
+ assertEquals(valAltSchem1, schem1.getUnqualifiedLanguagePropertyValue(altName, langAltSchem1));
List<String> bag = schem1.getUnqualifiedBagValueList(bagName);
- Assert.assertTrue(bag.contains(valBagSchem1));
- Assert.assertTrue(bag.contains(valBagSchem2));
+ assertTrue(bag.contains(valBagSchem1));
+ assertTrue(bag.contains(valBagSchem2));
List<String> seq = schem1.getUnqualifiedSequenceValueList(seqName);
- Assert.assertTrue(seq.contains(valSeqSchem1));
- Assert.assertTrue(seq.contains(valSeqSchem1));
+ assertTrue(seq.contains(valSeqSchem1));
+ assertTrue(seq.contains(valSeqSchem1));
}
@@ -441,11 +448,11 @@ public class XMPSchemaTest
schem.setAttribute(att);
schem.setBooleanProperty(bool);
- Assert.assertEquals(schem.getAllProperties(), schem.getAllProperties());
- Assert.assertTrue(schem.getAllProperties().contains(bool));
- Assert.assertTrue(schem.getAllAttributes().contains(att));
+ assertEquals(schem.getAllProperties(), schem.getAllProperties());
+ assertTrue(schem.getAllProperties().contains(bool));
+ assertTrue(schem.getAllAttributes().contains(att));
- Assert.assertEquals(bool, schem.getProperty(boolname));
+ assertEquals(bool, schem.getProperty(boolname));
}
}
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/AttributeTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/AttributeTest.java?rev=1883462&r1=1883461&r2=1883462&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/AttributeTest.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/AttributeTest.java Sun Nov 15 23:22:35 2020
@@ -21,8 +21,9 @@
package org.apache.xmpbox.type;
-import org.junit.Assert;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
public class AttributeTest
{
@@ -37,9 +38,9 @@ public class AttributeTest
Attribute att = new Attribute(nsUri, localName, value);
- Assert.assertEquals(nsUri, att.getNamespace());
- Assert.assertEquals(localName, att.getName());
- Assert.assertEquals(value, att.getValue());
+ assertEquals(nsUri, att.getNamespace());
+ assertEquals(localName, att.getName());
+ assertEquals(value, att.getValue());
String nsUri2 = "nsUri2";
String prefix2 = "prefix2";
@@ -50,9 +51,9 @@ public class AttributeTest
att.setName(localName2);
att.setValue(value2);
- Assert.assertEquals(nsUri2, att.getNamespace());
- Assert.assertEquals(localName2, att.getName());
- Assert.assertEquals(value2, att.getValue());
+ assertEquals(nsUri2, att.getNamespace());
+ assertEquals(localName2, att.getName());
+ assertEquals(value2, att.getValue());
}
@@ -65,11 +66,11 @@ public class AttributeTest
Attribute att = new Attribute(nsUri, localName, value);
- Assert.assertEquals(nsUri, att.getNamespace());
- Assert.assertEquals(localName, att.getName());
+ assertEquals(nsUri, att.getNamespace());
+ assertEquals(localName, att.getName());
att = new Attribute(nsUri, localName, value);
- Assert.assertEquals(nsUri, att.getNamespace());
- Assert.assertEquals(localName, att.getName());
+ assertEquals(nsUri, att.getNamespace());
+ assertEquals(localName, att.getName());
}
}
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestAbstractStructuredType.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestAbstractStructuredType.java?rev=1883462&r1=1883461&r2=1883462&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestAbstractStructuredType.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestAbstractStructuredType.java Sun Nov 15 23:22:35 2020
@@ -21,11 +21,14 @@
package org.apache.xmpbox.type;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
import java.util.Calendar;
import org.apache.xmpbox.XMPMetadata;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class TestAbstractStructuredType
{
@@ -52,7 +55,7 @@ public class TestAbstractStructuredType
public static final String MY_PREFIX = "test";
- @Before
+ @BeforeEach
public void before() throws Exception
{
XMPMetadata xmp = XMPMetadata.createXMPMetadata();
@@ -62,21 +65,21 @@ public class TestAbstractStructuredType
@Test
public void validate() throws Exception
{
- Assert.assertEquals(MY_NS, st.getNamespace());
- Assert.assertEquals(MY_PREFIX, st.getPrefix());
- Assert.assertEquals(MY_PREFIX, st.getPrefix());
+ assertEquals(MY_NS, st.getNamespace());
+ assertEquals(MY_PREFIX, st.getPrefix());
+ assertEquals(MY_PREFIX, st.getPrefix());
}
@Test
public void testNonExistingProperty() throws Exception
{
- Assert.assertNull(st.getProperty("NOT_EXISTING"));
+ assertNull(st.getProperty("NOT_EXISTING"));
}
@Test
public void testNotValuatedPropertyProperty() throws Exception
{
- Assert.assertNull(st.getProperty(MyStructuredType.MYTEXT));
+ assertNull(st.getProperty(MyStructuredType.MYTEXT));
}
@Test
@@ -84,9 +87,9 @@ public class TestAbstractStructuredType
{
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));
+ assertEquals(s, st.getPropertyValueAsString(MyStructuredType.MYTEXT));
+ assertNull(st.getPropertyValueAsString(MyStructuredType.MYDATE));
+ assertNotNull(st.getProperty(MyStructuredType.MYTEXT));
}
@Test
@@ -94,9 +97,9 @@ public class TestAbstractStructuredType
{
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));
+ assertEquals(c, st.getDatePropertyAsCalendar(MyStructuredType.MYDATE));
+ assertNull(st.getDatePropertyAsCalendar(MyStructuredType.MYTEXT));
+ assertNotNull(st.getProperty(MyStructuredType.MYDATE));
}
}
Modified: pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestSimpleMetadataProperties.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestSimpleMetadataProperties.java?rev=1883462&r1=1883461&r2=1883462&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestSimpleMetadataProperties.java (original)
+++ pdfbox/trunk/xmpbox/src/test/java/org/apache/xmpbox/type/TestSimpleMetadataProperties.java Sun Nov 15 23:22:35 2020
@@ -21,13 +21,17 @@
package org.apache.xmpbox.type;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.Calendar;
import java.util.List;
import org.apache.xmpbox.XMPMetadata;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Test MetaData Objects for simple properties
@@ -40,7 +44,7 @@ public class TestSimpleMetadataPropertie
protected XMPMetadata parent;
- @Before
+ @BeforeEach
public void resetDocument() throws Exception
{
parent = XMPMetadata.createXMPMetadata();
@@ -51,10 +55,12 @@ public class TestSimpleMetadataPropertie
*
* @throws IllegalArgumentException
*/
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testBooleanBadTypeDetection()
{
- new BooleanType(parent, null, "test", "boolean", "Not a Boolean");
+ assertThrows(IllegalArgumentException.class, () -> {
+ new BooleanType(parent, null, "test", "boolean", "Not a Boolean");
+ });
}
/**
@@ -62,10 +68,12 @@ public class TestSimpleMetadataPropertie
*
* @throws IllegalArgumentException
*/
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testDateBadTypeDetection()
{
- new DateType(parent, null, "test", "date", "Bad Date");
+ assertThrows(IllegalArgumentException.class, () -> {
+ new DateType(parent, null, "test", "date", "Bad Date");
+ });
}
/**
@@ -73,10 +81,12 @@ public class TestSimpleMetadataPropertie
*
* @throws IllegalArgumentException
*/
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testIntegerBadTypeDetection()
{
- new IntegerType(parent, null, "test", "integer", "Not an int");
+ assertThrows(IllegalArgumentException.class, () -> {
+ new IntegerType(parent, null, "test", "integer", "Not an int");
+ });
}
/**
@@ -84,10 +94,12 @@ public class TestSimpleMetadataPropertie
*
* @throws IllegalArgumentException
*/
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testRealBadTypeDetection() throws Exception
{
- new RealType(parent, null, "test", "real", "Not a real");
+ assertThrows(IllegalArgumentException.class, () -> {
+ new RealType(parent, null, "test", "real", "Not a real");
+ });
}
/**
@@ -95,10 +107,12 @@ public class TestSimpleMetadataPropertie
*
* @throws IllegalArgumentException
*/
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testTextBadTypeDetection() throws Exception
{
- new TextType(parent, null, "test", "text", Calendar.getInstance());
+ assertThrows(IllegalArgumentException.class, () -> {
+ new TextType(parent, null, "test", "text", Calendar.getInstance());
+ });
}
/**
@@ -120,11 +134,11 @@ public class TestSimpleMetadataPropertie
RealType real = parent.getTypeMapping().createReal(null, "test", "real", realv);
TextType text = parent.getTypeMapping().createText(null, "test", "text", textv);
- Assert.assertEquals(boolv, bool.getValue());
- Assert.assertEquals(datev, date.getValue());
- Assert.assertEquals(Integer.valueOf(integerv), integer.getValue());
- Assert.assertEquals(realv, real.getValue(), 0);
- Assert.assertEquals(textv, text.getStringValue());
+ assertEquals(boolv, bool.getValue());
+ assertEquals(datev, date.getValue());
+ assertEquals(Integer.valueOf(integerv), integer.getValue());
+ assertEquals(realv, real.getValue(), 0);
+ assertEquals(textv, text.getStringValue());
}
@@ -148,11 +162,11 @@ public class TestSimpleMetadataPropertie
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());
- Assert.assertEquals(integerv, integer.getStringValue());
- Assert.assertEquals(realv, real.getStringValue());
- Assert.assertEquals(textv, text.getStringValue());
+ assertEquals(boolv, bool.getStringValue());
+ assertEquals(datev, date.getStringValue());
+ assertEquals(integerv, integer.getStringValue());
+ assertEquals(realv, real.getStringValue());
+ assertEquals(textv, text.getStringValue());
}
/**
@@ -170,11 +184,11 @@ public class TestSimpleMetadataPropertie
RealType real = parent.getTypeMapping().createReal(ns, "test", "real", (float) 1.6);
TextType text = parent.getTypeMapping().createText(ns, "test", "text", "TEST");
- Assert.assertEquals(ns, bool.getNamespace());
- Assert.assertEquals(ns, date.getNamespace());
- Assert.assertEquals(ns, integer.getNamespace());
- Assert.assertEquals(ns, real.getNamespace());
- Assert.assertEquals(ns, text.getNamespace());
+ assertEquals(ns, bool.getNamespace());
+ assertEquals(ns, date.getNamespace());
+ assertEquals(ns, integer.getNamespace());
+ assertEquals(ns, real.getNamespace());
+ assertEquals(ns, text.getNamespace());
}
@@ -183,10 +197,12 @@ public class TestSimpleMetadataPropertie
*
* @throws IllegalArgumentException
*/
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testExceptionWithCause() throws Exception
{
- throw new IllegalArgumentException("TEST", new Throwable());
+ assertThrows(IllegalArgumentException.class, () -> {
+ throw new IllegalArgumentException("TEST", new Throwable());
+ });
}
/**
@@ -206,16 +222,16 @@ public class TestSimpleMetadataPropertie
// System.out.println(value.getQualifiedName());
- Assert.assertEquals(value, integer.getAttribute(value.getName()));
- Assert.assertTrue(integer.containsAttribute(value.getName()));
+ assertEquals(value, integer.getAttribute(value.getName()));
+ assertTrue(integer.containsAttribute(value.getName()));
// Replacement check
integer.setAttribute(value2);
- Assert.assertEquals(value2, integer.getAttribute(value2.getName()));
+ assertEquals(value2, integer.getAttribute(value2.getName()));
integer.removeAttribute(value2.getName());
- Assert.assertFalse(integer.containsAttribute(value2.getName()));
+ assertFalse(integer.containsAttribute(value2.getName()));
// Attribute with namespace Creation checking
Attribute valueNS = new Attribute("http://www.tefst2.org/test/", "value2", "StringValue.2");
@@ -227,8 +243,8 @@ public class TestSimpleMetadataPropertie
/*
* for (Attribute attribute : atts) { System.out.println(attribute.getLocalName ()+" :"+attribute.getValue()); }
*/
- Assert.assertFalse(atts.contains(valueNS));
- Assert.assertTrue(atts.contains(valueNS2));
+ assertFalse(atts.contains(valueNS));
+ assertTrue(atts.contains(valueNS2));
}