Author: tilman
Date: Sat Apr 12 12:49:14 2025
New Revision: 1925044
URL: http://svn.apache.org/viewvc?rev=1925044&view=rev
Log:
PDFBOX-5660: Sonar fix
Modified:
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTest.java
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTester.java
Modified:
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTest.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTest.java?rev=1925044&r1=1925043&r2=1925044&view=diff
==============================================================================
---
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTest.java
(original)
+++
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTest.java
Sat Apr 12 12:49:14 2025
@@ -21,6 +21,7 @@
package org.apache.xmpbox.schema;
+import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -55,7 +56,7 @@ class XMPSchemaTest
* @throws IllegalArgumentException
*/
@Test
- void testBagManagement() throws Exception
+ void testBagManagement()
{
String bagName = "BAGTEST";
String value1 = "valueOne";
@@ -71,11 +72,10 @@ class XMPSchemaTest
List<String> values2 = schem.getUnqualifiedBagValueList(bagName);
assertEquals(1, values2.size());
assertEquals(value2, values2.get(0));
-
}
@Test
- void testArrayList() throws Exception
+ void testArrayList() throws BadFieldValueException
{
XMPMetadata meta = XMPMetadata.createXMPMetadata();
ArrayProperty newSeq = meta.getTypeMapping().createArrayProperty(null,
"nsSchem", "seqType", Cardinality.Seq);
@@ -97,7 +97,7 @@ class XMPSchemaTest
* @throws java.io.IOException
*/
@Test
- void testSeqManagement() throws Exception
+ void testSeqManagement()
{
Calendar date = Calendar.getInstance();
BooleanType bool = parent.getTypeMapping().createBoolean(null, "rdf",
"li", true);
@@ -141,15 +141,15 @@ class XMPSchemaTest
}
@Test
- void testBadRdfAbout() throws Exception
+ void testBadRdfAbout()
{
assertThrows(BadFieldValueException.class, () -> {
- schem.setAbout(new Attribute(null, "about", ""));
- });
+ schem.setAbout(new Attribute(null, "about", ""));
+ });
}
@Test
- void testSetSpecifiedSimpleTypeProperty() throws Exception
+ void testSetSpecifiedSimpleTypeProperty() throws BadFieldValueException
{
String prop = "testprop";
String val = "value";
@@ -163,7 +163,7 @@ class XMPSchemaTest
}
@Test
- void testSpecifiedSimplePropertyFormer() throws Exception
+ void testSpecifiedSimplePropertyFormer() throws BadFieldValueException
{
String prop = "testprop";
String val = "value";
@@ -176,7 +176,7 @@ class XMPSchemaTest
}
@Test
- void testAsSimpleMethods() throws Exception
+ void testAsSimpleMethods() throws BadFieldValueException
{
String bool = "bool";
boolean boolVal = true;
@@ -235,7 +235,7 @@ class XMPSchemaTest
* @throws BadFieldValueException
*/
@Test
- void testProperties() throws Exception
+ void testProperties() throws BadFieldValueException
{
assertEquals("nsURI", schem.getNamespace());
@@ -288,50 +288,13 @@ class XMPSchemaTest
assertEquals(intType, schem.getIntegerProperty("intType"));
// Check bad type verification
- boolean ok = false;
- try
- {
- schem.getIntegerProperty("boolType");
- }
- catch (BadFieldValueException e)
- {
- ok = true;
- }
- assertTrue(ok);
- ok = false;
- try
- {
- schem.getUnqualifiedTextProperty("intType");
- }
- catch (BadFieldValueException e)
- {
- ok = true;
- }
- assertTrue(ok);
- ok = false;
- try
- {
- schem.getDateProperty("textType");
- }
- catch (BadFieldValueException e)
- {
- ok = true;
- }
- assertTrue(ok);
- ok = false;
- try
- {
- schem.getBooleanProperty("dateType");
- }
- catch (BadFieldValueException e)
- {
- ok = true;
- }
-
+ assertThrows(BadFieldValueException.class, () ->
schem.getIntegerProperty("boolType"));
+ assertThrows(BadFieldValueException.class, () ->
schem.getDateProperty("textType"));
+ assertThrows(BadFieldValueException.class, () ->
schem.getBooleanProperty("dateType"));
}
@Test
- void testAltProperties() throws Exception
+ void testAltProperties() throws BadFieldValueException
{
String altProp = "AltProp";
@@ -380,7 +343,7 @@ class XMPSchemaTest
* @throws java.io.IOException
*/
@Test
- void testMergeSchema() throws Exception
+ void testMergeSchema() throws IOException, BadFieldValueException
{
String bagName = "bagName";
String seqName = "seqName";
@@ -426,7 +389,7 @@ class XMPSchemaTest
}
@Test
- void testListAndContainerAccessor() throws Exception
+ void testListAndContainerAccessor()
{
String boolname = "bool";
boolean boolVal = true;
@@ -440,6 +403,5 @@ class XMPSchemaTest
assertTrue(schem.getAllAttributes().contains(att));
assertEquals(bool, schem.getProperty(boolname));
-
}
}
Modified:
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTester.java
URL:
http://svn.apache.org/viewvc/pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTester.java?rev=1925044&r1=1925043&r2=1925044&view=diff
==============================================================================
---
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTester.java
(original)
+++
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/schema/XMPSchemaTester.java
Sat Apr 12 12:49:14 2025
@@ -75,7 +75,7 @@ class XMPSchemaTester
return TypeMapping.createPropertyType(type, card);
}
- public void testGetSetValue() throws Exception
+ public void testGetSetValue() throws ReflectiveOperationException
{
if (type.type() == Types.Text && type.card() == Cardinality.Simple)
{
@@ -119,11 +119,11 @@ class XMPSchemaTester
}
else
{
- throw new Exception("Unknown type : " + type);
+ throw new IllegalArgumentException("Unknown type : " + type);
}
}
- public void testGetSetProperty() throws Exception
+ public void testGetSetProperty() throws ReflectiveOperationException
{
if (type.type() == Types.Text && type.card() == Cardinality.Simple)
{
@@ -187,7 +187,7 @@ class XMPSchemaTester
}
else
{
- throw new Exception("Unknown type : " + type);
+ throw new IllegalArgumentException("Unknown type : " + type);
}
Field[] fields = schemaClass.getFields();
for (Field field : fields)
@@ -323,7 +323,7 @@ class XMPSchemaTester
}
- protected void testGetSetBooleanProperty() throws Exception
+ protected void testGetSetBooleanProperty() throws
ReflectiveOperationException
{
String setName = setMethod(property);
String getName = getMethod(property);
@@ -338,7 +338,7 @@ class XMPSchemaTester
}
- protected void testGetSetDateProperty() throws Exception
+ protected void testGetSetDateProperty() throws ReflectiveOperationException
{
String setName = setMethod(property);
String getName = getMethod(property);
@@ -352,7 +352,7 @@ class XMPSchemaTester
assertEquals(value, found);
}
- protected void testGetSetIntegerProperty() throws Exception
+ protected void testGetSetIntegerProperty() throws
ReflectiveOperationException
{
String setName = setMethod(property);
String getName = getMethod(property);
@@ -366,7 +366,7 @@ class XMPSchemaTester
assertEquals(value, found);
}
- protected void testGetSetTextProperty() throws Exception
+ protected void testGetSetTextProperty() throws ReflectiveOperationException
{
String setName = setMethod(property);
String getName = getMethod(property);
@@ -381,7 +381,7 @@ class XMPSchemaTester
}
- protected void testGetSetURIProperty() throws Exception
+ protected void testGetSetURIProperty() throws ReflectiveOperationException
{
String setName = setMethod(property);
String getName = getMethod(property);
@@ -396,7 +396,7 @@ class XMPSchemaTester
}
- protected void testGetSetURLProperty() throws Exception
+ protected void testGetSetURLProperty() throws ReflectiveOperationException
{
String setName = setMethod(property);
String getName = getMethod(property);
@@ -411,7 +411,7 @@ class XMPSchemaTester
}
- protected void testGetSetAgentNameProperty() throws Exception
+ protected void testGetSetAgentNameProperty() throws
ReflectiveOperationException
{
String setName = setMethod(property);
String getName = getMethod(property);
@@ -427,7 +427,7 @@ class XMPSchemaTester
}
- protected void testGetSetTextListValue(String tp) throws Exception
+ protected void testGetSetTextListValue(String tp) throws
ReflectiveOperationException
{
String setName = addToValueMethod(property);
String getName = getValueMethod(property);
@@ -448,7 +448,7 @@ class XMPSchemaTester
}
}
- protected void testGetSetDateListValue(String tp) throws Exception
+ protected void testGetSetDateListValue(String tp) throws
ReflectiveOperationException
{
String setName = addToValueMethod(property);
String getName = getValueMethod(property);
@@ -469,7 +469,7 @@ class XMPSchemaTester
}
}
- protected void testGetSetThumbnail() throws Exception
+ protected void testGetSetThumbnail() throws ReflectiveOperationException
{
String addName = addMethod(property);
String getName = getMethod(property);
@@ -489,7 +489,7 @@ class XMPSchemaTester
assertEquals(img, t1.getImage());
}
- protected void testGetSetLangAltValue() throws Exception
+ protected void testGetSetLangAltValue() throws ReflectiveOperationException
{
String setName = addToValueMethod(property);
String getName = getValueMethod(property);
@@ -513,7 +513,7 @@ class XMPSchemaTester
}
}
- protected void testGetSetURLValue() throws Exception
+ protected void testGetSetURLValue() throws ReflectiveOperationException
{
String setName = addToValueMethod(property);
String getName = getValueMethod(property);
@@ -534,7 +534,7 @@ class XMPSchemaTester
}
}
- protected void testGetSetTextValue() throws Exception
+ protected void testGetSetTextValue() throws ReflectiveOperationException
{
String setName = setValueMethod(property);
String getName = getValueMethod(property);
@@ -548,7 +548,7 @@ class XMPSchemaTester
assertEquals(value, found);
}
- protected void testGetSetBooleanValue() throws Exception
+ protected void testGetSetBooleanValue() throws ReflectiveOperationException
{
String setName = setValueMethod(property);
String getName = getValueMethod(property);
@@ -562,7 +562,7 @@ class XMPSchemaTester
assertEquals(value, found);
}
- protected void testGetSetDateValue() throws Exception
+ protected void testGetSetDateValue() throws ReflectiveOperationException
{
String setName = setValueMethod(property);
String getName = getValueMethod(property);
@@ -576,7 +576,7 @@ class XMPSchemaTester
assertEquals(value, found);
}
- protected void testGetSetIntegerValue() throws Exception
+ protected void testGetSetIntegerValue() throws ReflectiveOperationException
{
String setName = setValueMethod(property);
String getName = getValueMethod(property);