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 org.apache.archiva.web.api.RuntimeInfoService;
22 import org.apache.archiva.web.model.ApplicationRuntimeInfo;
23 import org.apache.commons.io.FileUtils;
24 import org.apache.commons.lang.StringUtils;
25 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
26 import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
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";
66 protected String getRestServicesPath()
68 return "restServices";
71 protected String getBaseUrl()
73 String baseUrlSysProps = System.getProperty( "archiva.baseRestUrl" );
74 return StringUtils.isBlank( baseUrlSysProps ) ? "http://localhost:" + port : baseUrlSysProps;
78 public void runtimeInfoService()
81 RuntimeInfoService service =
82 JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaUiServices/",
83 RuntimeInfoService.class,
84 Collections.singletonList( new JacksonJaxbJsonProvider() ) );
86 ApplicationRuntimeInfo applicationRuntimeInfo = service.getApplicationRuntimeInfo( "en" );
88 assertEquals( System.getProperty( "expectedVersion" ), applicationRuntimeInfo.getVersion() );
89 assertFalse( applicationRuntimeInfo.isJavascriptLog() );
90 assertTrue( applicationRuntimeInfo.isLogMissingI18n() );