001package org.apache.fulcrum.intake; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import static org.junit.jupiter.api.Assertions.assertEquals; 023import static org.junit.jupiter.api.Assertions.assertNotNull; 024import static org.junit.jupiter.api.Assertions.assertTrue; 025import static org.junit.jupiter.api.Assertions.fail; 026 027import java.io.File; 028 029import org.apache.fulcrum.intake.model.Group; 030import org.apache.fulcrum.testcontainer.BaseUnit5Test; 031import org.apache.logging.log4j.LogManager; 032import org.apache.logging.log4j.Logger; 033import org.junit.jupiter.api.BeforeEach; 034import org.junit.jupiter.api.Test; 035import org.junit.jupiter.api.TestInfo; 036 037 038/** 039 * Test for Intake service 040 * 041 * @author <a href="mailto:epugh@upstate.com">epugh@upstate.com</a> 042 * @version $Id$ 043 */ 044public class IntakeServiceTest extends BaseUnit5Test 045{ 046 private static final File BASEDIR = new File("."); 047 private IntakeService intakeService = null; 048 049 protected static final Logger log = LogManager.getLogger( IntakeServiceTest.class ); 050 051 /** 052 * Defines the testcase for JUnit5. 053 * 054 * @param testInfo defining the test 055 */ 056 public IntakeServiceTest(TestInfo testInfo) 057 { 058 } 059 060 /** 061 * @throws Exception generic exception 062 */ 063 @BeforeEach 064 public void setUp() throws Exception 065 { 066 File appData = new File( BASEDIR, "target/appData.ser"); 067 if(appData.exists()){ 068 appData.delete(); 069 } 070 try { 071 intakeService = (IntakeService) this.lookup( IntakeService.class.getName() ); 072 } catch (Throwable e) { 073 fail(e.getMessage()); 074 } 075 assertNotNull(intakeService); 076 077 } 078 079 /** 080 * @throws Exception generic exception 081 */ 082 @Test 083 public void testBasicConfigLoads() throws Exception 084 { 085 Group group = intakeService.getGroup("LoginGroup"); 086 087 File file = new File( BASEDIR, "target/appData.ser"); 088 assertTrue(file.exists(), "Make sure serialized data file exists:" + file); 089 090 assertNotNull(group); 091 assertEquals("loginGroupKey", group.getGID()); 092 assertEquals("LoginGroup", group.getIntakeGroupName()); 093 094 Group group2 = intakeService.getGroup("AnotherGroup"); 095 assertNotNull(group2); 096 assertEquals("anotherGroupKey", group2.getGID()); 097 assertEquals("AnotherGroup", group2.getIntakeGroupName()); 098 } 099 100}