Skip to content

Commit c7f0215

Browse files
introfogyulian-gaponenko
authored andcommitted
Move events mechanism main classes to events module
DEVSIX-5233 Autoported commit. Original commit hash: [42d72f2b9] Manual files: events/src/main/java/com/itextpdf/events/util/DateTimeUtil.java events/src/main/java/com/itextpdf/events/util/EncodingUtil.java events/src/main/java/com/itextpdf/events/util/MessageFormatUtil.java io/src/main/java/com/itextpdf/io/source/RandomAccessSourceFactory.java io/src/main/java/com/itextpdf/io/util/SystemUtil.java io/src/test/java/com/itextpdf/io/font/FontProgramTest.java kernel/src/main/java/com/itextpdf/kernel/counter/DataHandlerCounter.java kernel/src/main/java/com/itextpdf/kernel/counter/data/EventDataHandler.java kernel/src/main/java/com/itextpdf/kernel/counter/data/IEventDataFactory.java kernel/src/main/java/com/itextpdf/kernel/utils/DefaultSafeXmlParserFactory.java sign/src/test/java/com/itextpdf/signatures/testutils/builder/TestCrlBuilder.java sign/src/test/java/com/itextpdf/signatures/testutils/builder/TestOcspResponseBuilder.java sign/src/test/java/com/itextpdf/signatures/testutils/builder/TestTimestampTokenBuilder.java sign/src/test/java/com/itextpdf/signatures/testutils/cert/TestCertificateBuilder.java styled-xml-parser/src/main/java/com/itextpdf/styledxmlparser/resolver/resource/UriResolver.java
1 parent a7c829d commit c7f0215

File tree

565 files changed

+1542
-1380
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

565 files changed

+1542
-1380
lines changed

itext.tests/itext.barcodes.tests/itext/barcodes/Barcode128Test.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ public virtual void Barcode02Test() {
9696

9797
[NUnit.Framework.Test]
9898
public virtual void BarcodeRawValueGenerationTest01() {
99-
NUnit.Framework.Assert.AreEqual(iText.Events.Util.JavaUtil.GetStringForBytes(new byte[] { 103, 17, 18, 19,
100-
20, 21, 17, 18, 19, 20, 21 }), Barcode128.GetRawText("1234512345", false, Barcode128.Barcode128CodeSet
99+
NUnit.Framework.Assert.AreEqual(iText.Events.Utils.JavaUtil.GetStringForBytes(new byte[] { 103, 17, 18, 19
100+
, 20, 21, 17, 18, 19, 20, 21 }), Barcode128.GetRawText("1234512345", false, Barcode128.Barcode128CodeSet
101101
.A));
102102
}
103103
}

itext.tests/itext.barcodes.tests/itext/barcodes/BarcodeMSITest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ source product.
4141
4242
*/
4343
using System;
44-
using iText.Events.Util;
44+
using iText.Events.Utils;
4545
using iText.Kernel.Colors;
4646
using iText.Kernel.Pdf;
4747
using iText.Kernel.Pdf.Canvas;

itext.tests/itext.kernel.tests/itext/kernel/actions/AbstractContextBasedEventHandlerTest.cs renamed to itext.tests/itext.events.tests/itext/events/AbstractContextBasedEventHandlerTest.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2020
You should have received a copy of the GNU Affero General Public License
2121
along with this program. If not, see <https://www.gnu.org/licenses/>.
2222
*/
23-
using iText.Events;
23+
using iText.Events.Contexts;
24+
using iText.Events.Ecosystem;
2425
using iText.Events.Sequence;
25-
using iText.Kernel.Actions.Ecosystem;
26-
using iText.Kernel.Counter.Context;
2726
using iText.Test;
2827

29-
namespace iText.Kernel.Actions {
28+
namespace iText.Events {
3029
public class AbstractContextBasedEventHandlerTest : ExtendedITextTest {
3130
[NUnit.Framework.Test]
3231
public virtual void CoreEventProcessedByHandlerTest() {

itext.tests/itext.kernel.tests/itext/kernel/actions/EventManagerTest.cs renamed to itext.tests/itext.events.tests/itext/events/EventManagerTest.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ You should have received a copy of the GNU Affero General Public License
2222
*/
2323
using System;
2424
using System.Collections.Generic;
25-
using iText.Events;
25+
using iText.Events.Ecosystem;
2626
using iText.Events.Exceptions;
2727
using iText.Events.Sequence;
28-
using iText.Kernel.Actions.Ecosystem;
2928
using iText.Test;
3029
using iText.Test.Attributes;
3130

32-
namespace iText.Kernel.Actions {
31+
namespace iText.Events {
3332
public class EventManagerTest : ExtendedITextTest {
3433
[NUnit.Framework.Test]
3534
[LogMessage(TestConfigurationEvent.MESSAGE)]
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2021 iText Group NV
4+
Authors: iText Software.
5+
6+
This program is offered under a commercial and under the AGPL license.
7+
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
8+
9+
AGPL licensing:
10+
This program is free software: you can redistribute it and/or modify
11+
it under the terms of the GNU Affero General Public License as published by
12+
the Free Software Foundation, either version 3 of the License, or
13+
(at your option) any later version.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU Affero General Public License for more details.
19+
20+
You should have received a copy of the GNU Affero General Public License
21+
along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
*/
23+
using iText.Events.Confirmations;
24+
using iText.Events.Ecosystem;
25+
using iText.Events.Exceptions;
26+
using iText.Events.Sequence;
27+
using iText.Events.Utils;
28+
using iText.Test;
29+
30+
namespace iText.Events {
31+
public class ProductEventHandlerTest : ExtendedITextTest {
32+
[NUnit.Framework.Test]
33+
public virtual void UnknownProductTest() {
34+
ProductEventHandler handler = ProductEventHandler.INSTANCE;
35+
NUnit.Framework.Assert.That(() => {
36+
handler.OnAcceptedEvent(new ITextTestEvent(new SequenceId(), null, "test-event", "Unknown Product"));
37+
}
38+
, NUnit.Framework.Throws.InstanceOf<UnknownProductException>().With.Message.EqualTo(MessageFormatUtil.Format(UnknownProductException.UNKNOWN_PRODUCT, "Unknown Product")))
39+
;
40+
}
41+
42+
[NUnit.Framework.Test]
43+
public virtual void SequenceIdBasedEventTest() {
44+
ProductEventHandler handler = ProductEventHandler.INSTANCE;
45+
SequenceId sequenceId = new SequenceId();
46+
NUnit.Framework.Assert.IsTrue(handler.GetEvents(sequenceId).IsEmpty());
47+
handler.OnAcceptedEvent(new ITextTestEvent(sequenceId, null, "test-event", ProductNameConstant.ITEXT_CORE)
48+
);
49+
NUnit.Framework.Assert.AreEqual(1, handler.GetEvents(sequenceId).Count);
50+
AbstractProductProcessITextEvent @event = handler.GetEvents(sequenceId)[0];
51+
NUnit.Framework.Assert.AreEqual(sequenceId.GetId(), @event.GetSequenceId().GetId());
52+
NUnit.Framework.Assert.IsNull(@event.GetMetaInfo());
53+
NUnit.Framework.Assert.AreEqual("test-event", @event.GetEventType());
54+
NUnit.Framework.Assert.AreEqual(ProductNameConstant.ITEXT_CORE, @event.GetProductName());
55+
}
56+
57+
[NUnit.Framework.Test]
58+
public virtual void ReportEventSeveralTimesTest() {
59+
ProductEventHandler handler = ProductEventHandler.INSTANCE;
60+
SequenceId sequenceId = new SequenceId();
61+
NUnit.Framework.Assert.IsTrue(handler.GetEvents(sequenceId).IsEmpty());
62+
ITextTestEvent @event = new ITextTestEvent(sequenceId, null, "test-event", ProductNameConstant.ITEXT_CORE);
63+
EventManager.GetInstance().OnEvent(@event);
64+
NUnit.Framework.Assert.AreEqual(1, handler.GetEvents(sequenceId).Count);
65+
NUnit.Framework.Assert.AreEqual(@event, handler.GetEvents(sequenceId)[0]);
66+
EventManager.GetInstance().OnEvent(@event);
67+
NUnit.Framework.Assert.AreEqual(2, handler.GetEvents(sequenceId).Count);
68+
NUnit.Framework.Assert.AreEqual(@event, handler.GetEvents(sequenceId)[0]);
69+
NUnit.Framework.Assert.AreEqual(@event, handler.GetEvents(sequenceId)[1]);
70+
}
71+
72+
[NUnit.Framework.Test]
73+
public virtual void ConfirmEventTest() {
74+
ProductEventHandler handler = ProductEventHandler.INSTANCE;
75+
SequenceId sequenceId = new SequenceId();
76+
NUnit.Framework.Assert.IsTrue(handler.GetEvents(sequenceId).IsEmpty());
77+
ITextTestEvent @event = new ITextTestEvent(sequenceId, null, "test-event", ProductNameConstant.ITEXT_CORE);
78+
EventManager.GetInstance().OnEvent(@event);
79+
ConfirmEvent confirmEvent = new ConfirmEvent(sequenceId, @event);
80+
EventManager.GetInstance().OnEvent(confirmEvent);
81+
NUnit.Framework.Assert.AreEqual(1, handler.GetEvents(sequenceId).Count);
82+
NUnit.Framework.Assert.IsTrue(handler.GetEvents(sequenceId)[0] is ConfirmedEventWrapper);
83+
NUnit.Framework.Assert.AreEqual(@event, ((ConfirmedEventWrapper)handler.GetEvents(sequenceId)[0]).GetEvent
84+
());
85+
}
86+
}
87+
}

itext.tests/itext.kernel.tests/itext/kernel/actions/events/ConfirmEventTest.cs renamed to itext.tests/itext.events.tests/itext/events/confirmations/ConfirmEventTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2020
You should have received a copy of the GNU Affero General Public License
2121
along with this program. If not, see <https://www.gnu.org/licenses/>.
2222
*/
23+
using iText.Events.Ecosystem;
2324
using iText.Events.Sequence;
24-
using iText.Kernel.Actions.Ecosystem;
2525
using iText.Test;
2626

27-
namespace iText.Kernel.Actions.Events {
27+
namespace iText.Events.Confirmations {
2828
public class ConfirmEventTest : ExtendedITextTest {
2929
[NUnit.Framework.Test]
3030
public virtual void ConstructorWithSequenceIdTest() {

itext.tests/itext.kernel.tests/itext/kernel/counter/ContextManagerTest.cs renamed to itext.tests/itext.events.tests/itext/events/contexts/ContextManagerTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ source product.
4242
*/
4343
using System;
4444
using iText.Events;
45-
using iText.Events.Util;
45+
using iText.Events.Utils;
4646
using iText.Test;
4747

48-
namespace iText.Kernel.Counter {
48+
namespace iText.Events.Contexts {
4949
public class ContextManagerTest : ExtendedITextTest {
5050
[NUnit.Framework.Test]
5151
public virtual void GetRecognisedNamespaceForSpecificNamespaceTest() {
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2021 iText Group NV
4+
Authors: iText Software.
5+
6+
This program is offered under a commercial and under the AGPL license.
7+
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
8+
9+
AGPL licensing:
10+
This program is free software: you can redistribute it and/or modify
11+
it under the terms of the GNU Affero General Public License as published by
12+
the Free Software Foundation, either version 3 of the License, or
13+
(at your option) any later version.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU Affero General Public License for more details.
19+
20+
You should have received a copy of the GNU Affero General Public License
21+
along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
*/
23+
using System;
24+
using iText.Events;
25+
using iText.Events.Confirmations;
26+
using iText.Events.Contexts;
27+
using iText.Events.Data;
28+
using iText.Events.Sequence;
29+
30+
namespace iText.Events.Ecosystem {
31+
public class ITextTestEvent : AbstractProductProcessITextEvent {
32+
private readonly String eventType;
33+
34+
public ITextTestEvent(SequenceId sequenceId, IMetaInfo metaInfo, String eventType, String productName)
35+
: base(sequenceId, new ProductData("", productName, "", 2000, 2100), metaInfo, EventConfirmationType.ON_CLOSE
36+
) {
37+
this.eventType = eventType;
38+
}
39+
40+
public ITextTestEvent(SequenceId sequenceId, ProductData productData, IMetaInfo metaInfo, String eventType
41+
, EventConfirmationType confirmationType)
42+
: base(sequenceId, productData, metaInfo, confirmationType) {
43+
this.eventType = eventType;
44+
}
45+
46+
public ITextTestEvent(SequenceId sequenceId, ProductData productData, IMetaInfo metaInfo, String eventType
47+
)
48+
: this(sequenceId, productData, metaInfo, eventType, EventConfirmationType.ON_CLOSE) {
49+
}
50+
51+
public override String GetEventType() {
52+
return eventType;
53+
}
54+
}
55+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2021 iText Group NV
4+
Authors: iText Software.
5+
6+
This program is offered under a commercial and under the AGPL license.
7+
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
8+
9+
AGPL licensing:
10+
This program is free software: you can redistribute it and/or modify
11+
it under the terms of the GNU Affero General Public License as published by
12+
the Free Software Foundation, either version 3 of the License, or
13+
(at your option) any later version.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU Affero General Public License for more details.
19+
20+
You should have received a copy of the GNU Affero General Public License
21+
along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
*/
23+
using System;
24+
using Common.Logging;
25+
using iText.Events;
26+
27+
namespace iText.Events.Ecosystem {
28+
public class TestConfigurationEvent : AbstractITextConfigurationEvent {
29+
public const String MESSAGE = "Test configuration event was processed";
30+
31+
private static readonly ILog LOGGER = LogManager.GetLogger(typeof(TestConfigurationEvent));
32+
33+
protected internal override void DoAction() {
34+
LOGGER.Warn(MESSAGE);
35+
}
36+
}
37+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2021 iText Group NV
4+
Authors: iText Software.
5+
6+
This program is offered under a commercial and under the AGPL license.
7+
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
8+
9+
AGPL licensing:
10+
This program is free software: you can redistribute it and/or modify
11+
it under the terms of the GNU Affero General Public License as published by
12+
the Free Software Foundation, either version 3 of the License, or
13+
(at your option) any later version.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU Affero General Public License for more details.
19+
20+
You should have received a copy of the GNU Affero General Public License
21+
along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
*/
23+
using System;
24+
using iText.Events.Contexts;
25+
26+
namespace iText.Events.Ecosystem {
27+
public class TestMetaInfo : IMetaInfo {
28+
private readonly String metaData;
29+
30+
public TestMetaInfo(String metaData) {
31+
this.metaData = metaData;
32+
}
33+
34+
public virtual String GetMetaData() {
35+
return metaData;
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)