diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/java/org/apache/archiva/webapp/ui/services/api/RuntimeInfoServiceTest.java b/archiva-modules/archiva-web/archiva-webapp-js/src/test/java/org/apache/archiva/webapp/ui/services/api/RuntimeInfoServiceTest.java new file mode 100644 index 000000000..cce205c40 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/test/java/org/apache/archiva/webapp/ui/services/api/RuntimeInfoServiceTest.java @@ -0,0 +1,89 @@ +package org.apache.archiva.webapp.ui.services.api; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.webapp.ui.services.model.ApplicationRuntimeInfo; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.cxf.jaxrs.client.JAXRSClientFactory; +import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider; +import org.codehaus.redback.rest.services.AbstractRestServicesTest; +import org.junit.Before; +import org.junit.Test; + +import java.io.File; +import java.util.Collections; + +/** + * @author Olivier Lamy + */ +public class RuntimeInfoServiceTest + extends AbstractRestServicesTest +{ + @Override + @Before + public void startServer() + throws Exception + { + File appServerBase = new File( System.getProperty( "appserver.base" ) ); + + File jcrDirectory = new File( appServerBase, "jcr" ); + + if ( jcrDirectory.exists() ) + { + FileUtils.deleteDirectory( jcrDirectory ); + } + + super.startServer(); + } + + @Override + protected String getSpringConfigLocation() + { + return "classpath*:META-INF/spring-context.xml,classpath*:META-INF/spring-context-test.xml"; + } + + protected String getRestServicesPath() + { + return "restServices"; + } + + protected String getBaseUrl() + { + String baseUrlSysProps = System.getProperty( "archiva.baseRestUrl" ); + return StringUtils.isBlank( baseUrlSysProps ) ? "http://localhost:" + port : baseUrlSysProps; + } + + @Test + public void runtimeInfoService() + throws Exception + { + RuntimeInfoService service = + JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaUiServices/", + RuntimeInfoService.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + + ApplicationRuntimeInfo applicationRuntimeInfo = service.getApplicationRuntimeInfo( "en" ); + + assertEquals( System.getProperty( "expectedVersion" ), applicationRuntimeInfo.getVersion() ); + assertFalse( applicationRuntimeInfo.isJavascriptLog() ); + assertTrue( applicationRuntimeInfo.isLogMissingI18n() ); + + } +} diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repository.xml b/archiva-modules/archiva-web/archiva-webapp-js/src/test/repository.xml new file mode 100644 index 000000000..0be86ebbd --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/test/repository.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/resources/META-INF/spring-context-test.xml b/archiva-modules/archiva-web/archiva-webapp-js/src/test/resources/META-INF/spring-context-test.xml new file mode 100644 index 000000000..364578022 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/test/resources/META-INF/spring-context-test.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + scheduler1 + org.quartz.simpl.SimpleThreadPool + 2 + 4 + org.quartz.simpl.RAMJobStore + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file