Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
sbraconnier committed Jun 29, 2022
1 parent ac9260a commit 0e13ff5
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@

package org.jodconverter.local.office;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.jodconverter.core.office.AbstractOfficeManagerPool;
import org.jodconverter.core.office.InstalledOfficeManagerHolder;
import org.jodconverter.core.office.OfficeUtils;
import org.jodconverter.core.util.AssertUtils;
import org.jodconverter.core.util.StringUtils;
import org.jodconverter.local.process.ProcessManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
* Default {@link org.jodconverter.core.office.OfficeManager} implementation that uses a pool of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,7 @@ class LocalOfficeProcessManager {
instanceProfileDir =
new File(
workingDir,
".jodconverter_"
+ officeUrl
.getConnectString()
.replace(',', '_')
.replace('=', '-'));
".jodconverter_" + officeUrl.getConnectString().replace(',', '_').replace('=', '-'));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ class OfficeUrl {
// Here we must use a try catch since OpenOffice and LibreOffice doesn't
// have the same UnoUrl.parseUnoUrl signature
try {
//return UnoUrl.parseUnoUrl(
// return UnoUrl.parseUnoUrl(
// "socket,host=" + h + ",port=" + port + ";urp;StarOffice.ServiceManager");
return UnoUrl.parseUnoUrl(
"socket,host=" + h + ",port=" + port + ",tcpNoDelay=1;urp;StarOffice.ServiceManager");
"socket,host=" + h + ",port=" + port + ",tcpNoDelay=1;urp;StarOffice.ServiceManager");
} catch (Exception ex) {
throw new IllegalArgumentException(ex);
}
Expand Down Expand Up @@ -134,14 +134,15 @@ public UnoUrl getUnoUrl() {

/**
* Returns the string that should be used as --accept argument when an office process is launched.
*
* @return The accept string.
*/
public String getAcceptString() {
return unoUrl.getConnectionAndParametersAsString()
+ ";"
+ unoUrl.getProtocolAndParametersAsString()
+ ";"
+ unoUrl.getRootOid();
+ ";"
+ unoUrl.getProtocolAndParametersAsString()
+ ";"
+ unoUrl.getRootOid();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@ public boolean isConnected() {
@Override
public void connect() throws OfficeConnectionException {
if (throwConnectException) {
throw new OfficeConnectionException(
"Could not connect.", url.getConnectString());
throw new OfficeConnectionException("Could not connect.", url.getConnectString());
}
if (connectSleep > 0L) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ void shouldInitializedManagerWithDefaultValues() {
DEFAULT_CONNECT_TIMEOUT,
DEFAULT_CONNECT_RETRY_INTERVAL,
DEFAULT_CONNECT_FAIL_FAST,
new OfficeUrl(DEFAULT_HOSTNAME, 2002)
.getConnectString()));
new OfficeUrl(DEFAULT_HOSTNAME, 2002).getConnectString()));
}
}

Expand Down Expand Up @@ -168,8 +167,7 @@ void withNullValues_ShouldInitializedManagerWithDefaultValues() {
DEFAULT_CONNECT_TIMEOUT,
DEFAULT_CONNECT_RETRY_INTERVAL,
DEFAULT_CONNECT_FAIL_FAST,
new OfficeUrl(DEFAULT_HOSTNAME, 2002)
.getConnectString()));
new OfficeUrl(DEFAULT_HOSTNAME, 2002).getConnectString()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ void withNullPortNumberAndNullPipeName_ShouldReturnOfficeUrlWithDefaultPortNumbe
.satisfies(
urls ->
assertThat(urls.get(0).getConnectString())
.isEqualTo(
new OfficeUrl(LocalOfficeUtils.DEFAULT_PORT)
.getConnectString()));
.isEqualTo(new OfficeUrl(LocalOfficeUtils.DEFAULT_PORT).getConnectString()));
}

@Test
Expand All @@ -123,9 +121,7 @@ void withNullPortNumberAndEmptyPipeName_ShouldReturnOfficeUrlWithDefaultPortNumb
.satisfies(
urls ->
assertThat(urls.get(0).getConnectString())
.isEqualTo(
new OfficeUrl(LocalOfficeUtils.DEFAULT_PORT)
.getConnectString()));
.isEqualTo(new OfficeUrl(LocalOfficeUtils.DEFAULT_PORT).getConnectString()));
}

@Test
Expand All @@ -136,9 +132,7 @@ void withEmptyPortNumberAndEmptyPipeName_ShouldReturnOfficeUrlWithDefaultPortNum
.satisfies(
urls ->
assertThat(urls.get(0).getConnectString())
.isEqualTo(
new OfficeUrl(LocalOfficeUtils.DEFAULT_PORT)
.getConnectString()));
.isEqualTo(new OfficeUrl(LocalOfficeUtils.DEFAULT_PORT).getConnectString()));
}

@Test
Expand All @@ -149,9 +143,7 @@ void withEmptyPortNumberAndNullPipeName_ShouldReturnOfficeUrlWithDefaultPortNumb
.satisfies(
urls ->
assertThat(urls.get(0).getConnectString())
.isEqualTo(
new OfficeUrl(LocalOfficeUtils.DEFAULT_PORT)
.getConnectString()));
.isEqualTo(new OfficeUrl(LocalOfficeUtils.DEFAULT_PORT).getConnectString()));
}

@Test
Expand Down

0 comments on commit 0e13ff5

Please sign in to comment.