7

組み込みのTomcat Webサーバーを使用し、SDKを介してOpenKMを使用するspring-boot 2.1.2.RELEASEアプリケーションがあります。

restassured現在、 lib を使用して REST 呼び出しを行い、応答構造を検証するいくつかの統合テストがあります。私の考えは、OpenKM.warこの wmbedded tomcat に統合し、別のサーバーで openkm アプリケーションを実行する必要なく、このテストを実行できるようにすることです。

これは、openkm.war を読み取って展開する組み込み tomcat を作成する方法です。

@Configuration
public class TomcatConfig {
    @Bean
    public ServletWebServerFactory servletContainer() {
        TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory() {
            @Override
            protected void postProcessContext(Context context) {
                SecurityConstraint securityConstraint = new SecurityConstraint();
                securityConstraint.setUserConstraint("CONFIDENTIAL");
                SecurityCollection collection = new SecurityCollection();
                collection.addPattern("/*");
                securityConstraint.addCollection(collection);
                context.addConstraint(securityConstraint);
            }

            @Override
            protected TomcatWebServer getTomcatWebServer(Tomcat tomcat) {
                new File(tomcat.getServer().getCatalinaBase(), "webapp").mkdirs();
                try {
                    tomcat.addWebapp("/okm", new ClassPathResource("webapp/openkm.war").getFile().toString());
                } catch (Exception ex) {
                    throw new IllegalStateException("Failed to add okm", ex);
                }
                return super.getTomcatWebServer(tomcat);
            }
        };

        tomcat.addAdditionalTomcatConnectors(redirectConnector());
        return tomcat;
    }

    private Connector redirectConnector() {
        Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
        connector.setScheme("http");
        connector.setPort(8080);
        connector.setSecure(false);
        connector.setRedirectPort(8443);
        return connector;
    }
}

展開は、openkm に同梱されているスタンドアロンの tomcat Web サーバーよりも時間がかかりますが、展開されます。

ただし、展開プロセスは次のように失敗します。

IOException parsing XML document from URL [file:/tmp/tomcat.2352216859213135410.8080/openkm.xml]; nested exception is java.io.FileNotFoundException: /tmp/tomcat.2352216859213135410.8080/openkm.xml (No such file or directory)

openkm.war ファイルと一緒にこのファイル (および server.xml、context.xml) を持っていますが、埋め込まれた tomcat はそれを認識していないようです。

これらのファイルはすべて にありますsrc/main/resources/webapp

それで、私はどの構成要素が欠けているか、または私が望むものを達成するためにより良いものが他にあるかどうかを知りたいですか?

4

1 に答える 1