Skip to content

Commit

Permalink
chore(ZNTA-2694): Upgrade Okapi to M36 (#982)
Browse files Browse the repository at this point in the history
* chore(ZNTA-2694): Upgrade Okapi to M35
* chore(ZNTA-2694): upgrade ICU4J to 62.1
* chore(ZNTA-2694): update tests
* chore(ZNTA-2694): fix HashUtilTest
* chore(ZNTA-2694): remove erroneous import
* fix(ZNTA-2694): upgrade Okapi to M36
* Remove okapi-cloudbees
* Update OkapiUtilTest to M36 behaviour
* Upgrade snakeyaml to 1.21
* Fix test comments
  • Loading branch information
djansen-redhat committed Aug 24, 2018
1 parent a310b43 commit 998454e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 39 deletions.
Expand Up @@ -35,6 +35,7 @@
import com.google.common.base.Charsets;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;

/**
* @author Carlos Munoz <a
Expand Down Expand Up @@ -70,10 +71,15 @@ public void singleSourceHash() {
assertThat(hashUtilHash).isEqualTo(testSingleContentHash);
}

@Test(expected = NullPointerException.class)
@Test
public void singleSourceHashNullIsInvalid() {
String nullString = null;
HashUtil.sourceHash(nullString);
try {
HashUtil.sourceHash(nullString);
fail("Should have had a NullPointer|IllegalArgument exception");
} catch (NullPointerException | IllegalArgumentException e) {
// Pass - can have one or the other?
}
}

@Test
Expand Down
18 changes: 3 additions & 15 deletions server/pom.xml
Expand Up @@ -40,7 +40,7 @@
<weld.se.version>${weld.version}</weld.se.version>
<weld.spi.version>2.3.Final </weld.spi.version>
<groovy.version>2.4.12</groovy.version>
<icu4j.version>56.1</icu4j.version>
<icu4j.version>62.1</icu4j.version>
<guava.version>23.5-jre</guava.version>
<gwt.version>2.8.0</gwt.version>
<lucene.version>5.3.1</lucene.version>
Expand All @@ -58,7 +58,7 @@
<seam.version>2.3.1.Final</seam.version>
<slf4j.version>1.7.25</slf4j.version>
<gwteventservice.version>1.2.1</gwteventservice.version>
<okapi.version>0.29</okapi.version>
<okapi.version>0.36</okapi.version>

<zanata.assets.version>10.4</zanata.assets.version>
<zanata.client.version>${project.version}</zanata.client.version>
Expand Down Expand Up @@ -376,7 +376,7 @@
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.16</version>
<version>1.21</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -1811,17 +1811,6 @@
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<repository>
<id>okapi-cloudbees-release</id>
<name>okapi-cloudbees-release</name>
<url>http://repository-okapi.forge.cloudbees.com/release/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<!-- Needed for GWT snapshots -->
<repository>
<id>google-maven-snapshot-repository</id>
Expand Down Expand Up @@ -2073,7 +2062,6 @@
<requireNoRepositories>
<allowedRepositories combine.children="append">
<allowedRepository>jboss-public-repository-group</allowedRepository>
<allowedRepository>okapi-cloudbees-release</allowedRepository>
<allowedRepository>google-maven-snapshot-repository</allowedRepository>
<allowedRepository>jcenter</allowedRepository>
</allowedRepositories>
Expand Down
Expand Up @@ -429,7 +429,7 @@ class TSAdapterTest : AbstractAdapterTest<TSAdapter>() {
}
}
try {
adapter.replaceLocaleInDocPart(event, LocaleId("en-GB"))
adapter.replaceLocaleInDocPart(event, LocaleId.fromBCP47("en-GB"))
fail("FileFormatAdapterException expected")
} catch (ffae: FileFormatAdapterException) {
// Pass
Expand Down
Expand Up @@ -98,7 +98,7 @@ public void mergeTextFlowWithOneFromChange() {
from.add(tf1);

HDocument to = new HDocument();

to.setLocale(new HLocale(LocaleId.EN_US));
boolean changed =
resourceUtils.transferFromTextFlows(from, to,
new HashSet<String>(), 1);
Expand All @@ -110,6 +110,7 @@ public void mergeTextFlowWithOneFromChange() {
public void mergeChangedTextFlow() {
// set up HDocument with a text flow
HDocument to = new HDocument();
to.setLocale(new HLocale(LocaleId.EN_US));
int originalTFRevision = 1;
to.setRevision(originalTFRevision);
HTextFlow originalTF = new HTextFlow(to, "id", "original text");
Expand Down
Expand Up @@ -47,6 +47,7 @@
import org.zanata.cache.InfinispanTestCacheContainer;
import org.zanata.cdi.TestTransaction;
import org.zanata.common.EntityStatus;
import org.zanata.common.LocaleId;
import org.zanata.dao.DocumentDAO;
import org.zanata.dao.LocaleDAO;
import org.zanata.dao.ProjectIterationDAO;
Expand Down Expand Up @@ -398,6 +399,7 @@ public void testCopyRawDocument() throws Exception {
@InRequestScope
public void testCopyTextFlow() throws Exception {
HDocument dummyDoc = getDummyDocument();
dummyDoc.setLocale(new HLocale(LocaleId.EN_US));
HTextFlow existingTextFlow = textFlowDAO.findById(1L);
HTextFlow newTextFlow =
service.copyTextFlow(dummyDoc, existingTextFlow);
Expand Down
Expand Up @@ -12,47 +12,52 @@ public class OkapiUtilTest {
"Graphic Design",
"the object is passed up to the UI tier",

// 4 (tokens in current line) [0 (total)]
"// in the first session\n" +
"Cat cat = (Cat) firstSession.load(Cat.class, catID);\n" +
"\n" +
// 6 [10] (a.b is one token)
"Cat cat = (Cat) firstSession.load(Cat.class, catID);\n\n" +
// 7 [17]
"// in a higher tier of the application\n" +
// 4 [21]
"Cat mate = new Cat();\n" +
"cat.setMate(mate);\n" +
"\n" +
// 2 [23] (a.b is one token)
"cat.setMate(mate);\n\n" +
// 5 [28]
"// later, in a new session\n" +
// 10 [38] (a.b is one token, non-null is one token)
"secondSession.saveOrUpdate(cat); // update existing state (cat has a non-null id)\n" +
// 11 [49] (a.b is one token)
"secondSession.saveOrUpdate(mate); // save the new instance (mate has a null id)",

"<filename class=\"directory\">/var/lib/ricci</filename>",

// NB okapi says 2, but looks like 4. perhaps
// something.ext counts as one word?
"https://cdn.redhat.com",

// NB okapi says 3, but looks like 4
"/etc/rhsm/rhsm.conf",
};
// @formatter:on
// These counts represent the expected word counts for the strings listed
// above.
private long[] count = { 2, 2, 9,
// Okapi says the fourth string has 49 words, but it looks like 54
// ?!
// TODO work out why
49, 3, 2, 3, };
private long[] count = {
// Not including tags
2,
// Simple text
2, 9,
// Non-null is 1 word, firstSession.load is 1
49,
// Not including tags
3,
// https and cdn.redhat.com
2,
// Slashes
3 };

@Test
public void testCountWords() {
countWords(null, "en-US");
int i = 0;
for (String s : strings) {
long expected = count[i++];
long n = countWords(s, "en-US");
Assert.assertEquals(expected, n);
// if (n == 0)
// Assert.fail(s + ":" + n);
// else
// System.out.println(n);
// System.out.println(s + ": Expecting " + expected + " words");
Assert.assertEquals(expected, countWords(s, "en-US"));
}
}

Expand Down

0 comments on commit 998454e

Please sign in to comment.