1 package org.apache.archiva;
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
22 import org.apache.archiva.web.api.RuntimeInfoService;
23 import org.apache.archiva.web.model.ApplicationRuntimeInfo;
24 import org.apache.commons.io.FileUtils;
25 import org.apache.commons.lang.StringUtils;
26 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
27 import org.apache.archiva.redback.rest.services.AbstractRestServicesTest;
28 import org.junit.Before;
29 import org.junit.Test;
32 import java.util.Collections;
33 import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
34 import org.junit.runner.RunWith;
37 * @author Olivier Lamy
39 @RunWith( ArchivaBlockJUnit4ClassRunner.class )
40 public class RuntimeInfoServiceTest
41 extends AbstractRestServicesTest
45 public void startServer()
48 File appServerBase = new File( System.getProperty( "appserver.base" ) );
50 File jcrDirectory = new File( appServerBase, "jcr" );
52 if ( jcrDirectory.exists() )
54 FileUtils.deleteDirectory( jcrDirectory );
61 protected String getSpringConfigLocation()
63 return "classpath*:META-INF/spring-context.xml,classpath:/spring-context-with-jcr.xml";
67 protected String getRestServicesPath()
69 return "restServices";
72 protected String getBaseUrl()
74 String baseUrlSysProps = System.getProperty( "archiva.baseRestUrl" );
75 return StringUtils.isBlank( baseUrlSysProps ) ? "http://localhost:" + port : baseUrlSysProps;
79 public void runtimeInfoService()
82 RuntimeInfoService service =
83 JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaUiServices/",
84 RuntimeInfoService.class,
85 Collections.singletonList( new JacksonJaxbJsonProvider() ) );
87 ApplicationRuntimeInfo applicationRuntimeInfo = service.getApplicationRuntimeInfo( "en" );
89 assertEquals( System.getProperty( "expectedVersion" ), applicationRuntimeInfo.getVersion() );
90 assertFalse( applicationRuntimeInfo.isJavascriptLog() );
91 assertTrue( applicationRuntimeInfo.isLogMissingI18n() );