Skip to content

Commit

Permalink
Merge pull request #933 from fanf/bug_7302/test_testpackagereader_sca…
Browse files Browse the repository at this point in the history
…la_in_error

Fixes #7302: Test TestPackageReader.scala in error
  • Loading branch information
VinceMacBuche committed Oct 23, 2015
2 parents 1f4d7c9 + 9995db4 commit e78a38e
Showing 1 changed file with 36 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,50 @@

package com.normation.cfclerk.services

import junit.framework.TestSuite
import java.io.File

import scala.annotation.elidable
import scala.annotation.elidable.ASSERTION
import scala.collection.Seq

import com.normation.cfclerk.domain.Cf3PromisesFileTemplateId
import com.normation.cfclerk.domain.RootTechniqueCategoryId
import com.normation.cfclerk.domain.TechniqueVersion
import com.normation.cfclerk.services.impl.FSTechniqueReader
import com.normation.cfclerk.services.impl.SystemVariableSpecServiceImpl
import com.normation.cfclerk.xmlparsers.Cf3PromisesFileTemplateParser
import com.normation.cfclerk.xmlparsers.SectionSpecParser
import com.normation.cfclerk.xmlparsers.TechniqueParser
import com.normation.cfclerk.xmlparsers.VariableSpecParser

import org.apache.commons.io.IOUtils
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit._
import org.junit.Assert._
import org.junit.runner.RunWith
import org.junit.runners.BlockJUnit4ClassRunner
import scala.collection._
import com.normation.cfclerk.domain._
import com.normation.cfclerk.xmlparsers.TechniqueParser
import org.springframework.context.{ ApplicationContext, ApplicationContextAware }
import org.springframework.test.context.ContextConfiguration
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
import java.io.File
import org.apache.commons.io.IOUtils
import com.normation.cfclerk.services.impl._

@RunWith(classOf[SpringJUnit4ClassRunner])
@ContextConfiguration(Array("file:src/test/resources/spring-config-test.xml"))
@RunWith(classOf[BlockJUnit4ClassRunner])
class TestPackageReader {

@Autowired
val policyParser: TechniqueParser = null

lazy val reader = new FSTechniqueReader(
policyParser,
"src/test/resources/techniquesRoot",
"metadata.xml",
"category.xml",
"expected_reports.csv")
{
val variableSpecParser = new VariableSpecParser
new TechniqueParser(
variableSpecParser
, new SectionSpecParser(variableSpecParser)
, new Cf3PromisesFileTemplateParser
, new SystemVariableSpecServiceImpl
)
}
, "src/test/resources/techniquesRoot"
, "metadata.xml"
, "category.xml"
, "expected_reports.csv"
)

@Test
def testReadPackage() {

val infos = reader.readTechniques
assertEquals(3, infos.subCategories.size)

Expand Down Expand Up @@ -154,4 +165,4 @@ class TestPackageReader {
assertTrue(cat1_1_1.packageIds.forall(id => id.version == TechniqueVersion("1.0")))

}
}
}

0 comments on commit e78a38e

Please sign in to comment.