|
1 | 1 | package com.dotcms.publishing; |
2 | 2 |
|
3 | 3 | import com.dotcms.LicenseTestUtil; |
4 | | -import com.dotcms.api.web.HttpServletRequestThreadLocal; |
5 | | -import com.dotcms.api.web.HttpServletResponseThreadLocal; |
6 | 4 | import com.dotcms.contenttype.model.field.Field; |
7 | 5 | import com.dotcms.contenttype.model.field.TextField; |
8 | 6 | import com.dotcms.contenttype.model.type.ContentType; |
|
34 | 32 | import com.dotcms.experiments.model.Experiment; |
35 | 33 | import com.dotcms.experiments.model.ExperimentVariant; |
36 | 34 | import com.dotcms.languagevariable.business.LanguageVariableAPI; |
37 | | -import com.dotcms.mock.request.MockAttributeRequest; |
38 | 35 | import com.dotcms.publisher.assets.bean.PushedAsset; |
39 | 36 | import com.dotcms.publisher.bundle.bean.Bundle; |
40 | 37 | import com.dotcms.publisher.bundle.business.BundleFactoryImpl; |
|
52 | 49 | import com.dotcms.publishing.manifest.ManifestItem; |
53 | 50 | import com.dotcms.publishing.manifest.ManifestItem.ManifestInfoBuilder; |
54 | 51 | import com.dotcms.publishing.manifest.ManifestReason; |
55 | | -import com.dotcms.rendering.velocity.viewtools.content.ContentTool; |
56 | | -import com.dotcms.rendering.velocity.viewtools.content.util.ContentUtils; |
57 | 52 | import com.dotcms.test.util.FileTestUtil; |
58 | 53 | import com.dotcms.util.IntegrationTestInitService; |
59 | 54 | import com.dotcms.variant.model.Variant; |
|
84 | 79 | import com.dotmarketing.portlets.workflows.model.WorkflowStep; |
85 | 80 | import com.dotmarketing.util.Config; |
86 | 81 | import com.dotmarketing.util.Logger; |
87 | | -import com.dotmarketing.util.PageMode; |
88 | | -import com.dotmarketing.util.WebKeys; |
89 | 82 | import com.liferay.portal.model.User; |
90 | 83 | import com.liferay.util.FileUtil; |
91 | 84 | import com.liferay.util.StringPool; |
|
104 | 97 | import org.junit.Test; |
105 | 98 | import org.junit.runner.RunWith; |
106 | 99 |
|
107 | | -import javax.servlet.http.HttpServletRequest; |
108 | | -import javax.servlet.http.HttpServletResponse; |
109 | | -import java.io.*; |
| 100 | +import java.io.BufferedInputStream; |
| 101 | +import java.io.BufferedReader; |
| 102 | +import java.io.File; |
| 103 | +import java.io.FileInputStream; |
| 104 | +import java.io.FileReader; |
| 105 | +import java.io.IOException; |
| 106 | +import java.io.InputStream; |
| 107 | +import java.io.OutputStream; |
110 | 108 | import java.net.HttpURLConnection; |
111 | 109 | import java.net.InetSocketAddress; |
112 | 110 | import java.nio.file.Files; |
|
128 | 126 | import static com.dotcms.variant.VariantAPI.DEFAULT_VARIANT; |
129 | 127 | import static org.junit.Assert.assertEquals; |
130 | 128 | import static org.junit.Assert.assertTrue; |
131 | | -import static org.mockito.Mockito.mock; |
132 | 129 |
|
133 | 130 |
|
134 | 131 | @RunWith(DataProviderRunner.class) |
@@ -1455,189 +1452,4 @@ public void testFilterDescriptors() throws IOException { |
1455 | 1452 | } |
1456 | 1453 |
|
1457 | 1454 | } |
1458 | | - |
1459 | | - /** |
1460 | | - * Method to test: {@link PublisherAPIImpl#publish(PublisherConfig)} |
1461 | | - * When: |
1462 | | - * - Create a ContentType called grandChild with just one field: title. |
1463 | | - * - Create a ContentType called child with 2 field: title and a relationship field pointing to grandChild. |
1464 | | - * - Create a ContentType called parent with 2 field: title and a relationship field pointing to child. |
1465 | | - * - Create a grandChild Contentlet with title equals to 'C' |
1466 | | - * - Create a child Contentlet with title equals to 'B' and related with C |
1467 | | - * - Create a parent Contentlet with title equals to 'A' and related with B |
1468 | | - * - Push A |
1469 | | - * |
1470 | | - * Should: send the 3 ContentTypes, the 3 Contentlets and the 2 Relationship |
1471 | | - * |
1472 | | - * @throws DotDataException |
1473 | | - * @throws DotSecurityException |
1474 | | - * @throws DotPublishingException |
1475 | | - * @throws IOException |
1476 | | - */ |
1477 | | - @Test |
1478 | | - public void pushSecondLevelRelatedContent() throws DotDataException, DotSecurityException, DotPublishingException, IOException { |
1479 | | - final Class<? extends Publisher> publisher = GenerateBundlePublisher.class; |
1480 | | - final Host host = new SiteDataGen().nextPersisted(); |
1481 | | - |
1482 | | - final Field grandChildTitle = new FieldDataGen().name("title").next(); |
1483 | | - |
1484 | | - final ContentType contentTypeGrandChild = new ContentTypeDataGen() |
1485 | | - .host(host) |
1486 | | - .field(grandChildTitle) |
1487 | | - .nextPersisted(); |
1488 | | - |
1489 | | - |
1490 | | - final Field childTitle = new FieldDataGen().name("title").next(); |
1491 | | - |
1492 | | - ContentType contentTypeChild = new ContentTypeDataGen() |
1493 | | - .host(host) |
1494 | | - .field(childTitle) |
1495 | | - .nextPersisted(); |
1496 | | - |
1497 | | - Relationship relationship1 = new FieldRelationshipDataGen() |
1498 | | - .child(contentTypeGrandChild) |
1499 | | - .parent(contentTypeChild) |
1500 | | - .nextPersisted(); |
1501 | | - |
1502 | | - contentTypeChild = APILocator.getContentTypeAPI(APILocator.systemUser()).find(contentTypeChild.variable()); |
1503 | | - |
1504 | | - final Field parentTitle = new FieldDataGen().name("title").next(); |
1505 | | - |
1506 | | - ContentType contentTypeParent = new ContentTypeDataGen() |
1507 | | - .host(host) |
1508 | | - .field(parentTitle) |
1509 | | - .nextPersisted(); |
1510 | | - |
1511 | | - final Relationship relationship2 = new FieldRelationshipDataGen() |
1512 | | - .child(contentTypeChild) |
1513 | | - .parent(contentTypeParent) |
1514 | | - .nextPersisted(); |
1515 | | - |
1516 | | - contentTypeParent = APILocator.getContentTypeAPI(APILocator.systemUser()).find(contentTypeParent.variable()); |
1517 | | - |
1518 | | - final Contentlet grandChildContent = new ContentletDataGen(contentTypeGrandChild).setProperty("title", "C").nextPersisted(); |
1519 | | - final Contentlet childContent = new ContentletDataGen(contentTypeChild) |
1520 | | - .setProperty(relationship1.getChildRelationName(), Arrays.asList(grandChildContent)) |
1521 | | - .setProperty("title", "B") |
1522 | | - .nextPersisted(); |
1523 | | - final Contentlet parentContent = new ContentletDataGen(contentTypeParent) |
1524 | | - .setProperty(relationship2.getChildRelationName(), Arrays.asList(childContent)) |
1525 | | - .setProperty("title", "A") |
1526 | | - .nextPersisted(); |
1527 | | - |
1528 | | - final FilterDescriptor filterDescriptor = new FilterDescriptorDataGen().dependencies(true).relationships(true).nextPersisted(); |
1529 | | - final PublisherAPIImpl publisherAPI = new PublisherAPIImpl(); |
1530 | | - |
1531 | | - final PushPublisherConfig config = new PushPublisherConfig(); |
1532 | | - config.setPublishers(list(publisher)); |
1533 | | - config.setOperation(PublisherConfig.Operation.PUBLISH); |
1534 | | - config.setLuceneQueries(list()); |
1535 | | - config.setId("PublisherAPIImplTest_" + System.currentTimeMillis()); |
1536 | | - |
1537 | | - new BundleDataGen() |
1538 | | - .pushPublisherConfig(config) |
1539 | | - .addAssets(list(parentContent)) |
1540 | | - .filter(filterDescriptor) |
1541 | | - .operation(PublisherConfig.Operation.PUBLISH) |
1542 | | - .setSavePublishQueueElements(true) |
1543 | | - .nextPersisted(); |
1544 | | - |
1545 | | - final PublishStatus publish = publisherAPI.publish(config); |
1546 | | - |
1547 | | - File bundleRoot = publish.getOutputFiles().get(0); |
1548 | | - |
1549 | | - final File extractHere = new File(bundleRoot.getParent() + File.separator + config.getName()); |
1550 | | - extractTarArchive(bundleRoot, extractHere); |
1551 | | - |
1552 | | - List<Object> expected = Arrays.asList(contentTypeParent, |
1553 | | - contentTypeChild, contentTypeGrandChild, |
1554 | | - grandChildContent, childContent, |
1555 | | - parentContent, relationship2, relationship1); |
1556 | | - |
1557 | | - for (Object assetToAssert : expected) { |
1558 | | - FileTestUtil.assertBundleFile(extractHere, assetToAssert); |
1559 | | - } |
1560 | | - } |
1561 | | - |
1562 | | - /** |
1563 | | - * Method to test: {@link PublisherAPIImpl#publish(PublisherConfig)} |
1564 | | - * When: |
1565 | | - * - Create a ContentType with 2 fields: title and a relationship pointing to itself. |
1566 | | - * - Create a Contentlet with title equals to 'A' pointing to 'B' |
1567 | | - * - Create a Contentlet with title equals to 'B' pointing to 'C' |
1568 | | - * - Create a Contentlet with title equals to 'C' pointing to 'A' |
1569 | | - * - Push A |
1570 | | - * |
1571 | | - * Should: send the ContentType, the 3 Contentlets and the Relationship without any OutOfMemory Exception |
1572 | | - * |
1573 | | - * @throws DotDataException |
1574 | | - * @throws DotSecurityException |
1575 | | - * @throws DotPublishingException |
1576 | | - * @throws IOException |
1577 | | - */ |
1578 | | - @Test |
1579 | | - public void pushCiclyReferenceContentlets() throws DotDataException, DotSecurityException, DotPublishingException, IOException { |
1580 | | - final Class<? extends Publisher> publisher = GenerateBundlePublisher.class; |
1581 | | - final Host host = new SiteDataGen().nextPersisted(); |
1582 | | - |
1583 | | - final Field titleField = new FieldDataGen().name("title").next(); |
1584 | | - |
1585 | | - ContentType contentType = new ContentTypeDataGen() |
1586 | | - .host(host) |
1587 | | - .field(titleField) |
1588 | | - .nextPersisted(); |
1589 | | - |
1590 | | - Relationship relationship = new FieldRelationshipDataGen() |
1591 | | - .child(contentType) |
1592 | | - .parent(contentType) |
1593 | | - .nextPersisted(); |
1594 | | - |
1595 | | - contentType = APILocator.getContentTypeAPI(APILocator.systemUser()).find(contentType.variable()); |
1596 | | - |
1597 | | - final Contentlet contentB = new ContentletDataGen(contentType).setProperty("title", "B").nextPersisted(); |
1598 | | - final Contentlet contentC = new ContentletDataGen(contentType).setProperty("title", "B").nextPersisted(); |
1599 | | - final Contentlet contentA = new ContentletDataGen(contentType) |
1600 | | - .setProperty(relationship.getChildRelationName(), Arrays.asList(contentB)) |
1601 | | - .setProperty("title", "A") |
1602 | | - .nextPersisted(); |
1603 | | - |
1604 | | - final Contentlet checkoutB = ContentletDataGen.checkout(contentB); |
1605 | | - checkoutB.setProperty(relationship.getChildRelationName(), Arrays.asList(contentC)); |
1606 | | - ContentletDataGen.checkin(checkoutB); |
1607 | | - |
1608 | | - final Contentlet checkoutC = ContentletDataGen.checkout(contentC); |
1609 | | - checkoutC.setProperty(relationship.getChildRelationName(), Arrays.asList(contentA)); |
1610 | | - ContentletDataGen.checkin(checkoutC); |
1611 | | - |
1612 | | - final FilterDescriptor filterDescriptor = new FilterDescriptorDataGen().dependencies(true).relationships(true).nextPersisted(); |
1613 | | - final PublisherAPIImpl publisherAPI = new PublisherAPIImpl(); |
1614 | | - |
1615 | | - final PushPublisherConfig config = new PushPublisherConfig(); |
1616 | | - config.setPublishers(list(publisher)); |
1617 | | - config.setOperation(PublisherConfig.Operation.PUBLISH); |
1618 | | - config.setLuceneQueries(list()); |
1619 | | - config.setId("PublisherAPIImplTest_" + System.currentTimeMillis()); |
1620 | | - |
1621 | | - new BundleDataGen() |
1622 | | - .pushPublisherConfig(config) |
1623 | | - .addAssets(list(contentA)) |
1624 | | - .filter(filterDescriptor) |
1625 | | - .operation(PublisherConfig.Operation.PUBLISH) |
1626 | | - .setSavePublishQueueElements(true) |
1627 | | - .nextPersisted(); |
1628 | | - |
1629 | | - final PublishStatus publish = publisherAPI.publish(config); |
1630 | | - |
1631 | | - File bundleRoot = publish.getOutputFiles().get(0); |
1632 | | - |
1633 | | - final File extractHere = new File(bundleRoot.getParent() + File.separator + config.getName()); |
1634 | | - extractTarArchive(bundleRoot, extractHere); |
1635 | | - |
1636 | | - List<Object> expected = Arrays.asList(contentType, |
1637 | | - contentA, contentB, contentC, relationship); |
1638 | | - |
1639 | | - for (Object assetToAssert : expected) { |
1640 | | - FileTestUtil.assertBundleFile(extractHere, assetToAssert); |
1641 | | - } |
1642 | | - } |
1643 | 1455 | } |
0 commit comments