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.redback.rest.services.AbstractRestServicesTest;
23 import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
24 import org.apache.archiva.web.api.RuntimeInfoService;
25 import org.apache.archiva.web.model.ApplicationRuntimeInfo;
26 import org.apache.commons.lang.StringUtils;
27 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
28 import org.apache.cxf.jaxrs.client.WebClient;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
33 import java.nio.file.Files;
34 import java.nio.file.Path;
35 import java.nio.file.Paths;
36 import java.util.Collections;
39 * @author Olivier Lamy
41 @RunWith( ArchivaBlockJUnit4ClassRunner.class )
42 public class RuntimeInfoServiceTest
43 extends AbstractRestServicesTest
47 public void startServer()
50 Path appServerBase = Paths.get( System.getProperty( "appserver.base" ) );
52 Path jcrDirectory = appServerBase.resolve( "jcr" );
54 if ( Files.exists(jcrDirectory) )
56 org.apache.archiva.common.utils.FileUtils.deleteDirectory( jcrDirectory );
63 protected String getSpringConfigLocation()
65 return "classpath*:META-INF/spring-context.xml,classpath:/spring-context-with-jcr.xml";
69 protected String getRestServicesPath()
71 return "restServices";
74 protected String getBaseUrl()
76 String baseUrlSysProps = System.getProperty( "archiva.baseRestUrl" );
77 return StringUtils.isBlank( baseUrlSysProps ) ? "http://localhost:" + port : baseUrlSysProps;
81 public void runtimeInfoService()
84 RuntimeInfoService service =
85 JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaUiServices/",
86 RuntimeInfoService.class,
87 Collections.singletonList( new JacksonJaxbJsonProvider() ) );
89 WebClient.client(service).header("Referer","http://localhost");
90 ApplicationRuntimeInfo applicationRuntimeInfo = service.getApplicationRuntimeInfo( "en" );
92 assertEquals( System.getProperty( "expectedVersion" ), applicationRuntimeInfo.getVersion() );
93 assertFalse( applicationRuntimeInfo.isJavascriptLog() );
94 assertTrue( applicationRuntimeInfo.isLogMissingI18n() );