Skip to content

Commit

Permalink
Fix deprecated logging functions (#824)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwendland authored Mar 18, 2024
1 parent cac17f3 commit c61e61e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class OrderEvaluator(val baseNodes: Collection<Node>, val order: Order) : Evalua
val usedBases =
syntaxTree.filterIsInstanceToList<TerminalOrderNode>().map { it.baseName }.toSet()
if (usedBases.size > 1) {
logger.warn("Order statement contains more than one base. Not supported.")
logger.warn { "Order statement contains more than one base. Not supported." }
return emptySet()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object VersionProvider {
if (
!props.containsKey("project.name") || props.getProperty("project.name").lowercase() != "codyze"
) {
logger.warn("Could not find correct version properties file")
logger.warn { "Could not find correct version properties file" }
props.clear()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2024, Fraunhofer AISEC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.fraunhofer.aisec.codyze.core

import org.junit.jupiter.api.Test
import java.io.FileOutputStream
import java.util.Properties
import kotlin.test.assertEquals

class VersionProviderTest {

@Test
fun `test initialisation from properties file with incorrect project name`() {
val properties = Properties()

/* get the property file and load it; we want to fail if we can't find the property file to begin with */
val propFile = VersionProvider::class.java.classLoader.getResource("codyze.properties")!!
propFile.openStream().use {
properties.load(it)
}

// change property s.t. internal check fails
val oldValue = properties.setProperty("project.name", "test") as String
FileOutputStream(propFile.file).use {
properties.store(it, null)
}

// instantiate `VersionProvider` with altered properties -> properties in VersionProvider should now be empty
val vp = VersionProvider

// check empty properties through reflection
val vpProps = vp.javaClass.getDeclaredField("props")
.also { it.trySetAccessible() }
.let { it.get(vp) as Properties }
assertEquals(vpProps.size, 0)

// restore original properties file
properties.setProperty("project.name", oldValue)
FileOutputStream(propFile.file).use {
properties.store(it, null)
}
}
}

0 comments on commit c61e61e

Please sign in to comment.