错误在SpringBoot项目中使用DBUNIT运行Junit测试

huangapple go评论82阅读模式
英文:

Error running Junit test with DBUNIT on SpringBoot project

问题

我有一个 Junit 测试,在运行时出现以下错误:

    org.dbunit.dataset.NoSuchColumnException: AUTORISATION_BONANZA.ORGANISATION_ID - (非大写输入列:ORGANISATION_ID)在 ColumnNameToIndexes 缓存映射中。请注意,映射的列名不区分大小写。

实体类:

    @Entity
    @NoArgsConstructor
    @Data
    public class AutorisationBonanza implements Serializable {
    
        @Id
        @Column(name = "AUTORISATION_BONANZA_ID")
        private Long autorisationBonanzaId;
        private String pol;
        private String nomom;
    
        @ManyToOne
        @JoinColumn(name = "ORGANISATION_ID")
        private Organisation organisation;
    
    }

数据集:

    <AUTORISATION_BONANZA
            AUTORISATION_BONANZA_ID="1"
            POL="NOM"
            NOMOM="PRENOM"
            ORGANISATION_ID="1"
            />

以及:

    @Entity
    @NoArgsConstructor
    @Data
    public class Organisation implements Serializable {
    
        @Id
        @Column(name = "ORGANISATION_ID")
        private Long organisationId;
        private String code;
    
    }
英文:

I have a Junit test, that when I run it I have this error:

org.dbunit.dataset.NoSuchColumnException: AUTORISATION_BONANZA.ORGANISATION_ID -  (Non-uppercase input column: ORGANISATION_ID) in ColumnNameToIndexes cache map. Note that the map&#39;s column names are NOT case sensitive.

the entity

@Entity
@NoArgsConstructor
@Data
public class AutorisationBonanza implements Serializable {

	@Id
	@Column(name = &quot;AUTORISATION_BONANZA_ID&quot;)
	private Long autorisationBonanzaId;
	private String pol;
	private String nomom;


	@ManyToOne
	@JoinColumn(name = &quot;ORGANISATION_ID&quot;)
	private Organisation organisation;


}

the dataset:

&lt;AUTORISATION_BONANZA
        AUTORISATION_BONANZA_ID=&quot;1&quot;
        POL=&quot;NOM&quot;
        NOMOM=&quot;PRENOM&quot;
        ORGANISATION_ID=&quot;1&quot;
        /&gt;

and

@Entity
@NoArgsConstructor
@Data
public class Organisation implements Serializable {

	@Id
	@Column(name = &quot;ORGANISATION_ID&quot;)
	private Long organisationId;
	private String code;



}

答案1

得分: 1

尝试将以下内容添加到属性文件中:

org.dbunit.database.IMetadataHandler.implClassName=org.dbunit.ext.mysql.MySqlMetadataHandler
英文:

try to add this on the property file:

org.dbunit.database.IMetadataHandler.implClassName=org.dbunit.ext.mysql.MySqlMetadataHandler

huangapple
  • 本文由 发表于 2020年9月30日 03:08:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/64126096.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定